Skip to content

Commit

Permalink
disable the fullscreen button for chrome on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
bengarrett committed Apr 3, 2020
1 parent e80bab7 commit 924386b
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/js/dosee-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,22 @@
// (https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API)
DOSee.fullScreen = () => {
if (typeof document.fullscreenElement === `undefined`) return;
const element = document.getElementById(`doseeCanvas`);
if (!element.fullscreenElement) element.requestFullscreen();
else if (element.exitFullscreen) element.exitFullscreen();
if (!document.fullscreenEnabled) return;
if (
navigator.userAgent.includes(`Chrome/`) &&
navigator.userAgent.includes(`Mac OS X`)
)
return;
const elem = document.getElementById(`doseeCanvas`);
if (!document.fullscreenElement) {
elem.requestFullscreen().catch((err) => {
console.error(
`Error attempting to enable full-screen mode: ${err.message} (${err.name})`
);
});
} else {
document.exitFullscreen();
}
};

// Capture and save the canvas to a PNG image file
Expand Down Expand Up @@ -176,6 +189,12 @@
} else if (typeof document.fullscreenElement === `undefined`) {
// disable and hide the button if API is not supported by the browser such as in Safari
fullScreenButton.style.display = `none`;
} else if (
navigator.userAgent.includes(`Chrome/`) &&
navigator.userAgent.includes(`Mac OS X`)
) {
// chrome on macos behaves erratically
fullScreenButton.style.display = `none`;
} else {
fullScreenButton.addEventListener(`click`, DOSee.fullScreen);
}
Expand Down

0 comments on commit 924386b

Please sign in to comment.