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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -