-
-
Save fend25/2e2f54b4d762a3a61f26 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 = { | |
data: { | |
delay: 0, | |
to: null, | |
scope: null | |
} | |
init: function(delay, scope) { | |
data.delay = Number(delay); | |
data.to = null; | |
data.scope = scope; | |
}, | |
onChange: function(value) { | |
if (data.to) { | |
clearTimeout(data.to); | |
} | |
data.to = setTimeout(function() { | |
data.to = null; | |
data.setValue(value); | |
data.scope.$scan(); | |
}, data.delay); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment