Skip to content

Instantly share code, notes, and snippets.

@brettkelly
Last active May 27, 2022 21:03
Show Gist options
  • Save brettkelly/cfb94356ae191b9ca63e4bec985ce146 to your computer and use it in GitHub Desktop.
Save brettkelly/cfb94356ae191b9ca63e4bec985ce146 to your computer and use it in GitHub Desktop.
elements = [".some-class", "#some-id"]; // selectors for each element to suppress events
events = ["mouseover", "click"]; // events to suppress
document.addEventListener("fullscreenchange", (event) => {
// fullscreen event fired
elements.forEach((element) => {
events.forEach((event) => {
if (document.fullscreenElement) {
// some element has fullscreen now
document.querySelectorAll(element).forEach((el) => {
el.addEventListener(event, (e) => {
e.preventDefault();
return;
});
});
} else {
// no more full screen
document.querySelectorAll(element).forEach((el) => {
el.removeEventListener(event);
});
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment