Last active
August 22, 2018 20:25
-
-
Save drenther/467b7c1c8cd5c8ad6c17efcef4662686 to your computer and use it in GitHub Desktop.
src/pageVisibilityUtils.js for react-page-visibility-example
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
export const pageVisibilityApi = () => { | |
let hidden, visibilityChange; | |
if (typeof document.hidden !== "undefined") { | |
// Opera 12.10 and Firefox 18 and later support | |
hidden = "hidden"; | |
visibilityChange = "visibilitychange"; | |
} else if (typeof document.msHidden !== "undefined") { | |
hidden = "msHidden"; | |
visibilityChange = "msvisibilitychange"; | |
} else if (typeof document.webkitHidden !== "undefined") { | |
hidden = "webkitHidden"; | |
visibilityChange = "webkitvisibilitychange"; | |
} | |
return { hidden, visibilityChange }; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment