I have below code to enter fullscreen and listen on exist fullscreen event. This code works fine for chrome
, safari
, edge
. But the exitListener
is not called in firefox when exiting fullscreen mode. Does anyone know how to implement exit event listener in firefox?
const el = $('.mydiv')[0];
const rfs =
el.requestFullscreen ||
el.webkitRequestFullScreen ||
el.mozRequestFullScreen ||
el.msRequestFullscreen;
['webkitfullscreenchange', 'mozfullscreenchange', 'fullscreenchange', 'msfullscreenchange'].forEach(
eventName => $('.mydiv').bind(eventName, exitListener)
);
rfs.call(el, Element.ALLOW_KEYBOARD_INPUT);
const exitListener = () => {
const state = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
if (!state) {
// fullscreen exit
}
}
I have read the post https://stackoverflow.com/questions/10706070/how-to-detect-when-a-page-exits-fullscreen
but the solution there doesn't solve my problem.