-
-
Save AntonLitvin/0119b47a1d705281f31b44530649d153 to your computer and use it in GitHub Desktop.
JavaScript window resize event with a 500ms delay
This file contains 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).on('resize-end', function() { | |
console.log('IMMA RESIZED 500 MILLI-FOCKING-SECONDS AGO'); | |
}); | |
// решение для того чтобы ресайз не срабатывал на скролл на мобилках | |
var width = $(window).width(); | |
$(window).resize(function(){ | |
if($(window).width() != width){ | |
//DO RESIZE | |
width = $(window).width(); | |
} | |
}); |
This file contains 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 resizeEnd; | |
$(window).on('resize', function() { | |
clearTimeout(resizeEnd); | |
resizeEnd = setTimeout(function() { | |
$(window).trigger('resize-end'); | |
}, 500); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment