Skip to content

Commit fb9072f

Browse files
author
TATSUNO Yasuhiro
authored
Fix #376: Add the Fullscreen API (#402)
1 parent 8061334 commit fb9072f

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

src/main/scala/org/scalajs/dom/raw/lib.scala

+103
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,50 @@ abstract class Element
975975
*/
976976
def removeAttributeNS(namespaceURI: String,
977977
localName: String): Unit = js.native
978+
979+
/**
980+
* The Element.requestFullscreen() method issues an asynchronous request to
981+
* make the element be displayed in full-screen mode.
982+
*
983+
* It's not guaranteed that the element will be put into full screen mode.
984+
* If permission to enter full screen mode is granted, the returned Promise
985+
* will resolve and the element will receive a fullscreenchange event to let
986+
* it know that it's now in full screen mode. If permission is denied, the
987+
* promise is rejected and the element receives a fullscreenerror event
988+
* instead. If the element has been detached from the original document, then
989+
* the document receives these events instead.
990+
*
991+
* Earlier implementations of the Fullscreen API would always send these
992+
* events to the document rather than the element, and you may need to be
993+
* able to handle that situation. Check Browser compatibility in fullscreen
994+
* for specifics on when each browser made this change.
995+
*
996+
* MDN
997+
*/
998+
def requestFullscreen(
999+
options: FullscreenOptions = js.native): js.Promise[Unit] = js.native
1000+
1001+
/**
1002+
* The Element interface's onfullscreenchange property is an event handler
1003+
* for the fullscreenchange event that is fired when the element has
1004+
* transitioned into or out of full-screen mode.
1005+
*
1006+
* MDN
1007+
*/
1008+
var onfullscreenchange: js.Function1[Event, _] = js.native
1009+
1010+
/**
1011+
* The Element interface's onfullscreenerror property is an event handler
1012+
* for the fullscreenerror event which is sent to the element when an error
1013+
* occurs while attempting to transition into or out of full-screen mode.
1014+
*
1015+
* MDN
1016+
*/
1017+
var onfullscreenerror: js.Function1[Event, _] = js.native
1018+
}
1019+
1020+
trait FullscreenOptions extends js.Object {
1021+
var navigationUI: js.UndefOr[String] = js.undefined
9781022
}
9791023

9801024
/**
@@ -3495,6 +3539,65 @@ abstract class Document
34953539
*/
34963540
def createTreeWalker(root: Node, whatToShow: Int, filter: NodeFilter,
34973541
entityReferenceExpansion: Boolean): TreeWalker = js.native
3542+
3543+
/**
3544+
* The Document method exitFullscreen() requests that the element on this
3545+
* document which is currently being presented in full-screen mode be
3546+
* taken out of full-screen mode, restoring the previous state of the
3547+
* screen. This usually reverses the effects of a previous call to
3548+
* Element.requestFullscreen().
3549+
*
3550+
* The exception is if another element was already in full-screen mode
3551+
* when the current element was placed into full-screen mode using
3552+
* requestFullscreen(). In that case, the previous full-screen element is
3553+
* restored to full-screen status instead. In essence, a stack of
3554+
* full-screen elements is maintained.
3555+
*
3556+
* MDN
3557+
*/
3558+
def exitFullscreen(): js.Promise[Unit] = js.native
3559+
3560+
/**
3561+
* The DocumentOrShadowRoot.fullscreenElement read-only property returns the
3562+
* Element that is currently being presented in full-screen mode in this
3563+
* document, or null if full-screen mode is not currently in use.
3564+
*
3565+
* Although this property is read-only, it will not throw if it is modified
3566+
* (even in strict mode); the setter is a no-operation and it will be ignored.
3567+
*
3568+
* MDN
3569+
*/
3570+
def fullscreenElement: Element = js.native
3571+
3572+
/**
3573+
* The read-only fullscreenEnabled property on the Document interface
3574+
* indicates whether or not full-screen mode is available. Full-screen mode
3575+
* is available only for a page that has no windowed plug-ins in any of its
3576+
* documents, and if all <iframe> elements which contain the document have
3577+
* their allowfullscreen attribute set.
3578+
*
3579+
* MDN
3580+
*/
3581+
def fullscreenEnabled: Boolean = js.native
3582+
3583+
/**
3584+
* The Document interface's onfullscreenchange property is an event handler
3585+
* for the fullscreenchange event that is fired immediately before a document
3586+
* transitions into or out of full-screen mode.
3587+
*
3588+
* MDN
3589+
*/
3590+
var onfullscreenchange: js.Function1[Event, _] = js.native
3591+
3592+
/**
3593+
* The Document.onfullscreenerror property is an event handler for the
3594+
* fullscreenerror event that is sent to the document when it fails to
3595+
* transition into full-screen mode after a prior call to
3596+
* Element.requestFullscreen().
3597+
*
3598+
* MDN
3599+
*/
3600+
var onfullscreenerror: js.Function1[Event, _] = js.native
34983601
}
34993602

35003603
trait MessageEventInit extends EventInit {

0 commit comments

Comments
 (0)