mirror of
https://github.com/hakimel/reveal.js.git
synced 2025-08-07 23:26:57 +02:00
reader mode can be turned off without reload, add Reveal.toggleReader()
This commit is contained in:
@@ -1867,6 +1867,10 @@ $notesWidthPercent: 25%;
|
|||||||
/*********************************************
|
/*********************************************
|
||||||
* READER MODE
|
* READER MODE
|
||||||
*********************************************/
|
*********************************************/
|
||||||
|
.reveal-viewport.loading-scroll-mode {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.reveal-viewport.reveal-reader {
|
.reveal-viewport.reveal-reader {
|
||||||
& {
|
& {
|
||||||
margin: 0 auto !important;
|
margin: 0 auto !important;
|
||||||
@@ -1910,14 +1914,13 @@ $notesWidthPercent: 25%;
|
|||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
|
||||||
page-break-after: always;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.reveal .slides .reader-page section {
|
.reveal .slides .reader-page section {
|
||||||
visibility: visible !important;
|
visibility: visible !important;
|
||||||
display: block !important;
|
display: block !important;
|
||||||
position: relative !important;
|
position: relative !important;
|
||||||
|
top: auto !important;
|
||||||
|
|
||||||
margin: 0 !important;
|
margin: 0 !important;
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
|
2
dist/reveal.css
vendored
2
dist/reveal.css
vendored
File diff suppressed because one or more lines are too long
2
dist/reveal.esm.js
vendored
2
dist/reveal.esm.js
vendored
File diff suppressed because one or more lines are too long
2
dist/reveal.esm.js.map
vendored
2
dist/reveal.esm.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/reveal.js
vendored
2
dist/reveal.js
vendored
File diff suppressed because one or more lines are too long
2
dist/reveal.js.map
vendored
2
dist/reveal.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -360,16 +360,20 @@ export default class Keyboard {
|
|||||||
}
|
}
|
||||||
// A
|
// A
|
||||||
else if( keyCode === 65 ) {
|
else if( keyCode === 65 ) {
|
||||||
if ( config.autoSlideStoppable ) {
|
if( config.autoSlideStoppable ) {
|
||||||
this.Reveal.toggleAutoSlide( autoSlideWasPaused );
|
this.Reveal.toggleAutoSlide( autoSlideWasPaused );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// G
|
// G
|
||||||
else if( keyCode === 71 ) {
|
else if( keyCode === 71 ) {
|
||||||
if ( config.jumpToSlide ) {
|
if( config.jumpToSlide ) {
|
||||||
this.Reveal.toggleJumpToSlide();
|
this.Reveal.toggleJumpToSlide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// R
|
||||||
|
else if( keyCode === 82 ) {
|
||||||
|
this.Reveal.toggleReader();
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
triggered = false;
|
triggered = false;
|
||||||
}
|
}
|
||||||
|
@@ -11,26 +11,28 @@ export default class Reader {
|
|||||||
|
|
||||||
this.Reveal = Reveal;
|
this.Reveal = Reveal;
|
||||||
|
|
||||||
this.activated = false;
|
this.active = false;
|
||||||
this.activatedCallbacks = [];
|
this.activatedCallbacks = [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async activate() {
|
async activate() {
|
||||||
|
|
||||||
const slides = queryAll( this.Reveal.getRevealElement(), SLIDES_SELECTOR );
|
if( this.active ) return;
|
||||||
|
|
||||||
|
this.active = true;
|
||||||
|
|
||||||
|
this.slideHTMLBeforeActivation = this.Reveal.getSlidesElement().innerHTML;
|
||||||
|
|
||||||
const viewportElement = this.Reveal.getViewportElement();
|
const viewportElement = this.Reveal.getViewportElement();
|
||||||
|
const slides = queryAll( this.Reveal.getRevealElement(), SLIDES_SELECTOR );
|
||||||
const slideSize = this.Reveal.getComputedSlideSize( window.innerWidth, window.innerHeight );
|
|
||||||
|
|
||||||
// Dimensions of slides within the pages
|
// Dimensions of slides within the pages
|
||||||
|
const slideSize = this.Reveal.getComputedSlideSize( window.innerWidth, window.innerHeight );
|
||||||
const slideWidth = slideSize.width,
|
const slideWidth = slideSize.width,
|
||||||
slideHeight = slideSize.height;
|
slideHeight = slideSize.height;
|
||||||
|
|
||||||
await new Promise( requestAnimationFrame );
|
viewportElement.classList.add( 'loading-scroll-mode', 'reveal-reader' );
|
||||||
|
|
||||||
viewportElement.classList.add( 'reveal-reader' );
|
|
||||||
viewportElement.addEventListener( 'scroll', this.onScroll.bind( this ) );
|
viewportElement.addEventListener( 'scroll', this.onScroll.bind( this ) );
|
||||||
|
|
||||||
let presentationBackground;
|
let presentationBackground;
|
||||||
@@ -93,22 +95,45 @@ export default class Reader {
|
|||||||
|
|
||||||
this.Reveal.layout();
|
this.Reveal.layout();
|
||||||
|
|
||||||
this.activated = true;
|
viewportElement.classList.remove( 'loading-scroll-mode' );
|
||||||
|
|
||||||
this.activatedCallbacks.forEach( callback => callback() );
|
this.activatedCallbacks.forEach( callback => callback() );
|
||||||
this.activatedCallbacks = [];
|
this.activatedCallbacks = [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deactivate() {
|
||||||
|
|
||||||
|
if( !this.active ) return;
|
||||||
|
|
||||||
|
this.active = false;
|
||||||
|
|
||||||
|
this.Reveal.getViewportElement().classList.remove( 'reveal-reader' );
|
||||||
|
this.Reveal.getSlidesElement().innerHTML = this.slideHTMLBeforeActivation;
|
||||||
|
this.Reveal.sync();
|
||||||
|
|
||||||
|
// TODO Navigate to the slide that is currently scrolled into view
|
||||||
|
this.Reveal.slide( 0 );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle() {
|
||||||
|
|
||||||
|
if( this.active === true ) {
|
||||||
|
this.deactivate();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the reader mode is/should be activated.
|
* Checks if the reader mode is currently active.
|
||||||
*/
|
*/
|
||||||
isActive() {
|
isActive() {
|
||||||
|
|
||||||
if( typeof this._isReaderMode === 'undefined' ) {
|
return this.active;
|
||||||
this._isReaderMode = this.Reveal.getConfig().mode === 'reader';
|
|
||||||
}
|
|
||||||
|
|
||||||
return this._isReaderMode;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +212,7 @@ export default class Reader {
|
|||||||
|
|
||||||
scrollToSlide( slideElement ) {
|
scrollToSlide( slideElement ) {
|
||||||
|
|
||||||
if( !this.activated ) {
|
if( !this.active ) {
|
||||||
this.activatedCallbacks.push( () => this.scrollToSlide( slideElement ) );
|
this.activatedCallbacks.push( () => this.scrollToSlide( slideElement ) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -228,7 +228,7 @@ export default function( revealElement, options ) {
|
|||||||
}, 1 );
|
}, 1 );
|
||||||
|
|
||||||
const isPrintMode = print.isActive();
|
const isPrintMode = print.isActive();
|
||||||
const isReaderMode = reader.isActive();
|
const isReaderMode = config.mode === 'reader';
|
||||||
|
|
||||||
// Special setup and config is required when initializing a deck
|
// Special setup and config is required when initializing a deck
|
||||||
// to be read or printed linearly
|
// to be read or printed linearly
|
||||||
@@ -238,12 +238,11 @@ export default function( revealElement, options ) {
|
|||||||
removeEventListeners();
|
removeEventListeners();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
keyboard.unbind();
|
|
||||||
touch.unbind();
|
touch.unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Avoid content flickering during layout
|
// Avoid content flickering during layout
|
||||||
revealElement.style.visibility = 'hidden';
|
dom.viewport.classList.add( 'loading-scroll-mode' );
|
||||||
|
|
||||||
const activate = () => {
|
const activate = () => {
|
||||||
if( isPrintMode ) {
|
if( isPrintMode ) {
|
||||||
@@ -2722,6 +2721,9 @@ export default function( revealElement, options ) {
|
|||||||
// Toggles the overview mode on/off
|
// Toggles the overview mode on/off
|
||||||
toggleOverview: overview.toggle.bind( overview ),
|
toggleOverview: overview.toggle.bind( overview ),
|
||||||
|
|
||||||
|
// Toggles the reader mode on/off
|
||||||
|
toggleReader: reader.toggle.bind( reader ),
|
||||||
|
|
||||||
// Toggles the "black screen" mode on/off
|
// Toggles the "black screen" mode on/off
|
||||||
togglePause,
|
togglePause,
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user