How to wait for the 'end' of 'resize' event and only then perform an action?

后端 未结 24 1220
深忆病人
深忆病人 2020-11-22 09:39

So I currently use something like:

$(window).resize(function(){resizedw();});

But this gets called many times while resizing process goes o

24条回答
  •  醉酒成梦
    2020-11-22 10:09

    This is the code that I write according to @Mark Coleman answer:

    $(window).resize(function() {
        clearTimeout(window.resizedFinished);
        window.resizedFinished = setTimeout(function(){
            console.log('Resized finished.');
        }, 250);
    });
    

    Thanks Mark!

提交回复
热议问题