Guest User

Untitled

a guest
Dec 28th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. let h;
  2. switch (window.orientation) {
  3. case 0:
  4. h = "portrait";
  5. break;
  6. case 180:
  7. h = "portrait-upside-down";
  8. break;
  9. case -90:
  10. h = "landscape-clockwise";
  11. break;
  12. case 90:
  13. h = "landscape-counter-clockwise";
  14. break;
  15. }
  16.  
  17. window.addEventListener("deviceorientation",
  18. function(a) {
  19. switch (h) {
  20. case "portrait":
  21. (I = Math.round(100 * a.beta) / 100 - 30),
  22. (F = Math.round(100 * a.gamma) / 100);
  23. break;
  24. case "portrait-upside-down":
  25. (I = -1 * (Math.round(100 * a.beta) / 100 + 30)),
  26. (F = (Math.round(100 * a.gamma) / 100) * -1);
  27. break;
  28. case "landscape-clockwise":
  29. (F = (Math.round(100 * a.beta) / 100) * -1),
  30. (I = Math.round(100 * a.gamma) / 100 - 30);
  31. break;
  32. case "landscape-counter-clockwise":
  33. (F = Math.round(100 * a.beta) / 100),
  34. (I = -1 * (Math.round(100 * a.gamma) / 100 + 30));
  35. break;
  36. }
  37. }
  38. );
Add Comment
Please, Sign In to add comment