Last active
January 19, 2023 00:40
-
-
Save dmitryshimkin/5691740 to your computer and use it in GitHub Desktop.
resizeStart and resizeEnd events for $(window)
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
| (function () { | |
| var THRESHOLD = 750; | |
| var timeoutId; | |
| var resizing = false; | |
| var win = $(window); | |
| win.on('resize', function () { | |
| var timeout = function () { | |
| clearTimeout(timeoutId); | |
| timeoutId = setTimeout(function () { | |
| resizing = false; | |
| win.trigger('resizeEnd'); | |
| }, THRESHOLD); | |
| }; | |
| if (!resizing) { | |
| resizing = true; | |
| win.trigger('resizeStart'); | |
| } | |
| timeout(); | |
| }); | |
| }()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment