mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-13 11:22:46 +02:00
Merge pull request #96 from paullaros/master
Added resetScrollPosition option
This commit is contained in:
commit
2af4c51949
|
@ -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: () => {...},
|
||||||
|
@ -254,6 +255,13 @@ Pass an array of objects:
|
||||||
|
|
||||||
**Usage:** Whether the dropdown should appear above the input (rather than beneath) if there is not enough space within the window.
|
**Usage:** Whether the dropdown should appear above the input (rather than beneath) if there is not enough space within the window.
|
||||||
|
|
||||||
|
### resetScrollPosition
|
||||||
|
**Type:** `Boolean` **Default:** `true`
|
||||||
|
|
||||||
|
**Input types affected:** `select-multiple`
|
||||||
|
|
||||||
|
**Usage:** Whether the scroll position should reset after adding an item.
|
||||||
|
|
||||||
### regexFilter
|
### regexFilter
|
||||||
**Type:** `Regex` **Default:** `null`
|
**Type:** `Regex` **Default:** `null`
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue