Skip to content

Commit

Permalink
Updated Selectivity.js version to 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
msx2 committed May 14, 2015
1 parent 69a41d1 commit 334cdce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
47 changes: 15 additions & 32 deletions vendor/assets/javascripts/selectivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -2353,8 +2353,6 @@ function SelectivityDropdown(options) {
this.position();
this.setupCloseHandler();

this._scrolledProxy = debounce(this._scrolled.bind(this), 50);

this._suppressMouseWheel();

if (options.showSearchInput) {
Expand All @@ -2364,6 +2362,8 @@ function SelectivityDropdown(options) {

EventDelegator.call(this);

this.$results.on('scroll touchmove touchend', debounce(this._scrolled.bind(this), 50));

this.showLoading();

setTimeout(this.triggerOpen.bind(this), 1);
Expand Down Expand Up @@ -2744,29 +2744,6 @@ $.extend(SelectivityDropdown.prototype, EventDelegator.prototype, {
}
},

/**
* @private
*/
_scrollToHighlight: function(options) {

var el;
if (this.highlightedResult) {
var quotedId = Selectivity.quoteCssAttr(this.highlightedResult.id);
el = this.$('.selectivity-result-item[data-item-id=' + quotedId + ']')[0];
} else if (this.loadMoreHighlighted) {
el = this.$('.selectivity-load-more')[0];
} else {
return; // no highlight to scroll to
}

var rect = el.getBoundingClientRect(),
containerRect = this.$results[0].getBoundingClientRect();

if (rect.top < containerRect.top || rect.bottom > containerRect.bottom) {
el.scrollIntoView(options.alignToTop);
}
},

/**
* @private
*/
Expand Down Expand Up @@ -3019,21 +2996,27 @@ function listener(selectivity, $input) {
}

function scrollToHighlight() {
var el;
var $el;
if (dropdown.highlightedResult) {
var quotedId = Selectivity.quoteCssAttr(dropdown.highlightedResult.id);
el = dropdown.$('.selectivity-result-item[data-item-id=' + quotedId + ']')[0];
$el = dropdown.$('.selectivity-result-item[data-item-id=' + quotedId + ']');
} else if (dropdown.loadMoreHighlighted) {
el = dropdown.$('.selectivity-load-more')[0];
$el = dropdown.$('.selectivity-load-more');
} else {
return; // no highlight to scroll to
}

var rect = el.getBoundingClientRect(),
containerRect = dropdown.$results[0].getBoundingClientRect();
var position = $el.position();
if (!position) {
return;
}

if (rect.top < containerRect.top || rect.bottom > containerRect.bottom) {
el.scrollIntoView(delta < 0);
var top = position.top;
var elHeight = $el.height();
var resultsHeight = dropdown.$results.height();
if (top < 0 || top > resultsHeight - elHeight) {
top += dropdown.$results.scrollTop();
dropdown.$results.scrollTop(delta < 0 ? top : top - resultsHeight + elHeight);
}
}

Expand Down
1 change: 1 addition & 0 deletions vendor/assets/stylesheets/selectivity/dropdown.sass
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
.selectivity-results-container
max-height: 28em
overflow: auto
position: relative

.selectivity-load-more,
.selectivity-result-item
Expand Down

0 comments on commit 334cdce

Please sign in to comment.