Firing resize event only once when resizing is finished

Home   »   Firing resize event only once when resizing is finished

var resizeId;
window.addEventListener('resize', function() {
    clearTimeout(resizeId);
    resizeId = setTimeout(doneResizing, 500);
});

function doneResizing(){
    //whatever we want to do
}

Leave a Reply

Your email address will not be published.