Added resetScrollPosition option

This commit is contained in:
Paul Laros 2017-01-12 15:13:21 +01:00
parent 2280371b04
commit 24c6803391
2 changed files with 6 additions and 1 deletions

View file

@ -65,6 +65,7 @@ Or include Choices directly:
search: true, search: true,
searchFloor: 1, searchFloor: 1,
flip: true, flip: true,
resetScrollPosition: true,
regexFilter: null, regexFilter: null,
shouldSort: true, shouldSort: true,
sortFilter: () => {...}, sortFilter: () => {...},

View file

@ -60,6 +60,7 @@ class Choices {
search: true, search: true,
searchFloor: 1, searchFloor: 1,
flip: true, flip: true,
resetScrollPosition: true,
regexFilter: null, regexFilter: null,
shouldSort: true, shouldSort: true,
sortFilter: sortByAlpha, sortFilter: sortByAlpha,
@ -391,8 +392,11 @@ class Choices {
// Clear choices // Clear choices
this.choiceList.innerHTML = ''; this.choiceList.innerHTML = '';
// Scroll back to top of choices list // Scroll back to top of choices list
this.choiceList.scrollTop = 0; if(this.config.resetScrollPosition){
this.choiceList.scrollTop = 0;
}
// If we have grouped options // If we have grouped options
if (activeGroups.length >= 1 && this.isSearching !== true) { if (activeGroups.length >= 1 && this.isSearching !== true) {