svghmi/svghmi.js
branchsvghmi
changeset 3299 8b45d8494fae
parent 3268 d22782b9591f
child 3381 3a0908b0319d
--- a/svghmi/svghmi.js	Tue Aug 24 11:12:41 2021 +0200
+++ b/svghmi/svghmi.js	Fri Aug 27 11:31:32 2021 +0200
@@ -367,9 +367,22 @@
 var current_page_index;
 var page_node_local_index = hmi_local_index("page_node");
 
+function toggleFullscreen() {
+  let elem = document.documentElement;
+
+  if (!document.fullscreenElement) {
+    elem.requestFullscreen().catch(err => {
+      console.log("Error attempting to enable full-screen mode: "+err.message+" ("+err.name+")");
+    });
+  } else {
+    document.exitFullscreen();
+  }
+}
+
 function prepare_svg() {
     // prevents context menu from appearing on right click and long touch
     document.body.addEventListener('contextmenu', e => {
+        toggleFullscreen();
         e.preventDefault();
     });