JSFiddle - React, Tailwind, and code Playground
JavaScript
var oldSide = window.innerWidth - 200;
function debounce(fn, delay) {
var delayId, delay = delay || 200;
return function () {
var scope = this, args = arguments;
clearTimeout(delayId);
delayId = setTimeout(function () {
fn.apply(scope, Array.prototype.slice.call(args));
}, delay);
}
}
$(window).resize(debounce(function (e) {
var newSide = window.innerWidth - 200;
if (newSide * oldSide <= 0) {
console.log(window.innerWidth);
return;
}
console.log('The side stays');
oldSide = newSide;
}));