pinafore/src/routes/_utils/fullscreen.js
Nolan Lawson 4bd181d3cc
fix: update Sapper to latest (#775)
* fix: update to latest sapper

fixes #416

* fix error and debug pages

* requestIdleCallback makes column switching feel way nicer than double rAF

* add export feature

* add better csp info

* workaround for sapper sub-page issue

* clarify in readme about exporting

* fix now config

* switch from rIC to triple raf

* style-loader is no longer used

* update theming guide
2018-12-11 07:31:48 -08:00

24 lines
949 B
JavaScript

export const isFullscreen = () => !!(document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement)
export const attachFullscreenListener = (listener) => {
if ('onfullscreenchange' in document) {
document.addEventListener('fullscreenchange', listener)
} else if ('onwebkitfullscreenchange' in document) {
document.addEventListener('webkitfullscreenchange', listener)
} else if ('onmozfullscreenchange' in document) {
document.addEventListener('mozfullscreenchange', listener)
}
}
export const detachFullscreenListener = (listener) => {
if ('onfullscreenchange' in document) {
document.removeEventListener('fullscreenchange', listener)
} else if ('onwebkitfullscreenchange' in document) {
document.removeEventListener('webkitfullscreenchange', listener)
} else if ('onmozfullscreenchange' in document) {
document.removeEventListener('mozfullscreenchange', listener)
}
}