Browse Source

Fix selection min-height, fix pageup/down do not work when scrolling less than a page

pull/2209/head
jlukic 9 years ago
parent
commit
f77e00174f
3 changed files with 17 additions and 7 deletions
  1. 18
      src/definitions/modules/dropdown.js
  2. 1
      src/definitions/modules/dropdown.less
  3. 5
      src/themes/default/modules/dropdown.variables

18
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)

1
src/definitions/modules/dropdown.less

@ -345,6 +345,7 @@
transform: rotateZ(0deg);
min-width: @selectionMinWidth;
min-height: @selectionMinHeight;
background: @selectionBackground;
display: @selectionDisplay;

5
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;

Loading…
Cancel
Save