Skip to content

Commit df8fb40

Browse files
committed
arrow functions
1 parent 1f37369 commit df8fb40

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/plugins/virtual_scroll/plugin.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function(this:TomSelect) {
3232
if( !self.settings.shouldLoadMore ){
3333

3434
// return true if additional results should be loaded
35-
self.settings.shouldLoadMore = function():boolean{
35+
self.settings.shouldLoadMore = ():boolean=>{
3636

3737
const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
3838
if( scroll_percent > 0.9 ){
@@ -64,7 +64,7 @@ export default function(this:TomSelect) {
6464

6565

6666
// can we load more results for given query?
67-
function canLoadMore(query:string):boolean{
67+
const canLoadMore = (query:string):boolean => {
6868

6969
if( typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions ){
7070
return false;
@@ -75,23 +75,23 @@ export default function(this:TomSelect) {
7575
}
7676

7777
return false;
78-
}
78+
};
7979

80-
function clearFilter(option:TomOption, value:string):boolean{
80+
const clearFilter = (option:TomOption, value:string):boolean => {
8181
if( self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0 ){
8282
return true;
8383
}
8484
return false;
85-
}
85+
};
8686

8787

8888
// set the next url that will be
89-
self.setNextUrl = function(value:string,next_url:any):void{
89+
self.setNextUrl = (value:string,next_url:any):void => {
9090
pagination[value] = next_url;
9191
};
9292

9393
// getUrl() to be used in settings.load()
94-
self.getUrl = function(query:string):any{
94+
self.getUrl = (query:string):any =>{
9595

9696
if( query in pagination ){
9797
const next_url = pagination[query];
@@ -175,22 +175,22 @@ export default function(this:TomSelect) {
175175

176176
// add scroll listener and default templates
177177
self.on('initialize',()=>{
178-
default_values = Object.keys(this.options);
178+
default_values = Object.keys(self.options);
179179
dropdown_content = self.dropdown_content;
180180

181181
// default templates
182182
self.settings.render = Object.assign({}, {
183-
loading_more:function(){
183+
loading_more:() => {
184184
return `<div class="loading-more-results">Loading more results ... </div>`;
185185
},
186-
no_more_results:function(){
186+
no_more_results:() =>{
187187
return `<div class="no-more-results">No more results</div>`;
188188
}
189189
},self.settings.render);
190190

191191

192192
// watch dropdown content scroll position
193-
dropdown_content.addEventListener('scroll',function(){
193+
dropdown_content.addEventListener('scroll',()=>{
194194

195195
if( !self.settings.shouldLoadMore.call(self) ){
196196
return;

0 commit comments

Comments
 (0)