README.md (58400B)
1 # reveal.js [](https://travis-ci.org/hakimel/reveal.js) <a href="https://slides.com?ref=github"><img src="https://s3.amazonaws.com/static.slid.es/images/slides-github-banner-320x40.png?1" alt="Slides" width="160" height="20"></a> 2 3 A framework for easily creating beautiful presentations using HTML. [Check out the live demo](http://revealjs.com/). 4 5 reveal.js comes with a broad range of features including [nested slides](https://github.com/hakimel/reveal.js#markup), [Markdown contents](https://github.com/hakimel/reveal.js#markdown), [PDF export](https://github.com/hakimel/reveal.js#pdf-export), [speaker notes](https://github.com/hakimel/reveal.js#speaker-notes) and a [JavaScript API](https://github.com/hakimel/reveal.js#api). There's also a fully featured visual editor and platform for sharing reveal.js presentations at [slides.com](https://slides.com?ref=github). 6 7 8 ## Table of contents 9 10 - [Online Editor](#online-editor) 11 - [Installation](#installation) 12 - [Basic setup](#basic-setup) 13 - [Full setup](#full-setup) 14 - [Folder Structure](#folder-structure) 15 - [Instructions](#instructions) 16 - [Markup](#markup) 17 - [Markdown](#markdown) 18 - [Element Attributes](#element-attributes) 19 - [Slide Attributes](#slide-attributes) 20 - [Configuration](#configuration) 21 - [Presentation Size](#presentation-size) 22 - [Dependencies](#dependencies) 23 - [Ready Event](#ready-event) 24 - [Auto-sliding](#auto-sliding) 25 - [Keyboard Bindings](#keyboard-bindings) 26 - [Vertical Slide Navigation](#vertical-slide-navigation) 27 - [Touch Navigation](#touch-navigation) 28 - [Lazy Loading](#lazy-loading) 29 - [API](#api) 30 - [Slide Changed Event](#slide-changed-event) 31 - [Presentation State](#presentation-state) 32 - [Slide States](#slide-states) 33 - [Slide Backgrounds](#slide-backgrounds) 34 - [Parallax Background](#parallax-background) 35 - [Slide Transitions](#slide-transitions) 36 - [Internal links](#internal-links) 37 - [Fragments](#fragments) 38 - [Fragment events](#fragment-events) 39 - [Code syntax highlighting](#code-syntax-highlighting) 40 - [Slide number](#slide-number) 41 - [Overview mode](#overview-mode) 42 - [Fullscreen mode](#fullscreen-mode) 43 - [Embedded media](#embedded-media) 44 - [Stretching elements](#stretching-elements) 45 - [Resize Event](#resize-event) 46 - [postMessage API](#postmessage-api) 47 - [PDF Export](#pdf-export) 48 - [Theming](#theming) 49 - [Speaker Notes](#speaker-notes) 50 - [Share and Print Speaker Notes](#share-and-print-speaker-notes) 51 - [Server Side Speaker Notes](#server-side-speaker-notes) 52 - [Multiplexing](#multiplexing) 53 - [Master presentation](#master-presentation) 54 - [Client presentation](#client-presentation) 55 - [Socket.io server](#socketio-server) 56 - [MathJax](#mathjax) 57 - [License](#license) 58 59 #### More reading 60 61 - [Changelog](https://github.com/hakimel/reveal.js/releases): Up-to-date version history. 62 - [Examples](https://github.com/hakimel/reveal.js/wiki/Example-Presentations): Presentations created with reveal.js, add your own! 63 - [Browser Support](https://github.com/hakimel/reveal.js/wiki/Browser-Support): Explanation of browser support and fallbacks. 64 - [Plugins](https://github.com/hakimel/reveal.js/wiki/Plugins,-Tools-and-Hardware): A list of plugins that can be used to extend reveal.js. 65 66 67 ## Online Editor 68 69 Presentations are written using HTML or Markdown but there's also an online editor for those of you who prefer a graphical interface. Give it a try at [https://slides.com](https://slides.com?ref=github). 70 71 72 ## Installation 73 74 The **basic setup** is for authoring presentations only. The **full setup** gives you access to all reveal.js features and plugins such as speaker notes as well as the development tasks needed to make changes to the source. 75 76 ### Basic setup 77 78 The core of reveal.js is very easy to install. You'll simply need to download a copy of this repository and open the index.html file directly in your browser. 79 80 1. Download the latest version of reveal.js from <https://github.com/hakimel/reveal.js/releases> 81 2. Unzip and replace the example contents in index.html with your own 82 3. Open index.html in a browser to view it 83 84 ### Full setup 85 86 Some reveal.js features, like external Markdown and speaker notes, require that presentations run from a local web server. The following instructions will set up such a server as well as all of the development tasks needed to make edits to the reveal.js source code. 87 88 1. Install [Node.js](http://nodejs.org/) (4.0.0 or later) 89 90 1. Clone the reveal.js repository 91 ```sh 92 $ git clone https://github.com/hakimel/reveal.js.git 93 ``` 94 95 1. Navigate to the reveal.js folder 96 ```sh 97 $ cd reveal.js 98 ``` 99 100 1. Install dependencies 101 ```sh 102 $ npm install 103 ``` 104 105 1. Serve the presentation and monitor source files for changes 106 ```sh 107 $ npm start 108 ``` 109 110 1. Open <http://localhost:8000> to view your presentation 111 112 You can change the port by using `npm start -- --port=8001`. 113 114 ### Folder Structure 115 116 - **css/** Core styles without which the project does not function 117 - **js/** Like above but for JavaScript 118 - **plugin/** Components that have been developed as extensions to reveal.js 119 - **lib/** All other third party assets (JavaScript, CSS, fonts) 120 121 122 ## Instructions 123 124 ### Markup 125 126 Here's a barebones example of a fully working reveal.js presentation: 127 ```html 128 <html> 129 <head> 130 <link rel="stylesheet" href="css/reveal.css"> 131 <link rel="stylesheet" href="css/theme/white.css"> 132 </head> 133 <body> 134 <div class="reveal"> 135 <div class="slides"> 136 <section>Slide 1</section> 137 <section>Slide 2</section> 138 </div> 139 </div> 140 <script src="js/reveal.js"></script> 141 <script> 142 Reveal.initialize(); 143 </script> 144 </body> 145 </html> 146 ``` 147 148 The presentation markup hierarchy needs to be `.reveal > .slides > section` where the `section` represents one slide and can be repeated indefinitely. If you place multiple `section` elements inside of another `section` they will be shown as vertical slides. The first of the vertical slides is the "root" of the others (at the top), and will be included in the horizontal sequence. For example: 149 150 ```html 151 <div class="reveal"> 152 <div class="slides"> 153 <section>Single Horizontal Slide</section> 154 <section> 155 <section>Vertical Slide 1</section> 156 <section>Vertical Slide 2</section> 157 </section> 158 </div> 159 </div> 160 ``` 161 162 ### Markdown 163 164 It's possible to write your slides using Markdown. To enable Markdown, add the `data-markdown` attribute to your `<section>` elements and wrap the contents in a `<textarea data-template>` like the example below. You'll also need to add the `plugin/markdown/marked.js` and `plugin/markdown/markdown.js` scripts (in that order) to your HTML file. 165 166 This is based on [data-markdown](https://gist.github.com/1343518) from [Paul Irish](https://github.com/paulirish) modified to use [marked](https://github.com/chjj/marked) to support [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown). Sensitive to indentation (avoid mixing tabs and spaces) and line breaks (avoid consecutive breaks). 167 168 ```html 169 <section data-markdown> 170 <textarea data-template> 171 ## Page title 172 173 A paragraph with some text and a [link](http://hakim.se). 174 </textarea> 175 </section> 176 ``` 177 178 #### External Markdown 179 180 You can write your content as a separate file and have reveal.js load it at runtime. Note the separator arguments which determine how slides are delimited in the external file: the `data-separator` attribute defines a regular expression for horizontal slides (defaults to `^\r?\n---\r?\n$`, a newline-bounded horizontal rule) and `data-separator-vertical` defines vertical slides (disabled by default). The `data-separator-notes` attribute is a regular expression for specifying the beginning of the current slide's speaker notes (defaults to `notes?:`, so it will match both "note:" and "notes:"). The `data-charset` attribute is optional and specifies which charset to use when loading the external file. 181 182 When used locally, this feature requires that reveal.js [runs from a local web server](#full-setup). The following example customises all available options: 183 184 ```html 185 <section data-markdown="example.md" 186 data-separator="^\n\n\n" 187 data-separator-vertical="^\n\n" 188 data-separator-notes="^Note:" 189 data-charset="iso-8859-15"> 190 <!-- 191 Note that Windows uses `\r\n` instead of `\n` as its linefeed character. 192 For a regex that supports all operating systems, use `\r?\n` instead of `\n`. 193 --> 194 </section> 195 ``` 196 197 #### Element Attributes 198 199 Special syntax (through HTML comments) is available for adding attributes to Markdown elements. This is useful for fragments, amongst other things. 200 201 ```html 202 <section data-markdown> 203 <script type="text/template"> 204 - Item 1 <!-- .element: class="fragment" data-fragment-index="2" --> 205 - Item 2 <!-- .element: class="fragment" data-fragment-index="1" --> 206 </script> 207 </section> 208 ``` 209 210 #### Slide Attributes 211 212 Special syntax (through HTML comments) is available for adding attributes to the slide `<section>` elements generated by your Markdown. 213 214 ```html 215 <section data-markdown> 216 <script type="text/template"> 217 <!-- .slide: data-background="#ff0000" --> 218 Markdown content 219 </script> 220 </section> 221 ``` 222 223 #### Configuring *marked* 224 225 We use [marked](https://github.com/chjj/marked) to parse Markdown. To customise marked's rendering, you can pass in options when [configuring Reveal](#configuration): 226 227 ```javascript 228 Reveal.initialize({ 229 // Options which are passed into marked 230 // See https://marked.js.org/#/USING_ADVANCED.md#options 231 markdown: { 232 smartypants: true 233 } 234 }); 235 ``` 236 237 ### Configuration 238 239 At the end of your page you need to initialize reveal by running the following code. Note that all configuration values are optional and will default to the values specified below. 240 241 ```javascript 242 Reveal.initialize({ 243 244 // Display presentation control arrows 245 controls: true, 246 247 // Help the user learn the controls by providing hints, for example by 248 // bouncing the down arrow when they first encounter a vertical slide 249 controlsTutorial: true, 250 251 // Determines where controls appear, "edges" or "bottom-right" 252 controlsLayout: 'bottom-right', 253 254 // Visibility rule for backwards navigation arrows; "faded", "hidden" 255 // or "visible" 256 controlsBackArrows: 'faded', 257 258 // Display a presentation progress bar 259 progress: true, 260 261 // Display the page number of the current slide 262 slideNumber: false, 263 264 // Add the current slide number to the URL hash so that reloading the 265 // page/copying the URL will return you to the same slide 266 hash: false, 267 268 // Push each slide change to the browser history. Implies `hash: true` 269 history: false, 270 271 // Enable keyboard shortcuts for navigation 272 keyboard: true, 273 274 // Enable the slide overview mode 275 overview: true, 276 277 // Vertical centering of slides 278 center: true, 279 280 // Enables touch navigation on devices with touch input 281 touch: true, 282 283 // Loop the presentation 284 loop: false, 285 286 // Change the presentation direction to be RTL 287 rtl: false, 288 289 // See https://github.com/hakimel/reveal.js/#navigation-mode 290 navigationMode: 'default', 291 292 // Randomizes the order of slides each time the presentation loads 293 shuffle: false, 294 295 // Turns fragments on and off globally 296 fragments: true, 297 298 // Flags whether to include the current fragment in the URL, 299 // so that reloading brings you to the same fragment position 300 fragmentInURL: false, 301 302 // Flags if the presentation is running in an embedded mode, 303 // i.e. contained within a limited portion of the screen 304 embedded: false, 305 306 // Flags if we should show a help overlay when the questionmark 307 // key is pressed 308 help: true, 309 310 // Flags if speaker notes should be visible to all viewers 311 showNotes: false, 312 313 // Global override for autoplaying embedded media (video/audio/iframe) 314 // - null: Media will only autoplay if data-autoplay is present 315 // - true: All media will autoplay, regardless of individual setting 316 // - false: No media will autoplay, regardless of individual setting 317 autoPlayMedia: null, 318 319 // Global override for preloading lazy-loaded iframes 320 // - null: Iframes with data-src AND data-preload will be loaded when within 321 // the viewDistance, iframes with only data-src will be loaded when visible 322 // - true: All iframes with data-src will be loaded when within the viewDistance 323 // - false: All iframes with data-src will be loaded only when visible 324 preloadIframes: null, 325 326 // Number of milliseconds between automatically proceeding to the 327 // next slide, disabled when set to 0, this value can be overwritten 328 // by using a data-autoslide attribute on your slides 329 autoSlide: 0, 330 331 // Stop auto-sliding after user input 332 autoSlideStoppable: true, 333 334 // Use this method for navigation when auto-sliding 335 autoSlideMethod: Reveal.navigateNext, 336 337 // Specify the average time in seconds that you think you will spend 338 // presenting each slide. This is used to show a pacing timer in the 339 // speaker view 340 defaultTiming: 120, 341 342 // Enable slide navigation via mouse wheel 343 mouseWheel: false, 344 345 // Hide cursor if inactive 346 hideInactiveCursor: true, 347 348 // Time before the cursor is hidden (in ms) 349 hideCursorTime: 5000, 350 351 // Hides the address bar on mobile devices 352 hideAddressBar: true, 353 354 // Opens links in an iframe preview overlay 355 // Add `data-preview-link` and `data-preview-link="false"` to customise each link 356 // individually 357 previewLinks: false, 358 359 // Transition style 360 transition: 'slide', // none/fade/slide/convex/concave/zoom 361 362 // Transition speed 363 transitionSpeed: 'default', // default/fast/slow 364 365 // Transition style for full page slide backgrounds 366 backgroundTransition: 'fade', // none/fade/slide/convex/concave/zoom 367 368 // Number of slides away from the current that are visible 369 viewDistance: 3, 370 371 // Parallax background image 372 parallaxBackgroundImage: '', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'" 373 374 // Parallax background size 375 parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" 376 377 // Number of pixels to move the parallax background per slide 378 // - Calculated automatically unless specified 379 // - Set to 0 to disable movement along an axis 380 parallaxBackgroundHorizontal: null, 381 parallaxBackgroundVertical: null, 382 383 // The display mode that will be used to show slides 384 display: 'block' 385 386 }); 387 ``` 388 389 The configuration can be updated after initialization using the `configure` method: 390 391 ```javascript 392 // Turn autoSlide off 393 Reveal.configure({ autoSlide: 0 }); 394 395 // Start auto-sliding every 5s 396 Reveal.configure({ autoSlide: 5000 }); 397 ``` 398 399 ### Presentation Size 400 401 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. 402 403 See below for a list of configuration options related to sizing, including default values: 404 405 ```javascript 406 Reveal.initialize({ 407 408 // ... 409 410 // The "normal" size of the presentation, aspect ratio will be preserved 411 // when the presentation is scaled to fit different resolutions. Can be 412 // specified using percentage units. 413 width: 960, 414 height: 700, 415 416 // Factor of the display size that should remain empty around the content 417 margin: 0.1, 418 419 // Bounds for smallest/largest possible scale to apply to content 420 minScale: 0.2, 421 maxScale: 1.5 422 423 }); 424 ``` 425 426 If you wish to disable this behavior and do your own scaling (e.g. using media queries), try these settings: 427 428 ```javascript 429 Reveal.initialize({ 430 431 // ... 432 433 width: "100%", 434 height: "100%", 435 margin: 0, 436 minScale: 1, 437 maxScale: 1 438 }); 439 ``` 440 441 ### Dependencies 442 443 Reveal.js doesn't _rely_ on any third party scripts to work but a few optional libraries are included by default. These libraries are loaded as dependencies in the order they appear, for example: 444 445 ```javascript 446 Reveal.initialize({ 447 dependencies: [ 448 // Interpret Markdown in <section> elements 449 { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, 450 { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, 451 452 // Syntax highlight for <code> elements 453 { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, 454 455 // Zoom in and out with Alt+click 456 { src: 'plugin/zoom-js/zoom.js', async: true }, 457 458 // Speaker notes 459 { src: 'plugin/notes/notes.js', async: true }, 460 461 // MathJax 462 { src: 'plugin/math/math.js', async: true } 463 ] 464 }); 465 ``` 466 467 You can add your own extensions using the same syntax. The following properties are available for each dependency object: 468 - **src**: Path to the script to load 469 - **async**: [optional] Flags if the script should load after reveal.js has started, defaults to false 470 - **callback**: [optional] Function to execute when the script has loaded 471 - **condition**: [optional] Function which must return true for the script to be loaded 472 473 ### Ready Event 474 475 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()`. 476 477 ```javascript 478 Reveal.addEventListener( 'ready', function( event ) { 479 // event.currentSlide, event.indexh, event.indexv 480 } ); 481 ``` 482 483 Note that we also add a `.ready` class to the `.reveal` element so that you can hook into this with CSS. 484 485 ### Auto-sliding 486 487 Presentations can be configured to progress through slides automatically, without any user input. To enable this you will need to tell the framework how many milliseconds it should wait between slides: 488 489 ```javascript 490 // Slide every five seconds 491 Reveal.configure({ 492 autoSlide: 5000 493 }); 494 ``` 495 496 When this is turned on a control element will appear that enables users to pause and resume auto-sliding. Alternatively, sliding can be paused or resumed by pressing »A« on the keyboard. Sliding is paused automatically as soon as the user starts navigating. You can disable these controls by specifying `autoSlideStoppable: false` in your reveal.js config. 497 498 You can also override the slide duration for individual slides and fragments by using the `data-autoslide` attribute: 499 500 ```html 501 <section data-autoslide="2000"> 502 <p>After 2 seconds the first fragment will be shown.</p> 503 <p class="fragment" data-autoslide="10000">After 10 seconds the next fragment will be shown.</p> 504 <p class="fragment">Now, the fragment is displayed for 2 seconds before the next slide is shown.</p> 505 </section> 506 ``` 507 508 To override the method used for navigation when auto-sliding, you can specify the `autoSlideMethod` setting. To only navigate along the top layer and ignore vertical slides, set this to `Reveal.navigateRight`. 509 510 Whenever the auto-slide mode is resumed or paused the `autoslideresumed` and `autoslidepaused` events are fired. 511 512 ### Keyboard Bindings 513 514 If you're unhappy with any of the default keyboard bindings you can override them using the `keyboard` config option: 515 516 ```javascript 517 Reveal.configure({ 518 keyboard: { 519 13: 'next', // go to the next slide when the ENTER key is pressed 520 27: function() {}, // do something custom when ESC is pressed 521 32: null // don't do anything when SPACE is pressed (i.e. disable a reveal.js default binding) 522 } 523 }); 524 ``` 525 526 ### Vertical Slide Navigation 527 528 Slides can be nested within other slides to create vertical stacks (see [Markup](#markup)). When presenting, you use the left/right arrows to step through the main (horizontal) slides. When you arrive at a vertical stack you can optionally press the up/down arrows to view the vertical slides or skip past them by pressing the right arrow. Here's an example showing a bird's-eye view of what this looks like in action: 529 530 <img src="https://static.slid.es/support/reveal.js-vertical-slides.gif" width="450"> 531 532 #### Navigation Mode 533 You can finetune the reveal.js navigation behavior by using the `navigationMode` config option. Note that these options are only useful for presnetations that use a mix of horizontal and vertical slides. The following navigation modes are available: 534 535 | Value | Description | 536 | :--------------------------- | :---------- | 537 | default | Left/right arrow keys step between horizontal slides. Up/down arrow keys step between vertical slides. Space key steps through all slides (both horizontal and vertical). | 538 | linear | Removes the up/down arrows. Left/right arrows step through all slides (both horizontal and vertical). | 539 | grid | When this is enabled, stepping left/right from a vertical stack to an adjacent vertical stack will land you at the same vertical index.<br><br>Consider a deck with six slides ordered in two vertical stacks:<br>`1.1` `2.1`<br>`1.2` `2.2`<br>`1.3` `2.3`<br><br>If you're on slide 1.3 and navigate right, you will normally move from 1.3 -> 2.1. With navigationMode set to "grid" the same navigation takes you from 1.3 -> 2.3. | 540 541 ### Touch Navigation 542 543 You can swipe to navigate through a presentation on any touch-enabled device. Horizontal swipes change between horizontal slides, vertical swipes change between vertical slides. If you wish to disable this you can set the `touch` config option to false when initializing reveal.js. 544 545 If there's some part of your content that needs to remain accessible to touch events you'll need to highlight this by adding a `data-prevent-swipe` attribute to the element. One common example where this is useful is elements that need to be scrolled. 546 547 ### Lazy Loading 548 549 When working on presentation with a lot of media or iframe content it's important to load lazily. Lazy loading means that reveal.js will only load content for the few slides nearest to the current slide. The number of slides that are preloaded is determined by the `viewDistance` configuration option. 550 551 To enable lazy loading all you need to do is change your `src` attributes to `data-src` as shown below. This is supported for image, video, audio and iframe elements. 552 553 ```html 554 <section> 555 <img data-src="image.png"> 556 <iframe data-src="http://hakim.se"></iframe> 557 <video> 558 <source data-src="video.webm" type="video/webm" /> 559 <source data-src="video.mp4" type="video/mp4" /> 560 </video> 561 </section> 562 ``` 563 564 #### Lazy Loading Iframes 565 566 Note that lazy loaded iframes ignore the `viewDistance` configuration and will only load when their containing slide becomes visible. Iframes are also unloaded as soon as the slide is hidden. 567 568 When we lazy load a video or audio element, reveal.js won't start playing that content until the slide becomes visible. However there is no way to control this for an iframe since that could contain any kind of content. That means if we loaded an iframe before the slide is visible on screen it could begin playing media and sound in the background. 569 570 You can override this behavior with the `data-preload` attribute. The iframe below will be loaded 571 according to the `viewDistance`. 572 573 ```html 574 <section> 575 <iframe data-src="http://hakim.se" data-preload></iframe> 576 </section> 577 ``` 578 579 You can also change the default globally with the `preloadIframes` configuration option. If set to 580 `true` ALL iframes with a `data-src` attribute will be preloaded when within the `viewDistance` 581 regardless of individual `data-preload` attributes. If set to `false`, all iframes will only be 582 loaded when they become visible. 583 584 ### API 585 586 The `Reveal` object exposes a JavaScript API for controlling navigation and reading state: 587 588 ```javascript 589 // Navigation 590 Reveal.slide( indexh, indexv, indexf ); 591 Reveal.left(); 592 Reveal.right(); 593 Reveal.up(); 594 Reveal.down(); 595 Reveal.prev(); 596 Reveal.next(); 597 Reveal.prevFragment(); 598 Reveal.nextFragment(); 599 600 // Randomize the order of slides 601 Reveal.shuffle(); 602 603 // Toggle presentation states, optionally pass true/false to force on/off 604 Reveal.toggleOverview(); 605 Reveal.togglePause(); 606 Reveal.toggleAutoSlide(); 607 608 // Shows a help overlay with keyboard shortcuts, optionally pass true/false 609 // to force on/off 610 Reveal.toggleHelp(); 611 612 // Change a config value at runtime 613 Reveal.configure({ controls: true }); 614 615 // Returns the present configuration options 616 Reveal.getConfig(); 617 618 // Fetch the current scale of the presentation 619 Reveal.getScale(); 620 621 // Retrieves the previous and current slide elements 622 Reveal.getPreviousSlide(); 623 Reveal.getCurrentSlide(); 624 625 Reveal.getIndices(); // { h: 0, v: 0, f: 0 } 626 Reveal.getSlidePastCount(); 627 Reveal.getProgress(); // (0 == first slide, 1 == last slide) 628 Reveal.getSlides(); // Array of all slides 629 Reveal.getTotalSlides(); // Total number of slides 630 631 // Returns the speaker notes for the current slide 632 Reveal.getSlideNotes(); 633 634 // State checks 635 Reveal.isFirstSlide(); 636 Reveal.isLastSlide(); 637 Reveal.isOverview(); 638 Reveal.isPaused(); 639 Reveal.isAutoSliding(); 640 641 // Returns the top-level DOM element 642 getRevealElement(); // <div class="reveal">...</div> 643 ``` 644 645 ### Custom Key Bindings 646 647 Custom key bindings can be added and removed using the following Javascript API. Custom key bindings will override the default keyboard bindings, but will in turn be overridden by the user defined bindings in the ``keyboard`` config option. 648 649 ```javascript 650 Reveal.addKeyBinding( binding, callback ); 651 Reveal.removeKeyBinding( keyCode ); 652 ``` 653 654 For example 655 656 ```javascript 657 // The binding parameter provides the following properties 658 // keyCode: the keycode for binding to the callback 659 // key: the key label to show in the help overlay 660 // description: the description of the action to show in the help overlay 661 Reveal.addKeyBinding( { keyCode: 84, key: 'T', description: 'Start timer' }, function() { 662 // start timer 663 } ) 664 665 // The binding parameter can also be a direct keycode without providing the help description 666 Reveal.addKeyBinding( 82, function() { 667 // reset timer 668 } ) 669 ``` 670 671 This allows plugins to add key bindings directly to Reveal so they can 672 673 * make use of Reveal's pre-processing logic for key handling (for example, ignoring key presses when paused); and 674 * be included in the help overlay (optional) 675 676 ### Slide Changed Event 677 678 A `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. 679 680 Some libraries, like MathJax (see [#226](https://github.com/hakimel/reveal.js/issues/226#issuecomment-10261609)), get confused by the transforms and display states of slides. Often times, this can be fixed by calling their update or render function from this callback. 681 682 ```javascript 683 Reveal.addEventListener( 'slidechanged', function( event ) { 684 // event.previousSlide, event.currentSlide, event.indexh, event.indexv 685 } ); 686 ``` 687 688 ### Presentation State 689 690 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. 691 692 ```javascript 693 Reveal.slide( 1 ); 694 // we're on slide 1 695 696 var state = Reveal.getState(); 697 698 Reveal.slide( 3 ); 699 // we're on slide 3 700 701 Reveal.setState( state ); 702 // we're back on slide 1 703 ``` 704 705 ### Slide States 706 707 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. 708 709 Furthermore you can also listen to these changes in state via JavaScript: 710 711 ```javascript 712 Reveal.addEventListener( 'somestate', function() { 713 // TODO: Sprinkle magic 714 }, false ); 715 ``` 716 717 ### Slide Backgrounds 718 719 Slides are contained within a limited portion of the screen by default to allow them to fit any display and scale uniformly. You can apply full page backgrounds outside of the slide area by adding a `data-background` attribute to your `<section>` elements. Four different types of backgrounds are supported: color, image, video and iframe. 720 721 #### Color Backgrounds 722 723 All CSS color formats are supported, including hex values, keywords, `rgba()` or `hsl()`. 724 725 ```html 726 <section data-background-color="#ff0000"> 727 <h2>Color</h2> 728 </section> 729 ``` 730 731 #### Image Backgrounds 732 733 By default, background images are resized to cover the full page. Available options: 734 735 | Attribute | Default | Description | 736 | :------------------------------- | :--------- | :---------- | 737 | data-background-image | | URL of the image to show. GIFs restart when the slide opens. | 738 | data-background-size | cover | See [background-size](https://developer.mozilla.org/docs/Web/CSS/background-size) on MDN. | 739 | data-background-position | center | See [background-position](https://developer.mozilla.org/docs/Web/CSS/background-position) on MDN. | 740 | data-background-repeat | no-repeat | See [background-repeat](https://developer.mozilla.org/docs/Web/CSS/background-repeat) on MDN. | 741 | data-background-opacity | 1 | Opacity of the background image on a 0-1 scale. 0 is transparent and 1 is fully opaque. | 742 743 ```html 744 <section data-background-image="http://example.com/image.png"> 745 <h2>Image</h2> 746 </section> 747 <section data-background-image="http://example.com/image.png" data-background-size="100px" data-background-repeat="repeat"> 748 <h2>This background image will be sized to 100px and repeated</h2> 749 </section> 750 ``` 751 752 #### Video Backgrounds 753 754 Automatically plays a full size video behind the slide. 755 756 | Attribute | Default | Description | 757 | :--------------------------- | :------ | :---------- | 758 | data-background-video | | A single video source, or a comma separated list of video sources. | 759 | data-background-video-loop | false | Flags if the video should play repeatedly. | 760 | data-background-video-muted | false | Flags if the audio should be muted. | 761 | data-background-size | cover | Use `cover` for full screen and some cropping or `contain` for letterboxing. | 762 | data-background-opacity | 1 | Opacity of the background video on a 0-1 scale. 0 is transparent and 1 is fully opaque. | 763 764 ```html 765 <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" data-background-video-loop data-background-video-muted> 766 <h2>Video</h2> 767 </section> 768 ``` 769 770 #### Iframe Backgrounds 771 772 Embeds a web page as a slide background that covers 100% of the reveal.js width and height. The iframe is in the background layer, behind your slides, and as such it's not possible to interact with it by default. To make your background interactive, you can add the `data-background-interactive` attribute. 773 774 ```html 775 <section data-background-iframe="https://slides.com" data-background-interactive> 776 <h2>Iframe</h2> 777 </section> 778 ``` 779 780 #### Background Transitions 781 782 Backgrounds transition using a fade animation by default. This can be changed to a linear sliding transition by passing `backgroundTransition: 'slide'` to the `Reveal.initialize()` call. Alternatively you can set `data-background-transition` on any section with a background to override that specific transition. 783 784 785 ### Parallax Background 786 787 If you want to use a parallax scrolling background, set the first two properties below when initializing reveal.js (the other two are optional). 788 789 ```javascript 790 Reveal.initialize({ 791 792 // Parallax background image 793 parallaxBackgroundImage: '', // e.g. "https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg" 794 795 // Parallax background size 796 parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" - currently only pixels are supported (don't use % or auto) 797 798 // Number of pixels to move the parallax background per slide 799 // - Calculated automatically unless specified 800 // - Set to 0 to disable movement along an axis 801 parallaxBackgroundHorizontal: 200, 802 parallaxBackgroundVertical: 50 803 804 }); 805 ``` 806 807 Make sure that the background size is much bigger than screen size to allow for some scrolling. [View example](http://revealjs.com/?parallaxBackgroundImage=https%3A%2F%2Fs3.amazonaws.com%2Fhakim-static%2Freveal-js%2Freveal-parallax-1.jpg¶llaxBackgroundSize=2100px%20900px). 808 809 ### Slide Transitions 810 811 The global presentation transition is set using the `transition` config value. You can override the global transition for a specific slide by using the `data-transition` attribute: 812 813 ```html 814 <section data-transition="zoom"> 815 <h2>This slide will override the presentation transition and zoom!</h2> 816 </section> 817 818 <section data-transition-speed="fast"> 819 <h2>Choose from three transition speeds: default, fast or slow!</h2> 820 </section> 821 ``` 822 823 You can also use different in and out transitions for the same slide: 824 825 ```html 826 <section data-transition="slide"> 827 The train goes on … 828 </section> 829 <section data-transition="slide"> 830 and on … 831 </section> 832 <section data-transition="slide-in fade-out"> 833 and stops. 834 </section> 835 <section data-transition="fade-in slide-out"> 836 (Passengers entering and leaving) 837 </section> 838 <section data-transition="slide"> 839 And it starts again. 840 </section> 841 ``` 842 You can choose from `none`, `fade`, `slide`, `convex`, `concave` and `zoom`. 843 ### Internal links 844 845 It's easy to link between slides. The first example below targets the index of another slide whereas the second targets a slide with an ID attribute (`<section id="some-slide">`): 846 847 ```html 848 <a href="#/2/2">Link</a> 849 <a href="#/some-slide">Link</a> 850 ``` 851 852 You can also add relative navigation links, similar to the built in reveal.js controls, by appending one of the following classes on any element. Note that each element is automatically given an `enabled` class when it's a valid navigation route based on the current slide. 853 854 ```html 855 <a href="#" class="navigate-left"> 856 <a href="#" class="navigate-right"> 857 <a href="#" class="navigate-up"> 858 <a href="#" class="navigate-down"> 859 <a href="#" class="navigate-prev"> <!-- Previous vertical or horizontal slide --> 860 <a href="#" class="navigate-next"> <!-- Next vertical or horizontal slide --> 861 ``` 862 863 ### Fragments 864 865 Fragments are used to highlight individual elements on a slide. Every element with the class `fragment` will be stepped through before moving on to the next slide. Here's an example: http://revealjs.com/#/fragments 866 867 The default fragment style is to start out invisible and fade in. This style can be changed by appending a different class to the fragment: 868 869 ```html 870 <section> 871 <p class="fragment grow">grow</p> 872 <p class="fragment shrink">shrink</p> 873 <p class="fragment fade-out">fade-out</p> 874 <p class="fragment fade-up">fade-up (also down, left and right!)</p> 875 <p class="fragment fade-in-then-out">fades in, then out when we move to the next step</p> 876 <p class="fragment fade-in-then-semi-out">fades in, then obfuscate when we move to the next step</p> 877 <p class="fragment highlight-current-blue">blue only once</p> 878 <p class="fragment highlight-red">highlight-red</p> 879 <p class="fragment highlight-green">highlight-green</p> 880 <p class="fragment highlight-blue">highlight-blue</p> 881 </section> 882 ``` 883 884 Multiple fragments can be applied to the same element sequentially by wrapping it, this will fade in the text on the first step and fade it back out on the second. 885 886 ```html 887 <section> 888 <span class="fragment fade-in"> 889 <span class="fragment fade-out">I'll fade in, then out</span> 890 </span> 891 </section> 892 ``` 893 894 The display order of fragments can be controlled using the `data-fragment-index` attribute. 895 896 ```html 897 <section> 898 <p class="fragment" data-fragment-index="3">Appears last</p> 899 <p class="fragment" data-fragment-index="1">Appears first</p> 900 <p class="fragment" data-fragment-index="2">Appears second</p> 901 </section> 902 ``` 903 904 ### Fragment events 905 906 When a slide fragment is either shown or hidden reveal.js will dispatch an event. 907 908 Some libraries, like MathJax (see #505), get confused by the initially hidden fragment elements. Often times this can be fixed by calling their update or render function from this callback. 909 910 ```javascript 911 Reveal.addEventListener( 'fragmentshown', function( event ) { 912 // event.fragment = the fragment DOM element 913 } ); 914 Reveal.addEventListener( 'fragmenthidden', function( event ) { 915 // event.fragment = the fragment DOM element 916 } ); 917 ``` 918 919 ### Code syntax highlighting 920 921 By default, Reveal is configured with [highlight.js](https://highlightjs.org/) for code syntax highlighting. To enable syntax highlighting, you'll have to load the highlight plugin ([plugin/highlight/highlight.js](plugin/highlight/highlight.js)) and a highlight.js CSS theme (Reveal comes packaged with the Monokai themes: [lib/css/monokai.css](lib/css/monokai.css)). 922 923 ```javascript 924 Reveal.initialize({ 925 // More info https://github.com/hakimel/reveal.js#dependencies 926 dependencies: [ 927 { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, 928 ] 929 }); 930 ``` 931 932 Below is an example with clojure code that will be syntax highlighted. When the `data-trim` attribute is present, surrounding whitespace is automatically removed. HTML will be escaped by default. To avoid this, for example if you are using `<mark>` to call out a line of code, add the `data-noescape` attribute to the `<code>` element. 933 934 ```html 935 <section> 936 <pre><code data-trim data-noescape> 937 (def lazy-fib 938 (concat 939 [0 1] 940 <mark>((fn rfib [a b]</mark> 941 (lazy-cons (+ a b) (rfib b (+ a b)))) 0 1))) 942 </code></pre> 943 </section> 944 ``` 945 946 ### Slide number 947 948 If you would like to display the page number of the current slide you can do so using the `slideNumber` and `showSlideNumber` configuration values. 949 950 ```javascript 951 // Shows the slide number using default formatting 952 Reveal.configure({ slideNumber: true }); 953 954 // Slide number formatting can be configured using these variables: 955 // "h.v": horizontal . vertical slide number (default) 956 // "h/v": horizontal / vertical slide number 957 // "c": flattened slide number 958 // "c/t": flattened slide number / total slides 959 Reveal.configure({ slideNumber: 'c/t' }); 960 961 // You can provide a function to fully customize the number: 962 Reveal.configure({ slideNumber: function() { 963 // Ignore numbering of vertical slides 964 return [ Reveal.getIndices().h ]; 965 }}); 966 967 // Control which views the slide number displays on using the "showSlideNumber" value: 968 // "all": show on all views (default) 969 // "speaker": only show slide numbers on speaker notes view 970 // "print": only show slide numbers when printing to PDF 971 Reveal.configure({ showSlideNumber: 'speaker' }); 972 ``` 973 974 ### Overview mode 975 976 Press »ESC« or »O« keys to toggle the overview mode on and off. While you're in this mode, you can still navigate between slides, 977 as if you were at 1,000 feet above your presentation. The overview mode comes with a few API hooks: 978 979 ```javascript 980 Reveal.addEventListener( 'overviewshown', function( event ) { /* ... */ } ); 981 Reveal.addEventListener( 'overviewhidden', function( event ) { /* ... */ } ); 982 983 // Toggle the overview mode programmatically 984 Reveal.toggleOverview(); 985 ``` 986 987 ### Fullscreen mode 988 989 Just press »F« on your keyboard to show your presentation in fullscreen mode. Press the »ESC« key to exit fullscreen mode. 990 991 ### Embedded media 992 993 Add `data-autoplay` to your media element if you want it to automatically start playing when the slide is shown: 994 995 ```html 996 <video data-autoplay src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"></video> 997 ``` 998 999 If you want to enable or disable autoplay globally, for all embedded media, you can use the `autoPlayMedia` configuration option. If you set this to `true` ALL media will autoplay regardless of individual `data-autoplay` attributes. If you initialize with `autoPlayMedia: false` NO media will autoplay. 1000 1001 Note that embedded HTML5 `<video>`/`<audio>` and YouTube/Vimeo iframes are automatically paused when you navigate away from a slide. This can be disabled by decorating your element with a `data-ignore` attribute. 1002 1003 ### Embedded iframes 1004 1005 reveal.js automatically pushes two [post messages](https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage) to embedded iframes. `slide:start` when the slide containing the iframe is made visible and `slide:stop` when it is hidden. 1006 1007 ### Stretching elements 1008 1009 Sometimes it's desirable to have an element, like an image or video, stretch to consume as much space as possible within a given slide. This can be done by adding the `.stretch` class to an element as seen below: 1010 1011 ```html 1012 <section> 1013 <h2>This video will use up the remaining space on the slide</h2> 1014 <video class="stretch" src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"></video> 1015 </section> 1016 ``` 1017 1018 Limitations: 1019 - Only direct descendants of a slide section can be stretched 1020 - Only one descendant per slide section can be stretched 1021 1022 ### Resize Event 1023 1024 When reveal.js changes the scale of the slides it fires a resize event. You can subscribe to the event to resize your elements accordingly. 1025 1026 ```javascript 1027 Reveal.addEventListener( 'resize', function( event ) { 1028 // event.scale, event.oldScale, event.size 1029 } ); 1030 ``` 1031 1032 ### postMessage API 1033 1034 The framework has a built-in postMessage API that can be used when communicating with a presentation inside of another window. Here's an example showing how you'd make a reveal.js instance in the given window proceed to slide 2: 1035 1036 ```javascript 1037 <window>.postMessage( JSON.stringify({ method: 'slide', args: [ 2 ] }), '*' ); 1038 ``` 1039 1040 When reveal.js runs inside of an iframe it can optionally bubble all of its events to the parent. Bubbled events are stringified JSON with three fields: namespace, eventName and state. Here's how you subscribe to them from the parent window: 1041 1042 ```javascript 1043 window.addEventListener( 'message', function( event ) { 1044 var data = JSON.parse( event.data ); 1045 if( data.namespace === 'reveal' && data.eventName ==='slidechanged' ) { 1046 // Slide changed, see data.state for slide number 1047 } 1048 } ); 1049 ``` 1050 1051 This cross-window messaging can be toggled on or off using configuration flags. 1052 1053 ```javascript 1054 Reveal.initialize({ 1055 // ... 1056 1057 // Exposes the reveal.js API through window.postMessage 1058 postMessage: true, 1059 1060 // Dispatches all reveal.js events to the parent window through postMessage 1061 postMessageEvents: false 1062 }); 1063 ``` 1064 1065 1066 ## PDF Export 1067 1068 Presentations can be exported to PDF via a special print stylesheet. This feature requires that you use [Google Chrome](http://google.com/chrome) or [Chromium](https://www.chromium.org/Home) and to be serving the presentation from a web server. 1069 Here's an example of an exported presentation that's been uploaded to SlideShare: http://www.slideshare.net/hakimel/revealjs-300. 1070 1071 ### Separate pages for fragments 1072 [Fragments](#fragments) are printed on separate slides by default. Meaning if you have a slide with three fragment steps, it will generate three separate slides where the fragments appear incrementally. 1073 1074 If you prefer printing all fragments in their visible states on the same slide you can set the `pdfSeparateFragments` config option to false. 1075 1076 ### Page size 1077 1078 Export dimensions are inferred from the configured [presentation size](#presentation-size). Slides that are too tall to fit within a single page will expand onto multiple pages. You can limit how many pages a slide may expand onto using the `pdfMaxPagesPerSlide` config option, for example `Reveal.configure({ pdfMaxPagesPerSlide: 1 })` ensures that no slide ever grows to more than one printed page. 1079 1080 ### Print stylesheet 1081 1082 To enable the PDF print capability in your presentation, the special print stylesheet at [/css/print/pdf.css](https://github.com/hakimel/reveal.js/blob/master/css/print/pdf.css) must be loaded. The default index.html file handles this for you when `print-pdf` is included in the query string. If you're using a different HTML template, you can add this to your HEAD: 1083 1084 ```html 1085 <script> 1086 var link = document.createElement( 'link' ); 1087 link.rel = 'stylesheet'; 1088 link.type = 'text/css'; 1089 link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css'; 1090 document.getElementsByTagName( 'head' )[0].appendChild( link ); 1091 </script> 1092 ``` 1093 1094 ### Instructions 1095 1096 1. Open your presentation with `print-pdf` included in the query string i.e. http://localhost:8000/?print-pdf. You can test this with [revealjs.com?print-pdf](http://revealjs.com?print-pdf). 1097 * If you want to include [speaker notes](#speaker-notes) in your export, you can append `showNotes=true` to the query string: http://localhost:8000/?print-pdf&showNotes=true 1098 1. Open the in-browser print dialog (CTRL/CMD+P). 1099 1. Change the **Destination** setting to **Save as PDF**. 1100 1. Change the **Layout** to **Landscape**. 1101 1. Change the **Margins** to **None**. 1102 1. Enable the **Background graphics** option. 1103 1. Click **Save**. 1104 1105  1106 1107 Alternatively you can use the [decktape](https://github.com/astefanutti/decktape) project. 1108 1109 1110 ## Theming 1111 1112 The framework comes with a few different themes included: 1113 1114 - black: Black background, white text, blue links (default theme) 1115 - white: White background, black text, blue links 1116 - league: Gray background, white text, blue links (default theme for reveal.js < 3.0.0) 1117 - beige: Beige background, dark text, brown links 1118 - sky: Blue background, thin dark text, blue links 1119 - night: Black background, thick white text, orange links 1120 - serif: Cappuccino background, gray text, brown links 1121 - simple: White background, black text, blue links 1122 - solarized: Cream-colored background, dark green text, blue links 1123 1124 Each theme is available as a separate stylesheet. To change theme you will need to replace **black** below with your desired theme name in index.html: 1125 1126 ```html 1127 <link rel="stylesheet" href="css/theme/black.css" id="theme"> 1128 ``` 1129 1130 If you want to add a theme of your own see the instructions here: [/css/theme/README.md](https://github.com/hakimel/reveal.js/blob/master/css/theme/README.md). 1131 1132 1133 ## Speaker Notes 1134 1135 reveal.js comes with a speaker notes plugin which can be used to present per-slide notes in a separate browser window. The notes window also gives you a preview of the next upcoming slide so it may be helpful even if you haven't written any notes. Press the »S« key on your keyboard to open the notes window. 1136 1137 A speaker timer starts as soon as the speaker view is opened. You can reset it to 00:00:00 at any time by simply clicking/tapping on it. 1138 1139 Notes are defined by appending an `<aside>` element to a slide as seen below. You can add the `data-markdown` attribute to the aside element if you prefer writing notes using Markdown. 1140 1141 Alternatively you can add your notes in a `data-notes` attribute on the slide. Like `<section data-notes="Something important"></section>`. 1142 1143 When used locally, this feature requires that reveal.js [runs from a local web server](#full-setup). 1144 1145 ```html 1146 <section> 1147 <h2>Some Slide</h2> 1148 1149 <aside class="notes"> 1150 Oh hey, these are some notes. They'll be hidden in your presentation, but you can see them if you open the speaker notes window (hit »S« on your keyboard). 1151 </aside> 1152 </section> 1153 ``` 1154 1155 If you're using the external Markdown plugin, you can add notes with the help of a special delimiter: 1156 1157 ```html 1158 <section data-markdown="example.md" data-separator="^\n\n\n" data-separator-vertical="^\n\n" data-separator-notes="^Note:"></section> 1159 1160 # Title 1161 ## Sub-title 1162 1163 Here is some content... 1164 1165 Note: 1166 This will only display in the notes window. 1167 ``` 1168 1169 #### Share and Print Speaker Notes 1170 1171 Notes are only visible to the speaker inside of the speaker view. If you wish to share your notes with others you can initialize reveal.js with the `showNotes` configuration value set to `true`. Notes will appear along the bottom of the presentations. 1172 1173 When `showNotes` is enabled notes are also included when you [export to PDF](https://github.com/hakimel/reveal.js#pdf-export). By default, notes are printed in a box on top of the slide. If you'd rather print them on a separate page, after the slide, set `showNotes: "separate-page"`. 1174 1175 #### Speaker notes clock and timers 1176 1177 The speaker notes window will also show: 1178 1179 - Time elapsed since the beginning of the presentation. If you hover the mouse above this section, a timer reset button will appear. 1180 - Current wall-clock time 1181 - (Optionally) a pacing timer which indicates whether the current pace of the presentation is on track for the right timing (shown in green), and if not, whether the presenter should speed up (shown in red) or has the luxury of slowing down (blue). 1182 1183 The pacing timer can be enabled by configuring by the `defaultTiming` parameter in the `Reveal` configuration block, which specifies the number of seconds per slide. 120 can be a reasonable rule of thumb. Timings can also be given per slide `<section>` by setting the `data-timing` attribute. Both values are in numbers of seconds. 1184 1185 1186 ## Server Side Speaker Notes 1187 1188 In some cases it can be desirable to run notes on a separate device from the one you're presenting on. The Node.js-based notes plugin lets you do this using the same note definitions as its client side counterpart. Include the required scripts by adding the following dependencies: 1189 1190 ```javascript 1191 Reveal.initialize({ 1192 // ... 1193 1194 dependencies: [ 1195 { src: 'socket.io/socket.io.js', async: true }, 1196 { src: 'plugin/notes-server/client.js', async: true } 1197 ] 1198 }); 1199 ``` 1200 1201 Then: 1202 1203 1. Install [Node.js](http://nodejs.org/) (4.0.0 or later) 1204 2. Run `npm install` 1205 3. Run `node plugin/notes-server` 1206 1207 1208 ## Multiplexing 1209 1210 The multiplex plugin allows your audience to view the slides of the presentation you are controlling on their own phone, tablet or laptop. As the master presentation navigates the slides, all client presentations will update in real time. See a demo at [https://reveal-js-multiplex-ccjbegmaii.now.sh/](https://reveal-js-multiplex-ccjbegmaii.now.sh/). 1211 1212 The multiplex plugin needs the following 3 things to operate: 1213 1214 1. Master presentation that has control 1215 2. Client presentations that follow the master 1216 3. Socket.io server to broadcast events from the master to the clients 1217 1218 #### Master presentation 1219 1220 Served from a static file server accessible (preferably) only to the presenter. This need only be on your (the presenter's) computer. (It's safer to run the master presentation from your own computer, so if the venue's Internet goes down it doesn't stop the show.) An example would be to execute the following commands in the directory of your master presentation: 1221 1222 1. `npm install node-static` 1223 2. `static` 1224 1225 If you want to use the speaker notes plugin with your master presentation then make sure you have the speaker notes plugin configured correctly along with the configuration shown below, then execute `node plugin/notes-server` in the directory of your master presentation. The configuration below will cause it to connect to the socket.io server as a master, as well as launch your speaker-notes/static-file server. 1226 1227 You can then access your master presentation at `http://localhost:1947` 1228 1229 Example configuration: 1230 1231 ```javascript 1232 Reveal.initialize({ 1233 // other options... 1234 1235 multiplex: { 1236 // Example values. To generate your own, see the socket.io server instructions. 1237 secret: '13652805320794272084', // Obtained from the socket.io server. Gives this (the master) control of the presentation 1238 id: '1ea875674b17ca76', // Obtained from socket.io server 1239 url: 'https://reveal-js-multiplex-ccjbegmaii.now.sh' // Location of socket.io server 1240 }, 1241 1242 // Don't forget to add the dependencies 1243 dependencies: [ 1244 { src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js', async: true }, 1245 { src: 'plugin/multiplex/master.js', async: true }, 1246 1247 // and if you want speaker notes 1248 { src: 'plugin/notes-server/client.js', async: true } 1249 1250 // other dependencies... 1251 ] 1252 }); 1253 ``` 1254 1255 #### Client presentation 1256 1257 Served from a publicly accessible static file server. Examples include: GitHub Pages, Amazon S3, Dreamhost, Akamai, etc. The more reliable, the better. Your audience can then access the client presentation via `http://example.com/path/to/presentation/client/index.html`, with the configuration below causing them to connect to the socket.io server as clients. 1258 1259 Example configuration: 1260 1261 ```javascript 1262 Reveal.initialize({ 1263 // other options... 1264 1265 multiplex: { 1266 // Example values. To generate your own, see the socket.io server instructions. 1267 secret: null, // null so the clients do not have control of the master presentation 1268 id: '1ea875674b17ca76', // id, obtained from socket.io server 1269 url: 'https://reveal-js-multiplex-ccjbegmaii.now.sh' // Location of socket.io server 1270 }, 1271 1272 // Don't forget to add the dependencies 1273 dependencies: [ 1274 { src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js', async: true }, 1275 { src: 'plugin/multiplex/client.js', async: true } 1276 1277 // other dependencies... 1278 ] 1279 }); 1280 ``` 1281 1282 #### Socket.io server 1283 1284 Server that receives the `slideChanged` events from the master presentation and broadcasts them out to the connected client presentations. This needs to be publicly accessible. You can run your own socket.io server with the commands: 1285 1286 1. `npm install` 1287 2. `node plugin/multiplex` 1288 1289 Or you can use the socket.io server at [https://reveal-js-multiplex-ccjbegmaii.now.sh/](https://reveal-js-multiplex-ccjbegmaii.now.sh/). 1290 1291 You'll need to generate a unique secret and token pair for your master and client presentations. To do so, visit `http://example.com/token`, where `http://example.com` is the location of your socket.io server. Or if you're going to use the socket.io server at [https://reveal-js-multiplex-ccjbegmaii.now.sh/](https://reveal-js-multiplex-ccjbegmaii.now.sh/), visit [https://reveal-js-multiplex-ccjbegmaii.now.sh/token](https://reveal-js-multiplex-ccjbegmaii.now.sh/token). 1292 1293 You are very welcome to point your presentations at the Socket.io server running at [https://reveal-js-multiplex-ccjbegmaii.now.sh/](https://reveal-js-multiplex-ccjbegmaii.now.sh/), but availability and stability are not guaranteed. 1294 1295 For anything mission critical I recommend you run your own server. The easiest way to do this is by installing [now](https://zeit.co/now). With that installed, deploying your own Multiplex server is as easy running the following command from the reveal.js folder: `now plugin/multiplex`. 1296 1297 ##### socket.io server as file static server 1298 1299 The socket.io server can play the role of static file server for your client presentation, as in the example at [https://reveal-js-multiplex-ccjbegmaii.now.sh/](https://reveal-js-multiplex-ccjbegmaii.now.sh/). (Open [https://reveal-js-multiplex-ccjbegmaii.now.sh/](https://reveal-js-multiplex-ccjbegmaii.now.sh/) in two browsers. Navigate through the slides on one, and the other will update to match.) 1300 1301 Example configuration: 1302 1303 ```javascript 1304 Reveal.initialize({ 1305 // other options... 1306 1307 multiplex: { 1308 // Example values. To generate your own, see the socket.io server instructions. 1309 secret: null, // null so the clients do not have control of the master presentation 1310 id: '1ea875674b17ca76', // id, obtained from socket.io server 1311 url: 'example.com:80' // Location of your socket.io server 1312 }, 1313 1314 // Don't forget to add the dependencies 1315 dependencies: [ 1316 { src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js', async: true }, 1317 { src: 'plugin/multiplex/client.js', async: true } 1318 1319 // other dependencies... 1320 ] 1321 ``` 1322 1323 It can also play the role of static file server for your master presentation and client presentations at the same time (as long as you don't want to use speaker notes). (Open [https://reveal-js-multiplex-ccjbegmaii.now.sh/](https://reveal-js-multiplex-ccjbegmaii.now.sh/) in two browsers. Navigate through the slides on one, and the other will update to match. Navigate through the slides on the second, and the first will update to match.) This is probably not desirable, because you don't want your audience to mess with your slides while you're presenting. ;) 1324 1325 Example configuration: 1326 1327 ```javascript 1328 Reveal.initialize({ 1329 // other options... 1330 1331 multiplex: { 1332 // Example values. To generate your own, see the socket.io server instructions. 1333 secret: '13652805320794272084', // Obtained from the socket.io server. Gives this (the master) control of the presentation 1334 id: '1ea875674b17ca76', // Obtained from socket.io server 1335 url: 'example.com:80' // Location of your socket.io server 1336 }, 1337 1338 // Don't forget to add the dependencies 1339 dependencies: [ 1340 { src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js', async: true }, 1341 { src: 'plugin/multiplex/master.js', async: true }, 1342 { src: 'plugin/multiplex/client.js', async: true } 1343 1344 // other dependencies... 1345 ] 1346 }); 1347 ``` 1348 1349 1350 ## MathJax 1351 1352 If you want to display math equations in your presentation you can easily do so by including this plugin. The plugin is a very thin wrapper around the [MathJax](http://www.mathjax.org/) library. To use it you'll need to include it as a reveal.js dependency, [find our more about dependencies here](#dependencies). 1353 1354 The plugin defaults to using [LaTeX](http://en.wikipedia.org/wiki/LaTeX) but that can be adjusted through the `math` configuration object. Note that MathJax is loaded from a remote server. If you want to use it offline you'll need to download a copy of the library and adjust the `mathjax` configuration value. 1355 1356 Below is an example of how the plugin can be configured. If you don't intend to change these values you do not need to include the `math` config object at all. 1357 1358 ```js 1359 Reveal.initialize({ 1360 // other options ... 1361 1362 math: { 1363 mathjax: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js', 1364 config: 'TeX-AMS_HTML-full' // See http://docs.mathjax.org/en/latest/config-files.html 1365 // pass other options into `MathJax.Hub.Config()` 1366 TeX: { Macros: macros } 1367 }, 1368 1369 dependencies: [ 1370 { src: 'plugin/math/math.js', async: true } 1371 ] 1372 }); 1373 ``` 1374 1375 Read MathJax's documentation if you need [HTTPS delivery](http://docs.mathjax.org/en/latest/start.html#secure-access-to-the-cdn) or serving of [specific versions](http://docs.mathjax.org/en/latest/configuration.html#loading-mathjax-from-the-cdn) for stability. 1376 1377 #### MathJax in Markdown 1378 If you want to include math inside of a presentation written in Markdown you need to wrap the formula in backticks. This prevents syntax conflicts between LaTeX and Markdown. For example: 1379 1380 ``` 1381 `$$ J(\theta_0,\theta_1) = \sum_{i=0} $$` 1382 ``` 1383 1384 ## License 1385 1386 MIT licensed 1387 1388 Copyright (C) 2019 Hakim El Hattab, http://hakim.se