mirror of
https://github.com/hakimel/reveal.js.git
synced 2025-08-08 07:36:39 +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
|
||||
*********************************************/
|
||||
.reveal-viewport.loading-scroll-mode {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.reveal-viewport.reveal-reader {
|
||||
& {
|
||||
margin: 0 auto !important;
|
||||
@@ -1910,14 +1914,13 @@ $notesWidthPercent: 25%;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
z-index: 1;
|
||||
|
||||
page-break-after: always;
|
||||
}
|
||||
|
||||
.reveal .slides .reader-page section {
|
||||
visibility: visible !important;
|
||||
display: block !important;
|
||||
position: relative !important;
|
||||
top: auto !important;
|
||||
|
||||
margin: 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
|
||||
else if( keyCode === 65 ) {
|
||||
if ( config.autoSlideStoppable ) {
|
||||
if( config.autoSlideStoppable ) {
|
||||
this.Reveal.toggleAutoSlide( autoSlideWasPaused );
|
||||
}
|
||||
}
|
||||
// G
|
||||
else if( keyCode === 71 ) {
|
||||
if ( config.jumpToSlide ) {
|
||||
if( config.jumpToSlide ) {
|
||||
this.Reveal.toggleJumpToSlide();
|
||||
}
|
||||
}
|
||||
// R
|
||||
else if( keyCode === 82 ) {
|
||||
this.Reveal.toggleReader();
|
||||
}
|
||||
else {
|
||||
triggered = false;
|
||||
}
|
||||
|
@@ -11,26 +11,28 @@ export default class Reader {
|
||||
|
||||
this.Reveal = Reveal;
|
||||
|
||||
this.activated = false;
|
||||
this.active = false;
|
||||
this.activatedCallbacks = [];
|
||||
|
||||
}
|
||||
|
||||
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 slideSize = this.Reveal.getComputedSlideSize( window.innerWidth, window.innerHeight );
|
||||
const slides = queryAll( this.Reveal.getRevealElement(), SLIDES_SELECTOR );
|
||||
|
||||
// Dimensions of slides within the pages
|
||||
const slideSize = this.Reveal.getComputedSlideSize( window.innerWidth, window.innerHeight );
|
||||
const slideWidth = slideSize.width,
|
||||
slideHeight = slideSize.height;
|
||||
|
||||
await new Promise( requestAnimationFrame );
|
||||
|
||||
viewportElement.classList.add( 'reveal-reader' );
|
||||
viewportElement.classList.add( 'loading-scroll-mode', 'reveal-reader' );
|
||||
viewportElement.addEventListener( 'scroll', this.onScroll.bind( this ) );
|
||||
|
||||
let presentationBackground;
|
||||
@@ -93,22 +95,45 @@ export default class Reader {
|
||||
|
||||
this.Reveal.layout();
|
||||
|
||||
this.activated = true;
|
||||
viewportElement.classList.remove( 'loading-scroll-mode' );
|
||||
|
||||
this.activatedCallbacks.forEach( callback => callback() );
|
||||
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() {
|
||||
|
||||
if( typeof this._isReaderMode === 'undefined' ) {
|
||||
this._isReaderMode = this.Reveal.getConfig().mode === 'reader';
|
||||
}
|
||||
|
||||
return this._isReaderMode;
|
||||
return this.active;
|
||||
|
||||
}
|
||||
|
||||
@@ -187,7 +212,7 @@ export default class Reader {
|
||||
|
||||
scrollToSlide( slideElement ) {
|
||||
|
||||
if( !this.activated ) {
|
||||
if( !this.active ) {
|
||||
this.activatedCallbacks.push( () => this.scrollToSlide( slideElement ) );
|
||||
}
|
||||
else {
|
||||
|
@@ -228,7 +228,7 @@ export default function( revealElement, options ) {
|
||||
}, 1 );
|
||||
|
||||
const isPrintMode = print.isActive();
|
||||
const isReaderMode = reader.isActive();
|
||||
const isReaderMode = config.mode === 'reader';
|
||||
|
||||
// Special setup and config is required when initializing a deck
|
||||
// to be read or printed linearly
|
||||
@@ -238,12 +238,11 @@ export default function( revealElement, options ) {
|
||||
removeEventListeners();
|
||||
}
|
||||
else {
|
||||
keyboard.unbind();
|
||||
touch.unbind();
|
||||
}
|
||||
|
||||
// Avoid content flickering during layout
|
||||
revealElement.style.visibility = 'hidden';
|
||||
dom.viewport.classList.add( 'loading-scroll-mode' );
|
||||
|
||||
const activate = () => {
|
||||
if( isPrintMode ) {
|
||||
@@ -2722,6 +2721,9 @@ export default function( revealElement, options ) {
|
||||
// Toggles the overview mode on/off
|
||||
toggleOverview: overview.toggle.bind( overview ),
|
||||
|
||||
// Toggles the reader mode on/off
|
||||
toggleReader: reader.toggle.bind( reader ),
|
||||
|
||||
// Toggles the "black screen" mode on/off
|
||||
togglePause,
|
||||
|
||||
|
Reference in New Issue
Block a user