Advertisement
Milotronik

Debounce Resize Event JQuery

Oct 13th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function debouncer( func , timeout ) {
  2.    var timeoutID , timeout = timeout || 200;
  3.    return function () {
  4.       var scope = this , args = arguments;
  5.       clearTimeout( timeoutID );
  6.       timeoutID = setTimeout( function () {
  7.           func.apply( scope , Array.prototype.slice.call( args ) );
  8.       } , timeout );
  9.    }
  10. }
  11.  
  12.  
  13. $( window ).resize( debouncer( function ( e ) {
  14.     // do stuff
  15. } ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement