From f77e00174f29f2eef3581e965edf29ad2dd3213b Mon Sep 17 00:00:00 2001 From: jlukic Date: Fri, 1 May 2015 17:53:12 -0400 Subject: [PATCH] Fix selection min-height, fix pageup/down do not work when scrolling less than a page --- src/definitions/modules/dropdown.js | 18 +++++++++++++----- src/definitions/modules/dropdown.less | 1 + src/themes/default/modules/dropdown.variables | 5 +++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index d71a5252a..9e3567a72 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -427,7 +427,7 @@ $.fn.dropdown = function(parameters) { ; }, mouseEvents: function() { - module.verbose('Mouse detected binding mouse events'); + module.debug('Mouse detected binding mouse events'); if(module.is.multiple()) { $module .on('click' + eventNamespace, selector.label, module.event.label.click) @@ -1564,8 +1564,7 @@ $.fn.dropdown = function(parameters) { ? currentScroll - (itemHeight * itemsPerPage) : currentScroll + (itemHeight * itemsPerPage), $selectableItem = $item.not('.' + className.filtered), - isWithinRange = (newScroll < maxScroll && newScroll > 0), - + isWithinRange, $nextSelectedItem, elementIndex ; @@ -1574,8 +1573,17 @@ $.fn.dropdown = function(parameters) { ? $selectableItem.index($selectedItem) - itemsPerPage : $selectableItem.index($selectedItem) + itemsPerPage ; - $nextSelectedItem = $selectableItem.eq(elementIndex); - if(isWithinRange && $nextSelectedItem.length > 0) { + isWithinRange = (direction == 'up') + ? (elementIndex >= 0) + : (elementIndex < $selectableItem.length) + ; + $nextSelectedItem = (isWithinRange) + ? $selectableItem.eq(elementIndex) + : (direction == 'up') + ? $selectableItem.first() + : $selectableItem.last() + ; + if($nextSelectedItem.length > 0) { module.debug('Scrolling page', direction, $nextSelectedItem); $selectedItem .removeClass(className.selected) diff --git a/src/definitions/modules/dropdown.less b/src/definitions/modules/dropdown.less index 81d87d7ba..8daaf63df 100755 --- a/src/definitions/modules/dropdown.less +++ b/src/definitions/modules/dropdown.less @@ -345,6 +345,7 @@ transform: rotateZ(0deg); min-width: @selectionMinWidth; + min-height: @selectionMinHeight; background: @selectionBackground; display: @selectionDisplay; diff --git a/src/themes/default/modules/dropdown.variables b/src/themes/default/modules/dropdown.variables index 9577f7018..944f4b411 100644 --- a/src/themes/default/modules/dropdown.variables +++ b/src/themes/default/modules/dropdown.variables @@ -117,13 +117,14 @@ /*------------------- Types --------------------*/ - /* Selection */ @selectionMinWidth: 200px; +@borderEmWidth: 0.0785em; /* 2px / em size */ +@selectionMinHeight: @defaultInputLineHeight + (@selectionVerticalPadding * 2) - @borderEmWidth; @selectionBackground: @white; @selectionDisplay: inline-block; @selectionVerticalPadding: 0.78571em; -@selectionHorizontalPadding: 1.1em; +@selectionHorizontalPadding: 1em; @selectionIconDistance: 2em; @selectionPadding: @selectionVerticalPadding @selectionIconDistance @selectionVerticalPadding @selectionHorizontalPadding; @selectionZIndex: 10;