-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventBoiler.min.js
2 lines (2 loc) · 957 Bytes
/
eventBoiler.min.js
1
2
/* eventBoiler v0.2.2 by @ryanpcmcquen */
(function(){'use strict';var odis={throttle:function(func,delay){delay=delay||42;var waiting=false,funcTimeoutId;return function(){if(!waiting){waiting=true;clearTimeout(funcTimeoutId);funcTimeoutId=setTimeout(function(){func.call();waiting=false;},delay);}};}};var eventBoiler=function(selector,typeOfEvent,func,throttle){throttle=throttle||true;if(throttle){document.querySelector(selector).addEventListener(typeOfEvent,odis.throttle(func));}else{document.querySelector(selector).addEventListener(typeOfEvent,func);}};eventBoiler.all=function(selectors,typeOfEvent,func,throttle){throttle=throttle||true;if(throttle){Array.prototype.slice.call(document.querySelectorAll(selectors)).map(function(i){i.addEventListener(typeOfEvent,odis.throttle(func));});}else{Array.prototype.slice.call(document.querySelectorAll(selectors)).map(function(i){i.addEventListener(typeOfEvent,func);});}};window.evBo=eventBoiler;}());