Bugzilla – Bug 19917
Split fullscreenchange event into two separate events
Last modified: 2012-11-09 18:44:34 UTC
We have defined fullscreenchange event to capture the change of fullscreen (http://www.w3.org/TR/fullscreen/), but in some cases web app needs to know if the document is entering fullscreen or exiting fullscreen. For example, the web app wants to do some operation such as hide some elements or pop up an alert dialog to user when the document is exiting fullscreen , but only applying fullscreenchange event cannot make the app to be sure the document is exiting fullscreen unless web developer provide a trick, such as set a flag to mark the document's status(in fullscreen or out of fullscreen).
Therefore, can we split the "fullscreenchange" event to two separate events? One is "fullscreenenter" event which will be invoked when the document is entering fullscreen, another is "fullscreenexit" event which will be invoked when the document is exiting fullscreen. With those two events web developer can create app easily to distinguish condition of entering or exiting fullscreen.
for the reference, latest spec is in http://fullscreen.spec.whatwg.org/
Thanks Olli,I review the spec you provide, there is still one fullscreenchange event,no new event is defined.
yup, though I wonder why .fullscreenElement isn't enough for your use case.
Yes, fullscreenElement is meant to address this.
When you receive a "fullscreenchange" event, check document.fullscreenElement, If it's non-null, the user is in fullscreen mode. If it's null, the user has exited fullscreen. Is that sufficient for your needs?