Skip to content

Instantly share code, notes, and snippets.

@fend25
Forked from lega911/1.js
Last active December 18, 2015 19:16
Show Gist options
  • Save fend25/2e2f54b4d762a3a61f26 to your computer and use it in GitHub Desktop.
Save fend25/2e2f54b4d762a3a61f26 to your computer and use it in GitHub Desktop.
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