JQuery: How to call RESIZE event only once it's FINISHED resizing?

后端 未结 8 1308
一向
一向 2020-11-22 07:29

How do I call a function once the browser windows has FINISHED resizing?

I\'m trying to do it like so, but am having problems. I\'m using the JQuery Resize

8条回答
  •  生来不讨喜
    2020-11-22 08:05

    Underscore.js has a couple of great methods for this task: throttle and debounce. Even if you're not using Underscore, take a look at the source of these functions. Here's an example:

    var redraw = function() {'redraw logic here'};
    var debouncedRedraw = _.debounce(redraw, 750);
    $(window).on('resize', debouncedRedraw);
    

提交回复
热议问题