mirror of
https://github.com/hakimel/reveal.js.git
synced 2025-08-06 22:57:21 +02:00
add support for responsively activating reader mode via
This commit is contained in:
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
118
examples/reader-mode.html
Normal file
118
examples/reader-mode.html
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
|
||||||
|
<title>reveal.js - Reader Mode</title>
|
||||||
|
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="../dist/reset.css">
|
||||||
|
<link rel="stylesheet" href="../dist/reveal.css">
|
||||||
|
<link rel="stylesheet" href="../dist/theme/black.css" id="theme">
|
||||||
|
<link rel="stylesheet" href="../plugin/highlight/monokai.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="reveal">
|
||||||
|
|
||||||
|
<div class="slides">
|
||||||
|
|
||||||
|
<section><h1>Reader Mode</h1></section>
|
||||||
|
<section data-auto-animate data-auto-animate-easing="cubic-bezier(0.770, 0.000, 0.175, 1.000)">
|
||||||
|
<h2>Auto-Animate</h2>
|
||||||
|
<p>Automatically animate matching elements across slides with <a href="https://revealjs.com/auto-animate/">Auto-Animate</a>.</p>
|
||||||
|
<div class="r-hstack justify-center">
|
||||||
|
<div data-id="box1" style="background: #999; width: 50px; height: 50px; margin: 10px; border-radius: 5px;"></div>
|
||||||
|
<div data-id="box2" style="background: #999; width: 50px; height: 50px; margin: 10px; border-radius: 5px;"></div>
|
||||||
|
<div data-id="box3" style="background: #999; width: 50px; height: 50px; margin: 10px; border-radius: 5px;"></div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section data-auto-animate data-auto-animate-easing="cubic-bezier(0.770, 0.000, 0.175, 1.000)">
|
||||||
|
<div class="r-hstack justify-center">
|
||||||
|
<div data-id="box1" data-auto-animate-delay="0" style="background: cyan; width: 150px; height: 100px; margin: 10px;"></div>
|
||||||
|
<div data-id="box2" data-auto-animate-delay="0.1" style="background: magenta; width: 150px; height: 100px; margin: 10px;"></div>
|
||||||
|
<div data-id="box3" data-auto-animate-delay="0.2" style="background: yellow; width: 150px; height: 100px; margin: 10px;"></div>
|
||||||
|
</div>
|
||||||
|
<h2 style="margin-top: 20px;">Auto-Animate</h2>
|
||||||
|
</section>
|
||||||
|
<section data-auto-animate data-auto-animate-easing="cubic-bezier(0.770, 0.000, 0.175, 1.000)">
|
||||||
|
<div class="r-stack">
|
||||||
|
<div data-id="box1" style="background: cyan; width: 300px; height: 300px; border-radius: 200px;"></div>
|
||||||
|
<div data-id="box2" style="background: magenta; width: 200px; height: 200px; border-radius: 200px;"></div>
|
||||||
|
<div data-id="box3" style="background: yellow; width: 100px; height: 100px; border-radius: 200px;"></div>
|
||||||
|
</div>
|
||||||
|
<h2 style="margin-top: 20px;">Auto-Animate</h2>
|
||||||
|
</section>
|
||||||
|
<section data-background="indigo">
|
||||||
|
<h2>Scroll triggers</h2>
|
||||||
|
<ul>
|
||||||
|
<li class="fragment">Fragment one</li>
|
||||||
|
<li class="fragment">Fragment two</li>
|
||||||
|
<li class="fragment">Fragment three</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
<section data-background-gradient="linear-gradient(to bottom, #283b95, #17b2c3)">
|
||||||
|
<h2>Gradient Backgrounds</h2>
|
||||||
|
</section>
|
||||||
|
<section data-auto-animate>
|
||||||
|
<h2 data-id="code-title">Scroll triggered code highlights</h2>
|
||||||
|
<pre data-id="code-animation"><code class="hljs javascript" data-trim data-line-numbers="|4,8-11|17|22-24"><script type="text/template">
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
|
function Example() {
|
||||||
|
const [count, setCount] = useState(0);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<p>You clicked {count} times</p>
|
||||||
|
<button onClick={() => setCount(count + 1)}>
|
||||||
|
Click me
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function SecondExample() {
|
||||||
|
const [count, setCount] = useState(0);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<p>You clicked {count} times</p>
|
||||||
|
<button onClick={() => setCount(count + 1)}>
|
||||||
|
Click me
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
</script></code></pre>
|
||||||
|
</section>
|
||||||
|
<section data-background="https://static.slid.es/reveal/image-placeholder.png">
|
||||||
|
<h2>Image Backgrounds</h2>
|
||||||
|
<pre><code class="hljs html"><section data-background="image.png"></code></pre>
|
||||||
|
</section>
|
||||||
|
<section data-background-video="https://s3.amazonaws.com/static.slid.es/site/homepage/v1/homepage-video-editor.mp4,https://s3.amazonaws.com/static.slid.es/site/homepage/v1/homepage-video-editor.webm">
|
||||||
|
<h2>Video background</h2>
|
||||||
|
</section>
|
||||||
|
<section><h2>The end</h2></section>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="../dist/reveal.js"></script>
|
||||||
|
<script src="../plugin/notes/notes.js"></script>
|
||||||
|
<script src="../plugin/markdown/markdown.js"></script>
|
||||||
|
<script src="../plugin/highlight/highlight.js"></script>
|
||||||
|
<script>
|
||||||
|
Reveal.initialize({
|
||||||
|
view: 'reader',
|
||||||
|
|
||||||
|
plugins: [ RevealMarkdown, RevealHighlight, RevealNotes ]
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@@ -276,6 +276,10 @@ export default {
|
|||||||
// Only applies to presentations in reader mode.
|
// Only applies to presentations in reader mode.
|
||||||
readerScrollSnap: 'proximity',
|
readerScrollSnap: 'proximity',
|
||||||
|
|
||||||
|
// Responsively activate the reader mode when we reach the specified
|
||||||
|
// width (in pixels)
|
||||||
|
readerActivationWidth: null,
|
||||||
|
|
||||||
// The maximum number of pages a single slide can expand onto when printing
|
// The maximum number of pages a single slide can expand onto when printing
|
||||||
// to PDF, unlimited by default
|
// to PDF, unlimited by default
|
||||||
pdfMaxPagesPerSlide: Number.POSITIVE_INFINITY,
|
pdfMaxPagesPerSlide: Number.POSITIVE_INFINITY,
|
||||||
|
@@ -14,6 +14,8 @@ export default class Reader {
|
|||||||
this.active = false;
|
this.active = false;
|
||||||
this.activatedCallbacks = [];
|
this.activatedCallbacks = [];
|
||||||
|
|
||||||
|
this.onScroll = this.onScroll.bind( this );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +34,7 @@ export default class Reader {
|
|||||||
const slides = queryAll( this.Reveal.getRevealElement(), SLIDES_SELECTOR );
|
const slides = queryAll( this.Reveal.getRevealElement(), SLIDES_SELECTOR );
|
||||||
|
|
||||||
viewportElement.classList.add( 'loading-scroll-mode', 'reveal-reader' );
|
viewportElement.classList.add( 'loading-scroll-mode', 'reveal-reader' );
|
||||||
viewportElement.addEventListener( 'scroll', this.onScroll.bind( this ) );
|
viewportElement.addEventListener( 'scroll', this.onScroll );
|
||||||
|
|
||||||
let presentationBackground;
|
let presentationBackground;
|
||||||
if( viewportElement ) {
|
if( viewportElement ) {
|
||||||
@@ -113,7 +115,11 @@ export default class Reader {
|
|||||||
|
|
||||||
this.active = false;
|
this.active = false;
|
||||||
|
|
||||||
this.Reveal.getViewportElement().classList.remove( 'reveal-reader' );
|
const viewportElement = this.Reveal.getViewportElement();
|
||||||
|
|
||||||
|
viewportElement.removeEventListener( 'scroll', this.onScroll );
|
||||||
|
viewportElement.classList.remove( 'reveal-reader' );
|
||||||
|
|
||||||
this.Reveal.getSlidesElement().innerHTML = this.slideHTMLBeforeActivation;
|
this.Reveal.getSlidesElement().innerHTML = this.slideHTMLBeforeActivation;
|
||||||
this.Reveal.sync();
|
this.Reveal.sync();
|
||||||
|
|
||||||
|
12
js/reveal.js
12
js/reveal.js
@@ -999,6 +999,18 @@ export default function( revealElement, options ) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Responsively turn on the reader mode if there is an activation
|
||||||
|
// width configured. Ignore if we're configured to always be in
|
||||||
|
// reader mode.
|
||||||
|
if( typeof config.readerActivationWidth === 'number' && config.view !== 'reader' ) {
|
||||||
|
if( size.presentationWidth < config.readerActivationWidth ) {
|
||||||
|
if( !reader.isActive() ) reader.activate();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if( reader.isActive() ) reader.deactivate();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dom.viewport.style.setProperty( '--slide-scale', scale );
|
dom.viewport.style.setProperty( '--slide-scale', scale );
|
||||||
|
Reference in New Issue
Block a user