Created
June 16, 2017 02:12
-
-
Save kizzx2/09733ec5753ce2c08ce94eaa99f2fe68 to your computer and use it in GitHub Desktop.
Get the correct window.innerHeight for 'orientationchanged' event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Wait until innerheight changes, for max 120 frames | |
function orientationChanged() { | |
const timeout = 120; | |
return new window.Promise(function(resolve) { | |
const go = (i, height0) => { | |
window.innerHeight != height0 || i >= timeout ? | |
resolve() : | |
window.requestAnimationFrame(() => go(i + 1, height0)); | |
}; | |
go(0, window.innerHeight); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment