Add fullscreen with support to remote presentation controller (#712)
- F5 to enter/exit - Escape to exit
This commit is contained in:
committed by
Henrik Ingo
parent
6db3f7c877
commit
97546a5536
1
build.js
1
build.js
@@ -14,6 +14,7 @@ buildify()
|
||||
'src/plugins/blackout/blackout.js',
|
||||
'src/plugins/extras/extras.js',
|
||||
'src/plugins/form/form.js',
|
||||
'src/plugins/fullscreen/fullscreen.js',
|
||||
'src/plugins/goto/goto.js',
|
||||
'src/plugins/help/help.js',
|
||||
'src/plugins/impressConsole/impressConsole.js',
|
||||
|
||||
@@ -1668,6 +1668,64 @@
|
||||
} )( 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
|
||||
*
|
||||
|
||||
57
src/plugins/fullscreen/fullscreen.js
Normal file
57
src/plugins/fullscreen/fullscreen.js
Normal 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 );
|
||||
|
||||
Reference in New Issue
Block a user