From 342e663c4ae656287edb6ecb704b154ad9955cbc Mon Sep 17 00:00:00 2001 From: dosource Date: Sun, 3 Nov 2013 20:24:30 +0100 Subject: [PATCH 1/2] Don't scroll up if unnecessary Scroll down in dropdown then press UP. Before fix : dropdown scrolls up even if unnecessary, e.g. the new active option is entirely visible in the dropdown. After : dropdown scrolls up only if the target option is out of the visible part of the dropdown. --- src/selectize.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/selectize.js b/src/selectize.js index 41627e160..8baf36172 100644 --- a/src/selectize.js +++ b/src/selectize.js @@ -748,7 +748,7 @@ $.extend(Selectize.prototype, { scroll_top = y; scroll_bottom = y - height_menu + height_item; - if (y + height_item > height_menu - scroll) { + if (y + height_item > height_menu + scroll) { self.$dropdown_content.stop().animate({scrollTop: scroll_bottom}, animate ? self.settings.scrollDuration : 0); } else if (y < scroll) { self.$dropdown_content.stop().animate({scrollTop: scroll_top}, animate ? self.settings.scrollDuration : 0); @@ -1815,4 +1815,4 @@ $.extend(Selectize.prototype, { return html; } -}); \ No newline at end of file +}); From 7350e93bc79b7d4e630056704217bd3a92c14167 Mon Sep 17 00:00:00 2001 From: dosource Date: Sun, 3 Nov 2013 20:40:00 +0100 Subject: [PATCH 2/2] Consistency this-self --- src/selectize.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/selectize.js b/src/selectize.js index 8baf36172..3156cb6e2 100644 --- a/src/selectize.js +++ b/src/selectize.js @@ -1378,10 +1378,10 @@ $.extend(Selectize.prototype, { var isFull = self.isFull(); var isLocked = self.isLocked; - this.$wrapper + self.$wrapper .toggleClass('rtl', self.rtl); - this.$control + self.$control .toggleClass('focus', self.isFocused) .toggleClass('disabled', self.isDisabled) .toggleClass('required', self.isRequired) @@ -1393,7 +1393,7 @@ $.extend(Selectize.prototype, { .toggleClass('has-options', !$.isEmptyObject(self.options)) .toggleClass('has-items', self.items.length > 0); - this.$control_input.data('grow', !isFull && !isLocked); + self.$control_input.data('grow', !isFull && !isLocked); }, /** @@ -1461,7 +1461,7 @@ $.extend(Selectize.prototype, { self.$dropdown.css({visibility: 'hidden', display: 'block'}); self.positionDropdown(); self.$dropdown.css({visibility: 'visible'}); - self.trigger('dropdown_open', this.$dropdown); + self.trigger('dropdown_open', self.$dropdown); }, /** @@ -1471,7 +1471,7 @@ $.extend(Selectize.prototype, { var self = this; var trigger = self.isOpen; - if (self.settings.mode === 'single' && this.items.length) { + if (self.settings.mode === 'single' && self.items.length) { self.hideInput(); }