From 18d9a373d63033aa429e982179fa93c323ca7925 Mon Sep 17 00:00:00 2001 From: Felix Nagel Date: Wed, 28 Dec 2011 19:03:18 +0100 Subject: [PATCH] improved: menu height calculation and collision detection, thx to @Cito , see #189 --- ui/jquery.ui.selectmenu.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index 9d48582bb..7d66e7be9 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -420,13 +420,10 @@ $.widget("ui.selectmenu", { // reset height to auto this.list.css( 'height', 'auto' ); var listH = this.listWrap.height(); - // calculate default max height - if ( o.maxHeight && o.maxHeight < listH ) { - this.list.height( o.maxHeight ); - } else { - var winH = $( window ).height() / 3; - if ( winH < listH ) this.list.height( winH ); - } + var winH = $( window ).height(); + // calculate default max height + var maxH = o.maxHeight ? Math.min( o.maxHeight, winH ) : winH / 3; + if ( listH > maxH ) this.list.height( maxH ); // save reference to actionable li's (not group label li's) this._optionLis = this.list.find( 'li:not(.' + self.widgetBaseClass + '-group)' ); @@ -857,7 +854,6 @@ $.widget("ui.selectmenu", { var selected = this._selectedOptionLi(); var _offset = "0 " + ( this.list.offset().top - selected.offset().top - ( this.newelement.outerHeight() + selected.outerHeight() ) / 2); } - // update zIndex if jQuery UI is able to process this.listWrap .zIndex( this.element.zIndex() + 1 ) .position({ @@ -866,7 +862,7 @@ $.widget("ui.selectmenu", { my: o.positionOptions.my, at: o.positionOptions.at, offset: o.positionOptions.offset || _offset, - collision: o.positionOptions.collision || 'flip' + collision: o.positionOptions.collision || o.style == "popup" ? 'fit' :'flip' }); } }); -- 2.39.5