How can I reverse the effect of screen rotation on Chrome?

Viewed 94

I'm creating an application where user can rotate his mobile but the image inside web page will rotate in anti direction so it will seems to be still.

var rotate = 0 - window.orientation;
image.style.transform = "rotateZ("+ rotate * (Math.PI/180) +"deg)";
1 Answers

After working several hours i created a solution that's worked for me. Find the change in orientation and add Angle to it Here is the Code:

          var difference = initialAngleOfImage - Math.abs(event.alpha);
          if(difference >= 0 && difference <= 15){
              difference = 15;
          }
          if(difference >= 16 && difference <= 30){
              difference = 15;
          }
          else if(difference >= 31 && difference <=45){
              difference = 45;
          }
          else if(difference >= 46 && difference <=60){
              difference = 60;
          }
          else if(difference >= 61 && difference <=90){
              difference = 30;
          }
Related