Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let h;
- switch (window.orientation) {
- case 0:
- h = "portrait";
- break;
- case 180:
- h = "portrait-upside-down";
- break;
- case -90:
- h = "landscape-clockwise";
- break;
- case 90:
- h = "landscape-counter-clockwise";
- break;
- }
- window.addEventListener("deviceorientation",
- function(a) {
- switch (h) {
- case "portrait":
- (I = Math.round(100 * a.beta) / 100 - 30),
- (F = Math.round(100 * a.gamma) / 100);
- break;
- case "portrait-upside-down":
- (I = -1 * (Math.round(100 * a.beta) / 100 + 30)),
- (F = (Math.round(100 * a.gamma) / 100) * -1);
- break;
- case "landscape-clockwise":
- (F = (Math.round(100 * a.beta) / 100) * -1),
- (I = Math.round(100 * a.gamma) / 100 - 30);
- break;
- case "landscape-counter-clockwise":
- (F = Math.round(100 * a.beta) / 100),
- (I = -1 * (Math.round(100 * a.gamma) / 100 + 30));
- break;
- }
- }
- );
Add Comment
Please, Sign In to add comment