-
-
Save lega911/d4a3b81f37fbfb9018fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alight.filters.throttle = { | |
init: function(delay, scope) { | |
this.delay = Number(delay); | |
this.to = null; | |
this.scope = scope; | |
}, | |
onChange: function(value) { | |
var that; | |
that = this; | |
if (this.to) { | |
clearTimeout(this.to); | |
} | |
this.to = setTimeout(function() { | |
that.to = null; | |
that.setValue(value); | |
that.scope.$scan(); | |
}, this.delay); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alight.filters.throttle = { | |
init: function(delay, scope, env) { | |
delay = Number(delay); | |
var to = null; | |
return { | |
onChange: function(value) { | |
if(to) { | |
clearTimeout(to); | |
} | |
to = setTimeout(function() { | |
to = null; | |
env.setValue(value); | |
scope.$scan(); | |
}, delay); | |
} | |
} // return | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment