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


/ Published in: JavaScript
Save to your folder(s)

The resizeend event.
It works for me


Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.