Skip to content

Instantly share code, notes, and snippets.

@AntonLitvin
Forked from branneman/event.js
Last active August 11, 2019 14:48
Show Gist options
  • Save AntonLitvin/0119b47a1d705281f31b44530649d153 to your computer and use it in GitHub Desktop.
Save AntonLitvin/0119b47a1d705281f31b44530649d153 to your computer and use it in GitHub Desktop.
JavaScript window resize event with a 500ms delay
$(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();
}
});
$(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