javascript - Respond when page orientation change -
i've got below function window resize. question how make work on window resize page orientation changed?
$(window).resize(function() { if(this.ab) cleartimeout(this.ab); this.ab = settimeout(function() { $(this).trigger('winresized'); },1000); }); $(window).on('winresized', function() { });
you can use combination of resize , orientationchange event:
$(window).on("resize orientationchange", function() { // fires on both resize & orientation change if(this.ab) cleartimeout(this.ab); this.ab = settimeout(function() { $(this).trigger('winresized'); },1000); });
Comments
Post a Comment