ryanve / response.js

Responsive design toolkit
http://responsejs.com
Other
801 stars 123 forks source link

Device orientation change #52

Closed niallobrien closed 7 years ago

niallobrien commented 10 years ago

Hi all, I'm currently using Response.js in conjunction with Backstretch.js. Upon device orientation change it seems that my Backstretch code isn't being re-called and I had to add something like the following to get it to work:

R.action(function() {
  if (R.viewportW() < "640" ) {
    detectOrientation();
      window.onorientationchange = detectOrientation;
      function detectOrientation(){
        if(typeof window.onorientationchange != 'undefined'){
          if ( (orientation >= -90) && ( orientation <= 180) )  {
            $("#selector").backstretch("/images/to-backstretch.jpg");
          }
        }
      }
   }
}

Shouldn't this be part of Response.js?

Thanks in advance.

ryanve commented 10 years ago

Does Backstretch ever adjust anything on resize? I've not used Backstretch. Is it meant to be resize aware? I see no reason why that would be a part of Response.

niallobrien commented 7 years ago

Thanks for pointing that out @ryanve. Closing the issue for now as it can be resolved using the method I showed above.

ryanve commented 7 years ago

cool