JSFiddle - React, Tailwind, and code Playground
by Julien Etienne
JavaScript
var a = document.getElementById('yo');
var i = 0;
var gg = function () {
i++;
a.innerHTML = 'Hey' + i;
}
Object.prototype.resizilla = function (handler, delay, inception) {
var arr = arguments;
function debounce(func, delay, inception) {
var timeout;
return function () {
var context = this,
args = arguments;
var lastCall = function () {
timeout = null;
if (!inception) func.apply(context, args);
};
var instant = inception && !timeout;
clearTimeout(timeout);
timeout = setTimeout(lastCall, delay);
if (instant) func.apply(context, args);
};
};
var handlerFunc = debounce(function () {
arr[0]();
}, arr[1], arr[2]);
if (this.attachEvent) {
this.attachEvent('onresize', handlerFunc);
} else if (this.addEventListener) {
this.addEventListener('resize', handlerFunc, true);
} else {}
}
window.resizilla(gg, 100, false);