Do something after jQuery resize or scroll is done, or has paused.

Instead of firing the event every time the resize/scroll is detected, which is constantly during a resize/scroll operation, this fires a designated amount of time after the last resize/scroll event has fired.

var id;
$(window).on("resize", function() {
    clearTimeout(id);
    id = setTimeout(doResizeEvent, 200);

});

function doResizeEvent(){
  console.log("Done resizing!");
}

Similar answer on which I based my code above:
http://stackoverflow.com/a/4298653/4669143

Example from answer:
http://jsfiddle.net/Zevan/c9UE5/1/

Published On: August 6, 2018Categories: jQueryTags: