github.com/mweagle/Sparta@v1.15.0/docs_source/static/presentations/reveal.js-3.9.2/README.md (about) 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](https://revealjs.com/). 4 5 reveal.js comes with a broad range of features including [nested slides](https://github.com/hakimel/reveal.js#markup), [Markdown support](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 ### Supporting reveal.js 8 This project was started and is maintained by [@hakimel](https://github.com/hakimel/) with the help of many [contributions from the community](https://github.com/hakimel/reveal.js/graphs/contributors). The best way to support the project is to [become a paying member of Slides.com](https://slides.com/pricing)—the reveal.js presentation platform that Hakim is building. 9 10 11 ## Table of contents 12 13 - [Online Editor](#online-editor) 14 - [Installation](#installation) 15 - [Basic setup](#basic-setup) 16 - [Full setup](#full-setup) 17 - [Folder Structure](#folder-structure) 18 - [Instructions](#instructions) 19 - [Markup](#markup) 20 - [Markdown](#markdown) 21 - [Element Attributes](#element-attributes) 22 - [Slide Attributes](#slide-attributes) 23 - [Configuration](#configuration) 24 - [Presentation Size](#presentation-size) 25 - [Dependencies](#dependencies) 26 - [Ready Event](#ready-event) 27 - [Auto-sliding](#auto-sliding) 28 - [Keyboard Bindings](#keyboard-bindings) 29 - [Vertical Slide Navigation](#vertical-slide-navigation) 30 - [Touch Navigation](#touch-navigation) 31 - [Lazy Loading](#lazy-loading) 32 - [API](#api) 33 - [Custom Key Bindings](#custom-key-bindings) 34 - [Slide Changed Event](#slide-changed-event) 35 - [Presentation State](#presentation-state) 36 - [Slide States](#slide-states) 37 - [Slide Backgrounds](#slide-backgrounds) 38 - [Parallax Background](#parallax-background) 39 - [Slide Transitions](#slide-transitions) 40 - [Internal links](#internal-links) 41 - [Fragments](#fragments) 42 - [Fragment events](#fragment-events) 43 - [Code syntax highlighting](#code-syntax-highlighting) 44 - [Slide number](#slide-number) 45 - [Overview mode](#overview-mode) 46 - [Fullscreen mode](#fullscreen-mode) 47 - [Embedded media](#embedded-media) 48 - [Stretching elements](#stretching-elements) 49 - [Resize Event](#resize-event) 50 - [postMessage API](#postmessage-api) 51 - [PDF Export](#pdf-export) 52 - [Theming](#theming) 53 - [Speaker Notes](#speaker-notes) 54 - [Share and Print Speaker Notes](#share-and-print-speaker-notes) 55 - [Server Side Speaker Notes](#server-side-speaker-notes) 56 - [Plugins](#plugins) 57 - [Multiplexing](#multiplexing) 58 - [Master presentation](#master-presentation) 59 - [Client presentation](#client-presentation) 60 - [Socket.io server](#socketio-server) 61 - [MathJax](#mathjax) 62 - [License](#license) 63 64 #### More reading 65 66 - [Changelog](https://github.com/hakimel/reveal.js/releases): Up-to-date version history. 67 - [Examples](https://github.com/hakimel/reveal.js/wiki/Example-Presentations): Presentations created with reveal.js, add your own! 68 - [Browser Support](https://github.com/hakimel/reveal.js/wiki/Browser-Support): Explanation of browser support and fallbacks. 69 - [Plugins](https://github.com/hakimel/reveal.js/wiki/Plugins,-Tools-and-Hardware): A list of plugins that can be used to extend reveal.js. 70 71 72 ## Online Editor 73 74 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). 75 76 77 ## Installation 78 79 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. 80 81 ### Basic setup 82 83 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. 84 85 1. Download the latest version of reveal.js from <https://github.com/hakimel/reveal.js/releases> 86 2. Unzip and replace the example contents in index.html with your own 87 3. Open index.html in a browser to view it 88 89 ### Full setup 90 91 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. 92 93 1. Install [Node.js](https://nodejs.org/) (9.0.0 or later) 94 95 1. Clone the reveal.js repository 96 ```sh 97 $ git clone https://github.com/hakimel/reveal.js.git 98 ``` 99 100 1. Navigate to the reveal.js folder 101 ```sh 102 $ cd reveal.js 103 ``` 104 105 1. Install dependencies 106 ```sh 107 $ npm install 108 ``` 109 110 1. Serve the presentation and monitor source files for changes 111 ```sh 112 $ npm start 113 ``` 114 115 1. Open <http://localhost:8000> to view your presentation 116 117 You can change the port by using `npm start -- --port=8001`. 118 119 ### Folder Structure 120 121 - **css/** Core styles without which the project does not function 122 - **js/** Like above but for JavaScript 123 - **plugin/** Components that have been developed as extensions to reveal.js 124 - **lib/** All other third party assets (JavaScript, CSS, fonts) 125 126 127 ## Instructions 128 129 ### Markup 130 131 Here's a barebones example of a fully working reveal.js presentation: 132 ```html 133 <html> 134 <head> 135 <link rel="stylesheet" href="css/reveal.css"> 136 <link rel="stylesheet" href="css/theme/white.css"> 137 </head> 138 <body> 139 <div class="reveal"> 140 <div class="slides"> 141 <section>Slide 1</section> 142 <section>Slide 2</section> 143 </div> 144 </div> 145 <script src="js/reveal.js"></script> 146 <script> 147 Reveal.initialize(); 148 </script> 149 </body> 150 </html> 151 ``` 152 153 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: 154 155 ```html 156 <div class="reveal"> 157 <div class="slides"> 158 <section>Single Horizontal Slide</section> 159 <section> 160 <section>Vertical Slide 1</section> 161 <section>Vertical Slide 2</section> 162 </section> 163 </div> 164 </div> 165 ``` 166 167 ### Markdown 168 169 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. 170 171 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). 172 173 ```html 174 <section data-markdown> 175 <textarea data-template> 176 ## Page title 177 178 A paragraph with some text and a [link](http://hakim.se). 179 </textarea> 180 </section> 181 ``` 182 183 #### External Markdown 184 185 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. 186 187 When used locally, this feature requires that reveal.js [runs from a local web server](#full-setup). The following example customises all available options: 188 189 ```html 190 <section data-markdown="example.md" 191 data-separator="^\n\n\n" 192 data-separator-vertical="^\n\n" 193 data-separator-notes="^Note:" 194 data-charset="iso-8859-15"> 195 <!-- 196 Note that Windows uses `\r\n` instead of `\n` as its linefeed character. 197 For a regex that supports all operating systems, use `\r?\n` instead of `\n`. 198 --> 199 </section> 200 ``` 201 202 #### Element Attributes 203 204 Special syntax (through HTML comments) is available for adding attributes to Markdown elements. This is useful for fragments, amongst other things. 205 206 ```html 207 <section data-markdown> 208 <script type="text/template"> 209 - Item 1 <!-- .element: class="fragment" data-fragment-index="2" --> 210 - Item 2 <!-- .element: class="fragment" data-fragment-index="1" --> 211 </script> 212 </section> 213 ``` 214 215 #### Slide Attributes 216 217 Special syntax (through HTML comments) is available for adding attributes to the slide `<section>` elements generated by your Markdown. 218 219 ```html 220 <section data-markdown> 221 <script type="text/template"> 222 <!-- .slide: data-background="#ff0000" --> 223 Markdown content 224 </script> 225 </section> 226 ``` 227 228 #### Configuring *marked* 229 230 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): 231 232 ```javascript 233 Reveal.initialize({ 234 // Options which are passed into marked 235 // See https://marked.js.org/#/USING_ADVANCED.md#options 236 markdown: { 237 smartypants: true 238 } 239 }); 240 ``` 241 242 ### Configuration 243 244 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. 245 246 ```javascript 247 Reveal.initialize({ 248 249 // Display presentation control arrows 250 controls: true, 251 252 // Help the user learn the controls by providing hints, for example by 253 // bouncing the down arrow when they first encounter a vertical slide 254 controlsTutorial: true, 255 256 // Determines where controls appear, "edges" or "bottom-right" 257 controlsLayout: 'bottom-right', 258 259 // Visibility rule for backwards navigation arrows; "faded", "hidden" 260 // or "visible" 261 controlsBackArrows: 'faded', 262 263 // Display a presentation progress bar 264 progress: true, 265 266 // Display the page number of the current slide 267 slideNumber: false, 268 269 // Add the current slide number to the URL hash so that reloading the 270 // page/copying the URL will return you to the same slide 271 hash: false, 272 273 // Push each slide change to the browser history. Implies `hash: true` 274 history: false, 275 276 // Enable keyboard shortcuts for navigation 277 keyboard: true, 278 279 // Enable the slide overview mode 280 overview: true, 281 282 // Vertical centering of slides 283 center: true, 284 285 // Enables touch navigation on devices with touch input 286 touch: true, 287 288 // Loop the presentation 289 loop: false, 290 291 // Change the presentation direction to be RTL 292 rtl: false, 293 294 // See https://github.com/hakimel/reveal.js/#navigation-mode 295 navigationMode: 'default', 296 297 // Randomizes the order of slides each time the presentation loads 298 shuffle: false, 299 300 // Turns fragments on and off globally 301 fragments: true, 302 303 // Flags whether to include the current fragment in the URL, 304 // so that reloading brings you to the same fragment position 305 fragmentInURL: false, 306 307 // Flags if the presentation is running in an embedded mode, 308 // i.e. contained within a limited portion of the screen 309 embedded: false, 310 311 // Flags if we should show a help overlay when the questionmark 312 // key is pressed 313 help: true, 314 315 // Flags if speaker notes should be visible to all viewers 316 showNotes: false, 317 318 // Global override for autoplaying embedded media (video/audio/iframe) 319 // - null: Media will only autoplay if data-autoplay is present 320 // - true: All media will autoplay, regardless of individual setting 321 // - false: No media will autoplay, regardless of individual setting 322 autoPlayMedia: null, 323 324 // Global override for preloading lazy-loaded iframes 325 // - null: Iframes with data-src AND data-preload will be loaded when within 326 // the viewDistance, iframes with only data-src will be loaded when visible 327 // - true: All iframes with data-src will be loaded when within the viewDistance 328 // - false: All iframes with data-src will be loaded only when visible 329 preloadIframes: null, 330 331 // Number of milliseconds between automatically proceeding to the 332 // next slide, disabled when set to 0, this value can be overwritten 333 // by using a data-autoslide attribute on your slides 334 autoSlide: 0, 335 336 // Stop auto-sliding after user input 337 autoSlideStoppable: true, 338 339 // Use this method for navigation when auto-sliding 340 autoSlideMethod: Reveal.navigateNext, 341 342 // Specify the average time in seconds that you think you will spend 343 // presenting each slide. This is used to show a pacing timer in the 344 // speaker view 345 defaultTiming: 120, 346 347 // Specify the total time in seconds that is available to 348 // present. If this is set to a nonzero value, the pacing 349 // timer will work out the time available for each slide, 350 // instead of using the defaultTiming value 351 totalTime: 0, 352 353 // Specify the minimum amount of time you want to allot to 354 // each slide, if using the totalTime calculation method. If 355 // the automated time allocation causes slide pacing to fall 356 // below this threshold, then you will see an alert in the 357 // speaker notes window 358 minimumTimePerSlide: 0; 359 360 // Enable slide navigation via mouse wheel 361 mouseWheel: false, 362 363 // Hide cursor if inactive 364 hideInactiveCursor: true, 365 366 // Time before the cursor is hidden (in ms) 367 hideCursorTime: 5000, 368 369 // Hides the address bar on mobile devices 370 hideAddressBar: true, 371 372 // Opens links in an iframe preview overlay 373 // Add `data-preview-link` and `data-preview-link="false"` to customise each link 374 // individually 375 previewLinks: false, 376 377 // Transition style 378 transition: 'slide', // none/fade/slide/convex/concave/zoom 379 380 // Transition speed 381 transitionSpeed: 'default', // default/fast/slow 382 383 // Transition style for full page slide backgrounds 384 backgroundTransition: 'fade', // none/fade/slide/convex/concave/zoom 385 386 // Number of slides away from the current that are visible 387 viewDistance: 3, 388 389 // Number of slides away from the current that are visible on mobile 390 // devices. It is advisable to set this to a lower number than 391 // viewDistance in order to save resources. 392 mobileViewDistance: 2, 393 394 // Parallax background image 395 parallaxBackgroundImage: '', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'" 396 397 // Parallax background size 398 parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" 399 400 // Number of pixels to move the parallax background per slide 401 // - Calculated automatically unless specified 402 // - Set to 0 to disable movement along an axis 403 parallaxBackgroundHorizontal: null, 404 parallaxBackgroundVertical: null, 405 406 // The display mode that will be used to show slides 407 display: 'block' 408 409 }); 410 ``` 411 412 The configuration can be updated after initialization using the `configure` method: 413 414 ```javascript 415 // Turn autoSlide off 416 Reveal.configure({ autoSlide: 0 }); 417 418 // Start auto-sliding every 5s 419 Reveal.configure({ autoSlide: 5000 }); 420 ``` 421 422 ### Presentation Size 423 424 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. 425 426 See below for a list of configuration options related to sizing, including default values: 427 428 ```javascript 429 Reveal.initialize({ 430 431 // ... 432 433 // The "normal" size of the presentation, aspect ratio will be preserved 434 // when the presentation is scaled to fit different resolutions. Can be 435 // specified using percentage units. 436 width: 960, 437 height: 700, 438 439 // Factor of the display size that should remain empty around the content 440 margin: 0.1, 441 442 // Bounds for smallest/largest possible scale to apply to content 443 minScale: 0.2, 444 maxScale: 1.5 445 446 }); 447 ``` 448 449 If you wish to disable this behavior and do your own scaling (e.g. using media queries), try these settings: 450 451 ```javascript 452 Reveal.initialize({ 453 454 // ... 455 456 width: "100%", 457 height: "100%", 458 margin: 0, 459 minScale: 1, 460 maxScale: 1 461 }); 462 ``` 463 464 ### Dependencies 465 466 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: 467 468 ```javascript 469 Reveal.initialize({ 470 dependencies: [ 471 // Interpret Markdown in <section> elements 472 { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, 473 { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, 474 475 // Syntax highlight for <code> elements 476 { src: 'plugin/highlight/highlight.js', async: true }, 477 478 // Zoom in and out with Alt+click 479 { src: 'plugin/zoom-js/zoom.js', async: true }, 480 481 // Speaker notes 482 { src: 'plugin/notes/notes.js', async: true }, 483 484 // MathJax 485 { src: 'plugin/math/math.js', async: true } 486 ] 487 }); 488 ``` 489 490 You can add your own extensions using the same syntax. The following properties are available for each dependency object: 491 - **src**: Path to the script to load 492 - **async**: [optional] Flags if the script should load after reveal.js has started, defaults to false 493 - **callback**: [optional] Function to execute when the script has loaded 494 - **condition**: [optional] Function which must return true for the script to be loaded 495 496 ### Ready Event 497 498 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()`. 499 500 ```javascript 501 Reveal.addEventListener( 'ready', function( event ) { 502 // event.currentSlide, event.indexh, event.indexv 503 } ); 504 ``` 505 506 Note that we also add a `.ready` class to the `.reveal` element so that you can hook into this with CSS. 507 508 ### Auto-sliding 509 510 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: 511 512 ```javascript 513 // Slide every five seconds 514 Reveal.configure({ 515 autoSlide: 5000 516 }); 517 ``` 518 519 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. 520 521 You can also override the slide duration for individual slides and fragments by using the `data-autoslide` attribute: 522 523 ```html 524 <section data-autoslide="2000"> 525 <p>After 2 seconds the first fragment will be shown.</p> 526 <p class="fragment" data-autoslide="10000">After 10 seconds the next fragment will be shown.</p> 527 <p class="fragment">Now, the fragment is displayed for 2 seconds before the next slide is shown.</p> 528 </section> 529 ``` 530 531 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`. 532 533 Whenever the auto-slide mode is resumed or paused the `autoslideresumed` and `autoslidepaused` events are fired. 534 535 ### Keyboard Bindings 536 537 If you're unhappy with any of the default keyboard bindings you can override them using the `keyboard` config option: 538 539 ```javascript 540 Reveal.configure({ 541 keyboard: { 542 13: 'next', // go to the next slide when the ENTER key is pressed 543 27: function() {}, // do something custom when ESC is pressed 544 32: null // don't do anything when SPACE is pressed (i.e. disable a reveal.js default binding) 545 } 546 }); 547 ``` 548 549 ### Vertical Slide Navigation 550 551 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: 552 553 <img src="https://static.slid.es/support/reveal.js-vertical-slides.gif" width="450"> 554 555 #### Navigation Mode 556 You can fine tune the reveal.js navigation behavior by using the `navigationMode` config option. Note that these options are only useful for presentations that use a mix of horizontal and vertical slides. The following navigation modes are available: 557 558 | Value | Description | 559 | :--------------------------- | :---------- | 560 | 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). | 561 | linear | Removes the up/down arrows. Left/right arrows step through all slides (both horizontal and vertical). | 562 | 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. | 563 564 ### Touch Navigation 565 566 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. 567 568 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. 569 570 ### Lazy Loading 571 572 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. 573 574 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. 575 576 ```html 577 <section> 578 <img data-src="image.png"> 579 <iframe data-src="http://hakim.se"></iframe> 580 <video> 581 <source data-src="video.webm" type="video/webm" /> 582 <source data-src="video.mp4" type="video/mp4" /> 583 </video> 584 </section> 585 ``` 586 587 #### Lazy Loading Iframes 588 589 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. 590 591 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. 592 593 You can override this behavior with the `data-preload` attribute. The iframe below will be loaded 594 according to the `viewDistance`. 595 596 ```html 597 <section> 598 <iframe data-src="http://hakim.se" data-preload></iframe> 599 </section> 600 ``` 601 602 You can also change the default globally with the `preloadIframes` configuration option. If set to 603 `true` ALL iframes with a `data-src` attribute will be preloaded when within the `viewDistance` 604 regardless of individual `data-preload` attributes. If set to `false`, all iframes will only be 605 loaded when they become visible. 606 607 ### API 608 609 The `Reveal` object exposes a JavaScript API for controlling navigation and reading state: 610 611 ```javascript 612 // Navigation 613 Reveal.slide( indexh, indexv, indexf ); 614 Reveal.left(); 615 Reveal.right(); 616 Reveal.up(); 617 Reveal.down(); 618 Reveal.prev(); 619 Reveal.next(); 620 Reveal.prevFragment(); 621 Reveal.nextFragment(); 622 623 // Randomize the order of slides 624 Reveal.shuffle(); 625 626 // Toggle presentation states, optionally pass true/false to force on/off 627 Reveal.toggleOverview(); 628 Reveal.togglePause(); 629 Reveal.toggleAutoSlide(); 630 631 // Shows a help overlay with keyboard shortcuts, optionally pass true/false 632 // to force on/off 633 Reveal.toggleHelp(); 634 635 // Change a config value at runtime 636 Reveal.configure({ controls: true }); 637 638 // Returns the present configuration options 639 Reveal.getConfig(); 640 641 // Fetch the current scale of the presentation 642 Reveal.getScale(); 643 644 // Retrieves the previous and current slide elements 645 Reveal.getPreviousSlide(); 646 Reveal.getCurrentSlide(); 647 648 Reveal.getIndices(); // { h: 0, v: 0, f: 0 } 649 Reveal.getSlidePastCount(); 650 Reveal.getProgress(); // (0 == first slide, 1 == last slide) 651 Reveal.getSlides(); // Array of all slides 652 Reveal.getTotalSlides(); // Total number of slides 653 654 // Returns an array with all horizontal/vertical slides in the deck 655 Reveal.getHorizontalSlides(); 656 Reveal.getVerticalSlides(); 657 658 // Checks if the presentation contains two or more 659 // horizontal/vertical slides 660 Reveal.hasHorizontalSlides(); 661 Reveal.hasVerticalSlides(); 662 663 // Returns the speaker notes for the current slide 664 Reveal.getSlideNotes(); 665 666 // State checks 667 Reveal.isFirstSlide(); 668 Reveal.isLastSlide(); 669 Reveal.isOverview(); 670 Reveal.isPaused(); 671 Reveal.isAutoSliding(); 672 673 // Returns the top-level DOM element 674 Reveal.getRevealElement(); // <div class="reveal">...</div> 675 ``` 676 677 ### Custom Key Bindings 678 679 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. 680 681 ```javascript 682 Reveal.addKeyBinding( binding, callback ); 683 Reveal.removeKeyBinding( keyCode ); 684 ``` 685 686 For example 687 688 ```javascript 689 // The binding parameter provides the following properties 690 // keyCode: the keycode for binding to the callback 691 // key: the key label to show in the help overlay 692 // description: the description of the action to show in the help overlay 693 Reveal.addKeyBinding( { keyCode: 84, key: 'T', description: 'Start timer' }, function() { 694 // start timer 695 } ) 696 697 // The binding parameter can also be a direct keycode without providing the help description 698 Reveal.addKeyBinding( 82, function() { 699 // reset timer 700 } ) 701 ``` 702 703 This allows plugins to add key bindings directly to Reveal so they can 704 705 * make use of Reveal's pre-processing logic for key handling (for example, ignoring key presses when paused); and 706 * be included in the help overlay (optional) 707 708 ### Slide Changed Event 709 710 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. 711 712 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. 713 714 ```javascript 715 Reveal.addEventListener( 'slidechanged', function( event ) { 716 // event.previousSlide, event.currentSlide, event.indexh, event.indexv 717 } ); 718 ``` 719 720 ### Presentation State 721 722 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. 723 724 ```javascript 725 Reveal.slide( 1 ); 726 // we're on slide 1 727 728 var state = Reveal.getState(); 729 730 Reveal.slide( 3 ); 731 // we're on slide 3 732 733 Reveal.setState( state ); 734 // we're back on slide 1 735 ``` 736 737 ### Slide States 738 739 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. 740 741 Furthermore you can also listen to these changes in state via JavaScript: 742 743 ```javascript 744 Reveal.addEventListener( 'somestate', function() { 745 // TODO: Sprinkle magic 746 }, false ); 747 ``` 748 749 ### Slide Backgrounds 750 751 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. 752 753 #### Color Backgrounds 754 755 All CSS color formats are supported, including hex values, keywords, `rgba()` or `hsl()`. 756 757 ```html 758 <section data-background-color="#ff0000"> 759 <h2>Color</h2> 760 </section> 761 ``` 762 763 #### Image Backgrounds 764 765 By default, background images are resized to cover the full page. Available options: 766 767 | Attribute | Default | Description | 768 | :------------------------------- | :--------- | :---------- | 769 | data-background-image | | URL of the image to show. GIFs restart when the slide opens. | 770 | data-background-size | cover | See [background-size](https://developer.mozilla.org/docs/Web/CSS/background-size) on MDN. | 771 | data-background-position | center | See [background-position](https://developer.mozilla.org/docs/Web/CSS/background-position) on MDN. | 772 | data-background-repeat | no-repeat | See [background-repeat](https://developer.mozilla.org/docs/Web/CSS/background-repeat) on MDN. | 773 | data-background-opacity | 1 | Opacity of the background image on a 0-1 scale. 0 is transparent and 1 is fully opaque. | 774 775 ```html 776 <section data-background-image="http://example.com/image.png"> 777 <h2>Image</h2> 778 </section> 779 <section data-background-image="http://example.com/image.png" data-background-size="100px" data-background-repeat="repeat"> 780 <h2>This background image will be sized to 100px and repeated</h2> 781 </section> 782 ``` 783 784 #### Video Backgrounds 785 786 Automatically plays a full size video behind the slide. 787 788 | Attribute | Default | Description | 789 | :--------------------------- | :------ | :---------- | 790 | data-background-video | | A single video source, or a comma separated list of video sources. | 791 | data-background-video-loop | false | Flags if the video should play repeatedly. | 792 | data-background-video-muted | false | Flags if the audio should be muted. | 793 | data-background-size | cover | Use `cover` for full screen and some cropping or `contain` for letterboxing. | 794 | data-background-opacity | 1 | Opacity of the background video on a 0-1 scale. 0 is transparent and 1 is fully opaque. | 795 796 ```html 797 <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> 798 <h2>Video</h2> 799 </section> 800 ``` 801 802 #### Iframe Backgrounds 803 804 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. 805 806 ```html 807 <section data-background-iframe="https://slides.com" data-background-interactive> 808 <h2>Iframe</h2> 809 </section> 810 ``` 811 812 Iframes are lazy-loaded when they become visible. If you'd like to preload iframes ahead of time, you can append a `data-preload` attribute to the slide `<section>`. You can also enable preloading globally for all iframes using the `preloadIframes` configuration option. 813 814 #### Background Transitions 815 816 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. 817 818 819 ### Parallax Background 820 821 If you want to use a parallax scrolling background, set the first two properties below when initializing reveal.js (the other two are optional). 822 823 ```javascript 824 Reveal.initialize({ 825 826 // Parallax background image 827 parallaxBackgroundImage: '', // e.g. "https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg" 828 829 // Parallax background size 830 parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" - currently only pixels are supported (don't use % or auto) 831 832 // Number of pixels to move the parallax background per slide 833 // - Calculated automatically unless specified 834 // - Set to 0 to disable movement along an axis 835 parallaxBackgroundHorizontal: 200, 836 parallaxBackgroundVertical: 50 837 838 }); 839 ``` 840 841 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). 842 843 ### Slide Transitions 844 845 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: 846 847 ```html 848 <section data-transition="zoom"> 849 <h2>This slide will override the presentation transition and zoom!</h2> 850 </section> 851 852 <section data-transition-speed="fast"> 853 <h2>Choose from three transition speeds: default, fast or slow!</h2> 854 </section> 855 ``` 856 857 You can also use different in and out transitions for the same slide: 858 859 ```html 860 <section data-transition="slide"> 861 The train goes on … 862 </section> 863 <section data-transition="slide"> 864 and on … 865 </section> 866 <section data-transition="slide-in fade-out"> 867 and stops. 868 </section> 869 <section data-transition="fade-in slide-out"> 870 (Passengers entering and leaving) 871 </section> 872 <section data-transition="slide"> 873 And it starts again. 874 </section> 875 ``` 876 You can choose from `none`, `fade`, `slide`, `convex`, `concave` and `zoom`. 877 ### Internal links 878 879 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">`): 880 881 ```html 882 <a href="#/2/2">Link</a> 883 <a href="#/some-slide">Link</a> 884 ``` 885 886 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. 887 888 ```html 889 <a href="#" class="navigate-left"> 890 <a href="#" class="navigate-right"> 891 <a href="#" class="navigate-up"> 892 <a href="#" class="navigate-down"> 893 <a href="#" class="navigate-prev"> <!-- Previous vertical or horizontal slide --> 894 <a href="#" class="navigate-next"> <!-- Next vertical or horizontal slide --> 895 ``` 896 897 ### Fragments 898 899 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 900 901 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: 902 903 ```html 904 <section> 905 <p class="fragment grow">grow</p> 906 <p class="fragment shrink">shrink</p> 907 <p class="fragment fade-out">fade-out</p> 908 <p class="fragment fade-up">fade-up (also down, left and right!)</p> 909 <p class="fragment fade-in-then-out">fades in, then out when we move to the next step</p> 910 <p class="fragment fade-in-then-semi-out">fades in, then obfuscate when we move to the next step</p> 911 <p class="fragment highlight-current-blue">blue only once</p> 912 <p class="fragment highlight-red">highlight-red</p> 913 <p class="fragment highlight-green">highlight-green</p> 914 <p class="fragment highlight-blue">highlight-blue</p> 915 </section> 916 ``` 917 918 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. 919 920 ```html 921 <section> 922 <span class="fragment fade-in"> 923 <span class="fragment fade-out">I'll fade in, then out</span> 924 </span> 925 </section> 926 ``` 927 928 The display order of fragments can be controlled using the `data-fragment-index` attribute. 929 930 ```html 931 <section> 932 <p class="fragment" data-fragment-index="3">Appears last</p> 933 <p class="fragment" data-fragment-index="1">Appears first</p> 934 <p class="fragment" data-fragment-index="2">Appears second</p> 935 </section> 936 ``` 937 938 ### Fragment events 939 940 When a slide fragment is either shown or hidden reveal.js will dispatch an event. 941 942 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. 943 944 ```javascript 945 Reveal.addEventListener( 'fragmentshown', function( event ) { 946 // event.fragment = the fragment DOM element 947 } ); 948 Reveal.addEventListener( 'fragmenthidden', function( event ) { 949 // event.fragment = the fragment DOM element 950 } ); 951 ``` 952 953 ### Code Syntax Highlighting 954 955 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)). 956 957 ```javascript 958 Reveal.initialize({ 959 // More info https://github.com/hakimel/reveal.js#dependencies 960 dependencies: [ 961 { src: 'plugin/highlight/highlight.js', async: true }, 962 ] 963 }); 964 ``` 965 966 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. 967 968 ```html 969 <section> 970 <pre><code data-trim data-noescape> 971 (def lazy-fib 972 (concat 973 [0 1] 974 <mark>((fn rfib [a b]</mark> 975 (lazy-cons (+ a b) (rfib b (+ a b)))) 0 1))) 976 </code></pre> 977 </section> 978 ``` 979 980 #### Line Numbers & Highlights 981 982 To enable line numbers, add `data-line-numbers` to your `<code>` tags. If you want to highlight specific lines you can provide a comma separated list of line numbers using the same attribute. For example, in the following example lines 4 and 8-11 are highlighted: 983 984 ```html 985 <pre><code class="hljs" data-line-numbers="4,8-11"> 986 import React, { useState } from 'react'; 987 988 function Example() { 989 const [count, setCount] = useState(0); 990 991 return ( 992 <div> 993 <p>You clicked {count} times</p> 994 <button onClick={() => setCount(count + 1)}> 995 Click me 996 </button> 997 </div> 998 ); 999 } 1000 </code></pre> 1001 ``` 1002 1003 <img width="300" alt="line-numbers" src="https://user-images.githubusercontent.com/629429/55332077-eb3c4780-5494-11e9-8854-ba33cd0fa740.png"> 1004 1005 #### Step-by-step Highlights 1006 1007 You can step through multiple code highlights on the same code block. Delimit each of your highlight steps with the `|` character. For example `data-line-numbers="1|2-3|4,6-10"` will produce three steps. It will start by highlighting line 1, next step is lines 2-3, and finally line 4 and 6 through 10. 1008 1009 1010 1011 ### Slide number 1012 1013 If you would like to display the page number of the current slide you can do so using the `slideNumber` and `showSlideNumber` configuration values. 1014 1015 ```javascript 1016 // Shows the slide number using default formatting 1017 Reveal.configure({ slideNumber: true }); 1018 1019 // Slide number formatting can be configured using these variables: 1020 // "h.v": horizontal . vertical slide number (default) 1021 // "h/v": horizontal / vertical slide number 1022 // "c": flattened slide number 1023 // "c/t": flattened slide number / total slides 1024 Reveal.configure({ slideNumber: 'c/t' }); 1025 1026 // You can provide a function to fully customize the number: 1027 Reveal.configure({ slideNumber: function( slide ) { 1028 // Ignore numbering of vertical slides 1029 return [ Reveal.getIndices( slide ).h ]; 1030 }}); 1031 1032 // Control which views the slide number displays on using the "showSlideNumber" value: 1033 // "all": show on all views (default) 1034 // "speaker": only show slide numbers on speaker notes view 1035 // "print": only show slide numbers when printing to PDF 1036 Reveal.configure({ showSlideNumber: 'speaker' }); 1037 ``` 1038 1039 ### Overview mode 1040 1041 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, 1042 as if you were at 1,000 feet above your presentation. The overview mode comes with a few API hooks: 1043 1044 ```javascript 1045 Reveal.addEventListener( 'overviewshown', function( event ) { /* ... */ } ); 1046 Reveal.addEventListener( 'overviewhidden', function( event ) { /* ... */ } ); 1047 1048 // Toggle the overview mode programmatically 1049 Reveal.toggleOverview(); 1050 ``` 1051 1052 ### Fullscreen mode 1053 1054 Just press »F« on your keyboard to show your presentation in fullscreen mode. Press the »ESC« key to exit fullscreen mode. 1055 1056 ### Embedded media 1057 1058 Add `data-autoplay` to your media element if you want it to automatically start playing when the slide is shown: 1059 1060 ```html 1061 <video data-autoplay src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"></video> 1062 ``` 1063 1064 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. 1065 1066 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. 1067 1068 ### Embedded iframes 1069 1070 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. 1071 1072 ### Stretching elements 1073 1074 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: 1075 1076 ```html 1077 <section> 1078 <h2>This video will use up the remaining space on the slide</h2> 1079 <video class="stretch" src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"></video> 1080 </section> 1081 ``` 1082 1083 Limitations: 1084 - Only direct descendants of a slide section can be stretched 1085 - Only one descendant per slide section can be stretched 1086 1087 ### Resize Event 1088 1089 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. 1090 1091 ```javascript 1092 Reveal.addEventListener( 'resize', function( event ) { 1093 // event.scale, event.oldScale, event.size 1094 } ); 1095 ``` 1096 1097 ### postMessage API 1098 1099 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: 1100 1101 ```javascript 1102 <window>.postMessage( JSON.stringify({ method: 'slide', args: [ 2 ] }), '*' ); 1103 ``` 1104 1105 #### postMessage Events 1106 1107 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: 1108 1109 ```javascript 1110 window.addEventListener( 'message', function( event ) { 1111 var data = JSON.parse( event.data ); 1112 if( data.namespace === 'reveal' && data.eventName === 'slidechanged' ) { 1113 // Slide changed, see data.state for slide number 1114 } 1115 } ); 1116 ``` 1117 1118 #### postMessage Callbacks 1119 1120 When you call any method via the postMessage API, reveal.js will dispatch a message with the return value. This is done so that you can call a getter method and see what the result is. Check out this example: 1121 1122 ```javascript 1123 <revealWindow>.postMessage( JSON.stringify({ method: 'getTotalSlides' }), '*' ); 1124 1125 window.addEventListener( 'message', function( event ) { 1126 var data = JSON.parse( event.data ); 1127 // `data.method`` is the method that we invoked 1128 if( data.namespace === 'reveal' && data.eventName === 'callback' && data.method === 'getTotalSlides' ) { 1129 data.result // = the total number of slides 1130 } 1131 } ); 1132 ``` 1133 1134 #### Turning postMessage on/off 1135 1136 This cross-window messaging can be toggled on or off using configuration flags. These are the default values. 1137 1138 ```javascript 1139 Reveal.initialize({ 1140 // ... 1141 1142 // Exposes the reveal.js API through window.postMessage 1143 postMessage: true, 1144 1145 // Dispatches all reveal.js events to the parent window through postMessage 1146 postMessageEvents: false 1147 }); 1148 ``` 1149 1150 1151 ## PDF Export 1152 1153 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. 1154 Here's an example of an exported presentation that's been uploaded to SlideShare: http://www.slideshare.net/hakimel/revealjs-300. 1155 1156 ### Separate pages for fragments 1157 [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. 1158 1159 If you prefer printing all fragments in their visible states on the same slide you can set the `pdfSeparateFragments` config option to false. 1160 1161 ### Page size 1162 1163 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. 1164 1165 ### Print stylesheet 1166 1167 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: 1168 1169 ```html 1170 <script> 1171 var link = document.createElement( 'link' ); 1172 link.rel = 'stylesheet'; 1173 link.type = 'text/css'; 1174 link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css'; 1175 document.getElementsByTagName( 'head' )[0].appendChild( link ); 1176 </script> 1177 ``` 1178 1179 ### Instructions 1180 1181 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). 1182 * 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 1183 1. Open the in-browser print dialog (CTRL/CMD+P). 1184 1. Change the **Destination** setting to **Save as PDF**. 1185 1. Change the **Layout** to **Landscape**. 1186 1. Change the **Margins** to **None**. 1187 1. Enable the **Background graphics** option. 1188 1. Click **Save**. 1189 1190  1191 1192 Alternatively you can use the [decktape](https://github.com/astefanutti/decktape) project. 1193 1194 1195 ## Theming 1196 1197 The framework comes with a few different themes included: 1198 1199 - black: Black background, white text, blue links (default theme) 1200 - white: White background, black text, blue links 1201 - league: Gray background, white text, blue links (default theme for reveal.js < 3.0.0) 1202 - beige: Beige background, dark text, brown links 1203 - sky: Blue background, thin dark text, blue links 1204 - night: Black background, thick white text, orange links 1205 - serif: Cappuccino background, gray text, brown links 1206 - simple: White background, black text, blue links 1207 - solarized: Cream-colored background, dark green text, blue links 1208 1209 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: 1210 1211 ```html 1212 <link rel="stylesheet" href="css/theme/black.css" id="theme"> 1213 ``` 1214 1215 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). 1216 1217 1218 ## Speaker Notes 1219 1220 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. 1221 1222 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. 1223 1224 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. 1225 1226 Alternatively you can add your notes in a `data-notes` attribute on the slide. Like `<section data-notes="Something important"></section>`. 1227 1228 When used locally, this feature requires that reveal.js [runs from a local web server](#full-setup). 1229 1230 ```html 1231 <section> 1232 <h2>Some Slide</h2> 1233 1234 <aside class="notes"> 1235 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). 1236 </aside> 1237 </section> 1238 ``` 1239 1240 If you're using the external Markdown plugin, you can add notes with the help of a special delimiter: 1241 1242 ```html 1243 <section data-markdown="example.md" data-separator="^\n\n\n" data-separator-vertical="^\n\n" data-separator-notes="^Note:"></section> 1244 1245 # Title 1246 ## Sub-title 1247 1248 Here is some content... 1249 1250 Note: 1251 This will only display in the notes window. 1252 ``` 1253 1254 #### Share and Print Speaker Notes 1255 1256 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. 1257 1258 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"`. 1259 1260 #### Speaker notes clock and timers 1261 1262 The speaker notes window will also show: 1263 1264 - Time elapsed since the beginning of the presentation. If you hover the mouse above this section, a timer reset button will appear. 1265 - Current wall-clock time 1266 - (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). 1267 1268 The pacing timer can be enabled by configuring the `defaultTiming` parameter in the `Reveal` configuration block, which specifies the number of seconds per slide. 120 can be a reasonable rule of thumb. Alternatively, you can enable the timer by setting `totalTime`, which sets the total length of your presentation (also in seconds). If both values are specified, `totalTime` wins and `defaultTiming` is ignored. Regardless of the baseline timing method, timings can also be given per slide `<section>` by setting the `data-timing` attribute (again, in seconds). 1269 1270 1271 ## Server Side Speaker Notes 1272 1273 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: 1274 1275 ```javascript 1276 Reveal.initialize({ 1277 // ... 1278 1279 dependencies: [ 1280 { src: 'socket.io/socket.io.js', async: true }, 1281 { src: 'plugin/notes-server/client.js', async: true } 1282 ] 1283 }); 1284 ``` 1285 1286 Then: 1287 1288 1. Install [Node.js](http://nodejs.org/) (9.0.0 or later) 1289 2. Run `npm install` 1290 3. Run `node plugin/notes-server` 1291 1292 1293 ## Plugins 1294 1295 Plugins should register themselves with reveal.js by calling `Reveal.registerPlugin( 'myPluginID', MyPlugin )`. Registered plugin instances can optionally expose an "init" function that reveal.js will call to initialize them. 1296 1297 When reveal.js is booted up via `Reveal.initialize()`, it will go through all registered plugins and invoke their "init" methods. If the "init" method returns a Promise, reveal.js will wait for that promise to be fulfilled before finishing the startup sequence and firing the [ready](#ready-event) event. Here's an example of a plugin that does some asynchronous work before reveal.js can proceed: 1298 1299 ```javascript 1300 let MyPlugin = { 1301 init: () => new Promise( resolve => setTimeout( resolve, 3000 ) ) 1302 }; 1303 Reveal.registerPlugin( 'myPlugin', MyPlugin ); 1304 Reveal.addEventListener( 'ready', () => console.log( 'Three seconds later...' ) ); 1305 Reveal.initialize(); 1306 ``` 1307 1308 Note that reveal.js will *not* wait for init Promise fulfillment if the plugin is loaded as an [async dependency](#dependencies). If the plugin's init method does _not_ return a Promise, the plugin is considered ready right away and will not hold up the reveal.js startup sequence. 1309 1310 ### Retrieving Plugins 1311 1312 If you want to check if a specific plugin is registered you can use the `Reveal.hasPlugin` method and pass in a plugin ID, for example: `Reveal.hasPlugin( 'myPlugin' )`. If you want to retrieve a plugin instance you can use `Reveal.getPlugin( 'myPlugin' )`. 1313 1314 1315 ## Multiplexing 1316 1317 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/). 1318 1319 The multiplex plugin needs the following 3 things to operate: 1320 1321 1. Master presentation that has control 1322 2. Client presentations that follow the master 1323 3. Socket.io server to broadcast events from the master to the clients 1324 1325 #### Master presentation 1326 1327 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: 1328 1329 1. `npm install node-static` 1330 2. `static` 1331 1332 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. 1333 1334 You can then access your master presentation at `http://localhost:1947` 1335 1336 Example configuration: 1337 1338 ```javascript 1339 Reveal.initialize({ 1340 // other options... 1341 1342 multiplex: { 1343 // Example values. To generate your own, see the socket.io server instructions. 1344 secret: '13652805320794272084', // Obtained from the socket.io server. Gives this (the master) control of the presentation 1345 id: '1ea875674b17ca76', // Obtained from socket.io server 1346 url: 'https://reveal-js-multiplex-ccjbegmaii.now.sh' // Location of socket.io server 1347 }, 1348 1349 // Don't forget to add the dependencies 1350 dependencies: [ 1351 { src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js', async: true }, 1352 { src: 'plugin/multiplex/master.js', async: true }, 1353 1354 // and if you want speaker notes 1355 { src: 'plugin/notes-server/client.js', async: true } 1356 1357 // other dependencies... 1358 ] 1359 }); 1360 ``` 1361 1362 #### Client presentation 1363 1364 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 `https://example.com/path/to/presentation/client/index.html`, with the configuration below causing them to connect to the socket.io server as clients. 1365 1366 Example configuration: 1367 1368 ```javascript 1369 Reveal.initialize({ 1370 // other options... 1371 1372 multiplex: { 1373 // Example values. To generate your own, see the socket.io server instructions. 1374 secret: null, // null so the clients do not have control of the master presentation 1375 id: '1ea875674b17ca76', // id, obtained from socket.io server 1376 url: 'https://reveal-js-multiplex-ccjbegmaii.now.sh' // Location of socket.io server 1377 }, 1378 1379 // Don't forget to add the dependencies 1380 dependencies: [ 1381 { src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js', async: true }, 1382 { src: 'plugin/multiplex/client.js', async: true } 1383 1384 // other dependencies... 1385 ] 1386 }); 1387 ``` 1388 1389 #### Socket.io server 1390 1391 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: 1392 1393 1. `npm install` 1394 2. `node plugin/multiplex` 1395 1396 Or you can use the socket.io server at [https://reveal-js-multiplex-ccjbegmaii.now.sh/](https://reveal-js-multiplex-ccjbegmaii.now.sh/). 1397 1398 You'll need to generate a unique secret and token pair for your master and client presentations. To do so, visit `https://example.com/token`, where `https://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). 1399 1400 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. 1401 1402 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`. 1403 1404 ##### socket.io server as file static server 1405 1406 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.) 1407 1408 Example configuration: 1409 1410 ```javascript 1411 Reveal.initialize({ 1412 // other options... 1413 1414 multiplex: { 1415 // Example values. To generate your own, see the socket.io server instructions. 1416 secret: null, // null so the clients do not have control of the master presentation 1417 id: '1ea875674b17ca76', // id, obtained from socket.io server 1418 url: 'example.com:80' // Location of your socket.io server 1419 }, 1420 1421 // Don't forget to add the dependencies 1422 dependencies: [ 1423 { src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js', async: true }, 1424 { src: 'plugin/multiplex/client.js', async: true } 1425 1426 // other dependencies... 1427 ] 1428 ``` 1429 1430 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. ;) 1431 1432 Example configuration: 1433 1434 ```javascript 1435 Reveal.initialize({ 1436 // other options... 1437 1438 multiplex: { 1439 // Example values. To generate your own, see the socket.io server instructions. 1440 secret: '13652805320794272084', // Obtained from the socket.io server. Gives this (the master) control of the presentation 1441 id: '1ea875674b17ca76', // Obtained from socket.io server 1442 url: 'example.com:80' // Location of your socket.io server 1443 }, 1444 1445 // Don't forget to add the dependencies 1446 dependencies: [ 1447 { src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js', async: true }, 1448 { src: 'plugin/multiplex/master.js', async: true }, 1449 { src: 'plugin/multiplex/client.js', async: true } 1450 1451 // other dependencies... 1452 ] 1453 }); 1454 ``` 1455 1456 1457 ## MathJax 1458 1459 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). 1460 1461 The plugin defaults to using [LaTeX](https://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. 1462 1463 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. 1464 1465 ```js 1466 Reveal.initialize({ 1467 // other options ... 1468 1469 math: { 1470 mathjax: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js', 1471 config: 'TeX-AMS_HTML-full', // See http://docs.mathjax.org/en/latest/config-files.html 1472 // pass other options into `MathJax.Hub.Config()` 1473 TeX: { Macros: { RR: "{\\bf R}" } } 1474 }, 1475 1476 dependencies: [ 1477 { src: 'plugin/math/math.js', async: true } 1478 ] 1479 }); 1480 ``` 1481 1482 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. 1483 1484 #### MathJax in Markdown 1485 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: 1486 1487 ``` 1488 `$$ J(\theta_0,\theta_1) = \sum_{i=0} $$` 1489 ``` 1490 1491 ## License 1492 1493 MIT licensed 1494 1495 Copyright (C) 2020 Hakim El Hattab, http://hakim.se