Created
January 13, 2011 23:52
defines :delay(time) pseudo for Element.Event in MooTools
This file contains 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
This file contains 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
Event.definePseudo('onPause', function(split, fn, args){ | |
clearTimeout(fn.onPauseId); | |
fn.onPauseId = fn.delay(split.value, this, args); | |
}); | |
someElement.addEvent('keyup:onPause(100)', function(){ | |
// will execute 100ms after last keyup occurs, great for keyboard input | |
}); |
ibolmo, an element could have multiple of these events bound to it so, no, you probably shouldn't use element storage. The function you pass in will almost always be an anon function and wont be used anywhere else, therefor it makes a likely candidate for the timeout id. Logically it makes sense as well - the timer is for the function, not the element.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd imagine that this is bound to the element. Couldn't you store the delay timer in storage?