|
1117 | 1117 | if ( /\d/.test(optionHeight) ) {
|
1118 | 1118 | // Deduct height of header & border/padding to find height available for checkboxes.
|
1119 | 1119 | var $header = self.$header.filter(':visible');
|
1120 |
| - var headerHeight = $header.outerHeight(true) + self._jqHeightFix($header); |
| 1120 | + var headerHeight = $header.outerHeight(true); |
1121 | 1121 | var menuBorderPaddingHt = this.$menu.outerHeight(false) - this.$menu.height();
|
1122 | 1122 | var cbBorderPaddingHt = this.$checkboxes.outerHeight(false) - this.$checkboxes.height();
|
1123 | 1123 |
|
|
1133 | 1133 |
|
1134 | 1134 | var overflowSetting = 'hidden';
|
1135 | 1135 | var itemCount = 0;
|
1136 |
| - var ulHeight = 4; // Adjustment for hover height included here. |
| 1136 | + var hoverAdjust = 4; // Adjustment for hover height included here. |
| 1137 | + var ulHeight = hoverAdjust; |
| 1138 | + var ulTop = -1; |
1137 | 1139 |
|
1138 |
| - // The following adds up item heights. If the height sum exceeds the option height or if the number |
| 1140 | + // The following determines the how many items are visible per the menuHeight option. |
| 1141 | + // If the visible height calculation exceeds the calculated maximum height or if the number |
1139 | 1142 | // of item heights summed equal or exceed the native select size attribute, the loop is aborted.
|
1140 | 1143 | // If the loop is aborted, this means that the menu must be scrolled to see all the items.
|
1141 | 1144 | self.$checkboxes.find('li:not(.ui-multiselect-optgroup),a').filter(':visible').each( function() {
|
1142 |
| - ulHeight += $(this).outerHeight(true) + self._jqHeightFix(this); |
| 1145 | + if (ulTop < 0) { |
| 1146 | + ulTop = this.offsetTop; |
| 1147 | + } |
| 1148 | + ulHeight = this.offsetTop + this.offsetHeight - ulTop + hoverAdjust; |
1143 | 1149 | if (useSelectSize && ++itemCount >= elSelectSize || ulHeight > maxHeight) {
|
1144 | 1150 | overflowSetting = 'auto';
|
1145 | 1151 | if (!useSelectSize) {
|
|
1169 | 1175 | return domRect.right - domRect.left;
|
1170 | 1176 | },
|
1171 | 1177 |
|
1172 |
| - /** |
1173 |
| - * Calculate accurate outerHeight(false) using getBoundingClientRect() |
1174 |
| - * Note that this presumes that the element is visible in the layout. |
1175 |
| - * @param {node} DOM node or jQuery equivalent to get height for. |
1176 |
| - * @returns {float} Decimal floating point value for the height. |
1177 |
| - */ |
1178 |
| - _getBCRHeight: function(elem) { |
1179 |
| - if (!elem || !!elem.jquery && !elem[0]) { |
1180 |
| - return null; |
1181 |
| - } |
1182 |
| - var domRect = !!elem.jquery ? elem[0].getBoundingClientRect() : elem.getBoundingClientRect(); |
1183 |
| - return domRect.bottom - domRect.top; |
1184 |
| - }, |
1185 |
| - |
1186 | 1178 | /**
|
1187 | 1179 | * Calculate jQuery width correction factor to fix floating point round-off errors.
|
1188 | 1180 | * Note that this presumes that the element is visible in the layout.
|
|
1198 | 1190 | : this._getBCRWidth(elem) - $(elem).outerWidth(false);
|
1199 | 1191 | },
|
1200 | 1192 |
|
1201 |
| - /** |
1202 |
| - * Calculate jQuery height correction factor to fix floating point round-off errors. |
1203 |
| - * Note that this presumes that the element is visible in the layout. |
1204 |
| - * @param {node} DOM node or jQuery equivalent to get height for. |
1205 |
| - * @returns {float} Correction value for the height--typically a decimal < 1.0 |
1206 |
| - */ |
1207 |
| - _jqHeightFix: function(elem) { |
1208 |
| - if (!elem || !!elem.jquery && !elem[0]) { |
1209 |
| - return null; |
1210 |
| - } |
1211 |
| - return !!elem.jquery |
1212 |
| - ? this._getBCRHeight(elem[0]) - elem.outerHeight(false) |
1213 |
| - : this._getBCRHeight(elem) - $(elem).outerHeight(false); |
1214 |
| - }, |
1215 |
| - |
1216 | 1193 | /**
|
1217 | 1194 | * Moves focus up or down the options list
|
1218 | 1195 | * @param {number} which key that triggered the traversal
|
|
0 commit comments