Skip to content

Instantly share code, notes, and snippets.

@kizzx2
Created June 16, 2017 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kizzx2/09733ec5753ce2c08ce94eaa99f2fe68 to your computer and use it in GitHub Desktop.
Save kizzx2/09733ec5753ce2c08ce94eaa99f2fe68 to your computer and use it in GitHub Desktop.
Get the correct window.innerHeight for 'orientationchanged' event
// 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