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

后端 未结 24 1472
深忆病人
深忆病人 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:16

    There is an elegant solution using the Underscore.js So, if you are using it in your project you can do the following -

    $( window ).resize( _.debounce( resizedw, 500 ) );
    

    This should be enough :) But, If you are interested to read more on that, you can check my blog post - http://rifatnabi.com/post/detect-end-of-jquery-resize-event-using-underscore-debounce(deadlink)

提交回复
热议问题