Last active
August 23, 2017 19:53
-
-
Save imelgrat/736bd9fec263b7b60374 to your computer and use it in GitHub Desktop.
Prevent jerky motion upon resizing browser window by waiting until window resizing stops (no external libraries). Full article at: http://imelgrat.me/javascript/debouncing-javascript-events/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).bind('resize', function(e) | |
{ | |
window.resizeEvt; | |
$(window).resize(function() | |
{ | |
clearTimeout(window.resizeEvt); | |
window.resizeEvt = setTimeout(function() | |
{ | |
if($(window).width() != previous_width) | |
{ | |
//Do your stuff here | |
console.log('Resized finished.'); | |
} | |
}, 250); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment