diff --git a/src/jquery.webui-popover.js b/src/jquery.webui-popover.js index 4244804..9617a29 100644 --- a/src/jquery.webui-popover.js +++ b/src/jquery.webui-popover.js @@ -833,6 +833,8 @@ container = this.options.container, clientWidth = container.innerWidth(), clientHeight = container.innerHeight(), + windowHeight = $(window).height(), + windowScrollHeight = $(window).scrollTop(), scrollTop = container.scrollTop(), scrollLeft = container.scrollLeft(), pageX = Math.max(0, pos.left - scrollLeft), @@ -898,6 +900,13 @@ placement = isH ? 'left-top' : 'top-left'; } } + if(isV) { + if( (pos.top - windowScrollHeight) > windowHeight/3*2 ) { + placement = placement.replace('bottom','top'); + } else { + placement = placement.replace('top','bottom'); + } + } } else if (placement === 'auto-top') { if (pageX < clientWidth / 3) { placement = 'top-right';