Created
June 26, 2019 20:48
-
-
Save apostolou/ad480b52d23ab47e2a7477e9d4036cb6 to your computer and use it in GitHub Desktop.
clojuscript version of requestFullscreen inspired from js code https://www.w3schools.com/jsref/met_element_requestfullscreen.asp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns open-full-screen.core | |
(:require[goog.object :as gobj])) | |
(defn open-full-screen | |
"`element-id` is the string of the html element id of | |
the element to be displayed in fullscreen" | |
[element-id] | |
(let [e (.getElementById js/document element-id)] | |
(cond | |
(gobj/get e "requestFullscreen") (.requestFullscreen e) | |
(gobj/get e "mozRequestFullScreen") (.mozRequestFullScreen e) | |
(gobj/get e "webkitRequestFullscreen") (.webkitRequestFullscreen e) | |
(gobj/get e "msRequestFullscreen") (.msRequestFullscreen e)))) | |
(defn close-full-screen | |
[] | |
(let [d js/document] | |
(cond | |
(gobj/get d "exitFullscreen") (.exitFullscreen d) | |
(gobj/get d "mozCancelFullScreen") (.mozCancelFullScreen d) | |
(gobj/get d "webkitExitFullscreen") (.webkitExitFullscreen d) | |
(gobj/get d "msExitFullscreen") (.msExitFullscreen d)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment