Created
March 3, 2017 12:20
-
-
Save italodr/cb7b85bae103d1c3146ad89c2c01f0d1 to your computer and use it in GitHub Desktop.
Window width resize observer
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
/** | |
* jQuery on resize by @italo_dr (twitter) @italodr (github) | |
* Fix issue with iphone/ipad "resize" on height. When appears domain | |
* field and bottom menu. | |
* Add timer to launch function on resize end | |
*/ | |
var timer; | |
var windowWidth = $(window).width(); | |
$(window).on('resize', function(){ | |
if ($(window).width() != windowWidth) { | |
windowWidth = $(window).width(); | |
timer && clearTimeout(timer); | |
timer = setTimeout(function() { | |
/* Your function here */ | |
}, 100); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment