Skip to content

Commit 5359da0

Browse files
committed
documentation for getState/setState
1 parent 04b71f5 commit 5359da0

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

README.md

+32-15
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,17 @@ You can add your own extensions using the same syntax. The following properties
230230
- **condition**: [optional] Function which must return true for the script to be loaded
231231

232232

233+
### Ready Event
234+
235+
A 'ready' event is fired when reveal.js has loaded all non-async dependencies and is ready to start navigating. To check if reveal.js is already 'ready' you can call `Reveal.isReady()`.
236+
237+
```javascript
238+
Reveal.addEventListener( 'ready', function( event ) {
239+
// event.currentSlide, event.indexh, event.indexv
240+
} );
241+
```
242+
243+
233244
### Presentation Size
234245

235246
All presentations have a normal size, that is the resolution at which they are authored. The framework will automatically scale presentations uniformly based on this size to ensure that everything fits on any given display or viewport.
@@ -252,7 +263,7 @@ Reveal.initialize({
252263

253264
// Bounds for smallest/largest possible scale to apply to content
254265
minScale: 0.2,
255-
maxScale: 1.0
266+
maxScale: 1.5
256267

257268
});
258269
```
@@ -339,7 +350,7 @@ Reveal.toggleAutoSlide();
339350
// Change a config value at runtime
340351
Reveal.configure({ controls: true });
341352

342-
// Returns the currently active configuration options
353+
// Returns the present configuration options
343354
Reveal.getConfig();
344355

345356
// Fetch the current scale of the presentation
@@ -350,6 +361,7 @@ Reveal.getPreviousSlide();
350361
Reveal.getCurrentSlide();
351362

352363
Reveal.getIndices(); // { h: 0, v: 0 } }
364+
Reveal.getProgress(); // 0-1
353365
Reveal.getTotalSlides();
354366

355367
// State checks
@@ -360,18 +372,6 @@ Reveal.isPaused();
360372
Reveal.isAutoSliding();
361373
```
362374

363-
### Ready Event
364-
365-
The 'ready' event is fired when reveal.js has loaded all (synchronous) dependencies and is ready to start navigating.
366-
367-
```javascript
368-
Reveal.addEventListener( 'ready', function( event ) {
369-
// event.currentSlide, event.indexh, event.indexv
370-
} );
371-
```
372-
373-
To check if reveal.js is already 'ready' you can use call `Reveal.isReady()`.
374-
375375
### Slide Changed Event
376376

377377
An 'slidechanged' event is fired each time the slide is changed (regardless of state). The event object holds the index values of the current slide as well as a reference to the previous and current slide HTML nodes.
@@ -384,7 +384,24 @@ Reveal.addEventListener( 'slidechanged', function( event ) {
384384
} );
385385
```
386386

387-
### States
387+
### Presentation State
388+
389+
The presentation's current state can be fetched by using the `getState` method. A state object contains all of the information required to put the presentation back as it was when `getState` was first called. Sort of like a snapshot. It's a simple object that can easily be stringified and persisted or sent over the wire.
390+
391+
```javascript
392+
Reveal.slide( 1 );
393+
// we're on slide 1
394+
395+
var state = Reveal.getState();
396+
397+
Reveal.slide( 3 );
398+
// we're on slide 3
399+
400+
Reveal.setState( state );
401+
// we're back on slide 1
402+
```
403+
404+
### Slide States
388405

389406
If you set ``data-state="somestate"`` on a slide ``<section>``, "somestate" will be applied as a class on the document element when that slide is opened. This allows you to apply broad style changes to the page based on the active slide.
390407

0 commit comments

Comments
 (0)