Posted By

cerxx on 09/22/19


Tagged

jquery js-hacks


Versions (?)

JQuery - how to wait for the "end" of the "resize" event and only then perform the action?


 / Published in: JavaScript
 

URL: http://qaru.site/questions/33786/jquery-how-to-wait-for-the-end-of-resize-event-and-only-then-perform-an-action

The resizeend event. It works for me

  1. var rtime;
  2. var timeout = false;
  3. var delta = 200;
  4. $(window).resize(function() {
  5. rtime = new Date();
  6. if (timeout === false) {
  7. timeout = true;
  8. setTimeout(resizeend, delta);
  9. }
  10. });
  11.  
  12. function resizeend() {
  13. if (new Date() - rtime < delta) {
  14. setTimeout(resizeend, delta);
  15. } else {
  16. timeout = false;
  17. alert('Done resizing');
  18. }
  19. }

Report this snippet  

You need to login to post a comment.