Last active
November 16, 2016 15:15
-
-
Save rendfall/502c0e536d5e97ca1330c0b8d51f03e3 to your computer and use it in GitHub Desktop.
invokeOnce
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
function invokeOnce($element, eventType, handler, useCapture = false) { | |
var args = arguments; | |
$element.addEventListener(eventType, function selfRemoving(event) { | |
event.target.removeEventListener(event.type, selfRemoving, useCapture); | |
return handler.apply(handler, args); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment