Add fullscreen with support to remote presentation controller (#712)

- F5 to enter/exit
- Escape to exit
This commit is contained in:
Guilherme I F L Weizenmann
2019-02-06 08:36:04 -03:00
committed by Henrik Ingo
parent 6db3f7c877
commit 97546a5536
3 changed files with 116 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ buildify()
'src/plugins/blackout/blackout.js', 'src/plugins/blackout/blackout.js',
'src/plugins/extras/extras.js', 'src/plugins/extras/extras.js',
'src/plugins/form/form.js', 'src/plugins/form/form.js',
'src/plugins/fullscreen/fullscreen.js',
'src/plugins/goto/goto.js', 'src/plugins/goto/goto.js',
'src/plugins/help/help.js', 'src/plugins/help/help.js',
'src/plugins/impressConsole/impressConsole.js', 'src/plugins/impressConsole/impressConsole.js',

View File

@@ -1668,6 +1668,64 @@
} )( document ); } )( document );
/**
* Fullscreen plugin
*
* Press F5 to enter fullscreen and ESC to exit fullscreen mode.
*
* Copyright 2019 @giflw
* Released under the MIT license.
*/
/* global document */
( function( document ) {
"use strict";
function enterFullscreen() {
var elem = document.documentElement;
if ( !document.fullscreenElement ) {
elem.requestFullscreen();
}
}
function exitFullscreen() {
if ( document.fullscreenElement ) {
document.exitFullscreen();
}
}
// Wait for impress.js to be initialized
document.addEventListener( "impress:init", function( event ) {
var api = event.detail.api;
var root = event.target;
var gc = api.lib.gc;
var util = api.lib.util;
gc.addEventListener( document, "keydown", function( event ) {
// 116 (F5) is sent by presentation remote controllers
if ( event.code === "F5" ) {
event.preventDefault();
enterFullscreen();
util.triggerEvent( root.querySelector( ".active" ), "impress:steprefresh" );
}
// 27 (Escape) is sent by presentation remote controllers
if ( event.key === "Escape" || event.key === "F5" ) {
event.preventDefault();
exitFullscreen();
util.triggerEvent( root.querySelector( ".active" ), "impress:steprefresh" );
}
}, false );
util.triggerEvent( document, "impress:help:add",
{ command: "F5 / ESC", text: "Fullscreen: Enter / Exit", row: 200 } );
}, false );
} )( document );
/** /**
* Goto Plugin * Goto Plugin
* *

View File

@@ -0,0 +1,57 @@
/**
* Fullscreen plugin
*
* Press F5 to enter fullscreen and ESC to exit fullscreen mode.
*
* Copyright 2019 @giflw
* Released under the MIT license.
*/
/* global document */
( function( document ) {
"use strict";
function enterFullscreen() {
var elem = document.documentElement;
if ( !document.fullscreenElement ) {
elem.requestFullscreen();
}
}
function exitFullscreen() {
if ( document.fullscreenElement ) {
document.exitFullscreen();
}
}
// Wait for impress.js to be initialized
document.addEventListener( "impress:init", function( event ) {
var api = event.detail.api;
var root = event.target;
var gc = api.lib.gc;
var util = api.lib.util;
gc.addEventListener( document, "keydown", function( event ) {
// 116 (F5) is sent by presentation remote controllers
if ( event.code === "F5" ) {
event.preventDefault();
enterFullscreen();
util.triggerEvent( root.querySelector( ".active" ), "impress:steprefresh" );
}
// 27 (Escape) is sent by presentation remote controllers
if ( event.key === "Escape" || event.key === "F5" ) {
event.preventDefault();
exitFullscreen();
util.triggerEvent( root.querySelector( ".active" ), "impress:steprefresh" );
}
}, false );
util.triggerEvent( document, "impress:help:add",
{ command: "F5 / ESC", text: "Fullscreen: Enter / Exit", row: 200 } );
}, false );
} )( document );