reveal.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. /*!
  2. * reveal.js 1.3
  3. * http://lab.hakim.se/reveal-js
  4. * MIT licensed
  5. *
  6. * Copyright (C) 2012 Hakim El Hattab, http://hakim.se
  7. */
  8. var Reveal = (function(){
  9. var HORIZONTAL_SLIDES_SELECTOR = '#reveal .slides>section',
  10. VERTICAL_SLIDES_SELECTOR = '#reveal .slides>section.present>section',
  11. // The horizontal and verical index of the currently active slide
  12. indexh = 0,
  13. indexv = 0,
  14. // Configurations options, can be overridden at initialization time
  15. config = {
  16. controls: false,
  17. progress: false,
  18. history: false,
  19. loop: false,
  20. mouseWheel: true,
  21. rollingLinks: true,
  22. transition: 'default',
  23. theme: 'default'
  24. },
  25. // Slides may hold a data-state attribute which we pick up and apply
  26. // as a class to the body. This list contains the combined state of
  27. // all current slides.
  28. state = [],
  29. // Cached references to DOM elements
  30. dom = {},
  31. // Detect support for CSS 3D transforms
  32. supports3DTransforms = document.body.style['perspectiveProperty'] !== undefined ||
  33. document.body.style['WebkitPerspective'] !== undefined ||
  34. document.body.style['MozPerspective'] !== undefined ||
  35. document.body.style['msPerspective'] !== undefined ||
  36. document.body.style['OPerspective'] !== undefined,
  37. supports2DTransforms = document.body.style['transformProperty'] !== undefined ||
  38. document.body.style['WebkitTransform'] !== undefined ||
  39. document.body.style['MozTransform'] !== undefined ||
  40. document.body.style['msTransform'] !== undefined ||
  41. document.body.style['OTransform'] !== undefined,
  42. // Throttles mouse wheel navigation
  43. mouseWheelTimeout = 0,
  44. // Delays updates to the URL due to a Chrome thumbnailer bug
  45. writeURLTimeout = 0;
  46. /**
  47. * Starts up the slideshow by applying configuration
  48. * options and binding various events.
  49. */
  50. function initialize( options ) {
  51. if( !supports2DTransforms && !supports3DTransforms ) {
  52. document.body.setAttribute( 'class', 'no-transforms' );
  53. // If the browser doesn't support transforms we won't be
  54. // using JavaScript to control the presentation
  55. return;
  56. }
  57. // Cache references to DOM elements
  58. dom.wrapper = document.querySelector( '#reveal' );
  59. dom.progress = document.querySelector( '#reveal .progress' );
  60. dom.progressbar = document.querySelector( '#reveal .progress span' );
  61. dom.controls = document.querySelector( '#reveal .controls' );
  62. dom.controlsLeft = document.querySelector( '#reveal .controls .left' );
  63. dom.controlsRight = document.querySelector( '#reveal .controls .right' );
  64. dom.controlsUp = document.querySelector( '#reveal .controls .up' );
  65. dom.controlsDown = document.querySelector( '#reveal .controls .down' );
  66. // Bind all view events
  67. document.addEventListener('keydown', onDocumentKeyDown, false);
  68. document.addEventListener('touchstart', onDocumentTouchStart, false);
  69. window.addEventListener('hashchange', onWindowHashChange, false);
  70. dom.controlsLeft.addEventListener('click', preventAndForward( navigateLeft ), false);
  71. dom.controlsRight.addEventListener('click', preventAndForward( navigateRight ), false);
  72. dom.controlsUp.addEventListener('click', preventAndForward( navigateUp ), false);
  73. dom.controlsDown.addEventListener('click', preventAndForward( navigateDown ), false);
  74. // Copy options over to our config object
  75. extend( config, options );
  76. // Fall back on the 2D transform theme 'linear'
  77. if( supports3DTransforms === false ) {
  78. config.transition = 'linear';
  79. }
  80. if( config.controls ) {
  81. dom.controls.style.display = 'block';
  82. }
  83. if( config.progress ) {
  84. dom.progress.style.display = 'block';
  85. }
  86. if( config.transition !== 'default' ) {
  87. dom.wrapper.classList.add( config.transition );
  88. }
  89. if( config.theme !== 'default' ) {
  90. dom.wrapper.classList.add( config.theme );
  91. }
  92. if( config.mouseWheel ) {
  93. document.addEventListener('DOMMouseScroll', onDocumentMouseScroll, false); // FF
  94. document.addEventListener('mousewheel', onDocumentMouseScroll, false);
  95. }
  96. if( config.rollingLinks ) {
  97. // Add some 3D magic to our anchors
  98. linkify();
  99. }
  100. // Read the initial hash
  101. readURL();
  102. }
  103. /**
  104. * Extend object a with the properties of object b.
  105. * If there's a conflict, object b takes precedence.
  106. */
  107. function extend( a, b ) {
  108. for( var i in b ) {
  109. a[ i ] = b[ i ];
  110. }
  111. }
  112. /**
  113. * Prevents an events defaults behavior calls the
  114. * specified delegate.
  115. *
  116. * @param {Function} delegate The method to call
  117. * after the wrapper has been executed
  118. */
  119. function preventAndForward( delegate ) {
  120. return function( event ) {
  121. event.preventDefault();
  122. delegate.call();
  123. }
  124. }
  125. /**
  126. * Handler for the document level 'keydown' event.
  127. *
  128. * @param {Object} event
  129. */
  130. function onDocumentKeyDown( event ) {
  131. // FFT: Use document.querySelector( ':focus' ) === null
  132. // instead of checking contentEditable?
  133. // Disregard the event if the target is editable or a
  134. // modifier is present
  135. if ( event.target.contentEditable != 'inherit' || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return;
  136. var triggered = false;
  137. switch( event.keyCode ) {
  138. // p, page up
  139. case 80: case 33: navigatePrev(); triggered = true; break;
  140. // n, page down, space
  141. case 78: case 32: case 34: navigateNext(); triggered = true; break;
  142. // h, left
  143. case 72: case 37: navigateLeft(); triggered = true; break;
  144. // l, right
  145. case 76: case 39: navigateRight(); triggered = true; break;
  146. // k, up
  147. case 75: case 38: navigateUp(); triggered = true; break;
  148. // j, down
  149. case 74: case 40: navigateDown(); triggered = true; break;
  150. }
  151. if( triggered ) {
  152. event.preventDefault();
  153. }
  154. else if ( event.keyCode === 27 && supports3DTransforms ) {
  155. if( overviewIsActive() ) {
  156. deactivateOverview();
  157. }
  158. else {
  159. activateOverview();
  160. }
  161. event.preventDefault();
  162. }
  163. }
  164. /**
  165. * Handler for the document level 'touchstart' event.
  166. *
  167. * This enables very basic tap interaction for touch
  168. * devices. Added mainly for performance testing of 3D
  169. * transforms on iOS but was so happily surprised with
  170. * how smoothly it runs so I left it in here. Apple +1
  171. *
  172. * @param {Object} event
  173. */
  174. function onDocumentTouchStart( event ) {
  175. // We're only interested in one point taps
  176. if (event.touches.length === 1) {
  177. // Never prevent taps on anchors and images
  178. if( event.target.tagName.toLowerCase() === 'a' || event.target.tagName.toLowerCase() === 'img' ) {
  179. return;
  180. }
  181. event.preventDefault();
  182. var point = {
  183. x: event.touches[0].clientX,
  184. y: event.touches[0].clientY
  185. };
  186. // Define the extent of the areas that may be tapped
  187. // to navigate
  188. var wt = window.innerWidth * 0.3;
  189. var ht = window.innerHeight * 0.3;
  190. if( point.x < wt ) {
  191. navigateLeft();
  192. }
  193. else if( point.x > window.innerWidth - wt ) {
  194. navigateRight();
  195. }
  196. else if( point.y < ht ) {
  197. navigateUp();
  198. }
  199. else if( point.y > window.innerHeight - ht ) {
  200. navigateDown();
  201. }
  202. slide();
  203. }
  204. }
  205. /**
  206. * Handles mouse wheel scrolling, throttled to avoid
  207. * skipping multiple slides.
  208. */
  209. function onDocumentMouseScroll( event ){
  210. clearTimeout( mouseWheelTimeout );
  211. mouseWheelTimeout = setTimeout( function() {
  212. var delta = event.detail || -event.wheelDelta;
  213. if( delta > 0 ) {
  214. navigateNext();
  215. }
  216. else {
  217. navigatePrev();
  218. }
  219. }, 100 );
  220. }
  221. /**
  222. * Handler for the window level 'hashchange' event.
  223. *
  224. * @param {Object} event
  225. */
  226. function onWindowHashChange( event ) {
  227. readURL();
  228. }
  229. /**
  230. * Wrap all links in 3D goodness.
  231. */
  232. function linkify() {
  233. if( supports3DTransforms ) {
  234. var nodes = document.querySelectorAll( '#reveal .slides section a:not(.image)' );
  235. for( var i = 0, len = nodes.length; i < len; i++ ) {
  236. var node = nodes[i];
  237. if( node.textContent && !node.querySelector( 'img' ) && ( !node.className || !node.classList.contains( node, 'roll' ) ) ) {
  238. node.classList.add( 'roll' );
  239. node.innerHTML = '<span data-title="'+ node.text +'">' + node.innerHTML + '</span>';
  240. }
  241. };
  242. }
  243. }
  244. /**
  245. * Displays the overview of slides (quick nav) by
  246. * scaling down and arranging all slide elements.
  247. *
  248. * Experimental feature, might be dropped if perf
  249. * can't be improved.
  250. */
  251. function activateOverview() {
  252. dom.wrapper.classList.add( 'overview' );
  253. var horizontalSlides = Array.prototype.slice.call( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
  254. for( var i = 0, len1 = horizontalSlides.length; i < len1; i++ ) {
  255. var hslide = horizontalSlides[i],
  256. htransform = 'translateZ(-2500px) translate(' + ( ( i - indexh ) * 105 ) + '%, 0%)';
  257. hslide.setAttribute( 'data-index-h', i );
  258. hslide.style.display = 'block';
  259. hslide.style.WebkitTransform = htransform;
  260. hslide.style.MozTransform = htransform;
  261. hslide.style.msTransform = htransform;
  262. hslide.style.OTransform = htransform;
  263. hslide.style.transform = htransform;
  264. if( !hslide.classList.contains( 'stack' ) ) {
  265. // Navigate to this slide on click
  266. hslide.addEventListener( 'click', onOverviewSlideClicked, true );
  267. }
  268. var verticalSlides = Array.prototype.slice.call( hslide.querySelectorAll( 'section' ) );
  269. for( var j = 0, len2 = verticalSlides.length; j < len2; j++ ) {
  270. var vslide = verticalSlides[j],
  271. vtransform = 'translate(0%, ' + ( ( j - indexv ) * 105 ) + '%)';
  272. vslide.setAttribute( 'data-index-h', i );
  273. vslide.setAttribute( 'data-index-v', j );
  274. vslide.style.display = 'block';
  275. vslide.style.WebkitTransform = vtransform;
  276. vslide.style.MozTransform = vtransform;
  277. vslide.style.msTransform = vtransform;
  278. vslide.style.OTransform = vtransform;
  279. vslide.style.transform = vtransform;
  280. // Navigate to this slide on click
  281. vslide.addEventListener( 'click', onOverviewSlideClicked, true );
  282. }
  283. }
  284. }
  285. /**
  286. * Exits the slide overview and enters the currently
  287. * active slide.
  288. */
  289. function deactivateOverview() {
  290. dom.wrapper.classList.remove( 'overview' );
  291. var slides = Array.prototype.slice.call( document.querySelectorAll( '#reveal .slides section' ) );
  292. for( var i = 0, len = slides.length; i < len; i++ ) {
  293. var element = slides[i];
  294. // Resets all transforms to use the external styles
  295. element.style.WebkitTransform = '';
  296. element.style.MozTransform = '';
  297. element.style.msTransform = '';
  298. element.style.OTransform = '';
  299. element.style.transform = '';
  300. element.removeEventListener( 'click', onOverviewSlideClicked );
  301. }
  302. slide();
  303. }
  304. /**
  305. * Checks if the overview is currently active.
  306. *
  307. * @return {Boolean} true if the overview is active,
  308. * false otherwise
  309. */
  310. function overviewIsActive() {
  311. return dom.wrapper.classList.contains( 'overview' );
  312. }
  313. /**
  314. * Invoked when a slide is and we're in the overview.
  315. */
  316. function onOverviewSlideClicked( event ) {
  317. // TODO There's a bug here where the event listeners are not
  318. // removed after deactivating the overview.
  319. if( overviewIsActive() ) {
  320. event.preventDefault();
  321. deactivateOverview();
  322. indexh = this.getAttribute( 'data-index-h' );
  323. indexv = this.getAttribute( 'data-index-v' );
  324. slide();
  325. }
  326. }
  327. /**
  328. * Updates one dimension of slides by showing the slide
  329. * with the specified index.
  330. *
  331. * @param {String} selector A CSS selector that will fetch
  332. * the group of slides we are working with
  333. * @param {Number} index The index of the slide that should be
  334. * shown
  335. *
  336. * @return {Number} The index of the slide that is now shown,
  337. * might differ from the passed in index if it was out of
  338. * bounds.
  339. */
  340. function updateSlides( selector, index ) {
  341. // Select all slides and convert the NodeList result to
  342. // an array
  343. var slides = Array.prototype.slice.call( document.querySelectorAll( selector ) ),
  344. slidesLength = slides.length;
  345. if( slidesLength ) {
  346. // Should the index loop?
  347. if( config.loop ) {
  348. index %= slidesLength;
  349. if( index < 0 ) {
  350. index = slidesLength + index;
  351. }
  352. }
  353. // Enforce max and minimum index bounds
  354. index = Math.max( Math.min( index, slidesLength - 1 ), 0 );
  355. for( var i = 0; i < slidesLength; i++ ) {
  356. var slide = slides[i];
  357. // Optimization; hide all slides that are three or more steps
  358. // away from the present slide
  359. if( overviewIsActive() === false ) {
  360. // The distance loops so that it measures 1 between the first
  361. // and last slides
  362. var distance = Math.abs( ( index - i ) % ( slidesLength - 3 ) ) || 0;
  363. slide.style.display = distance > 3 ? 'none' : 'block';
  364. }
  365. slides[i].classList.remove( 'past' );
  366. slides[i].classList.remove( 'present' );
  367. slides[i].classList.remove( 'future' );
  368. if( i < index ) {
  369. // Any element previous to index is given the 'past' class
  370. slides[i].classList.add( 'past' );
  371. }
  372. else if( i > index ) {
  373. // Any element subsequent to index is given the 'future' class
  374. slides[i].classList.add( 'future' );
  375. }
  376. // If this element contains vertical slides
  377. if( slide.querySelector( 'section' ) ) {
  378. slides[i].classList.add( 'stack' );
  379. }
  380. }
  381. // Mark the current slide as present
  382. slides[index].classList.add( 'present' );
  383. // If this slide has a state associated with it, add it
  384. // onto the current state of the deck
  385. var slideState = slides[index].dataset.state;
  386. if( slideState ) {
  387. state = state.concat( slideState.split( ' ' ) );
  388. }
  389. }
  390. else {
  391. // Since there are no slides we can't be anywhere beyond the
  392. // zeroth index
  393. index = 0;
  394. }
  395. return index;
  396. }
  397. /**
  398. * Updates the visual slides to represent the currently
  399. * set indices.
  400. */
  401. function slide() {
  402. // Remember the state before this slide
  403. var stateBefore = state.concat();
  404. // Reset the state array
  405. state.length = 0;
  406. // Activate and transition to the new slide
  407. indexh = updateSlides( HORIZONTAL_SLIDES_SELECTOR, indexh );
  408. indexv = updateSlides( VERTICAL_SLIDES_SELECTOR, indexv );
  409. // Apply the new state
  410. stateLoop: for( var i = 0, len = state.length; i < len; i++ ) {
  411. // Check if this state existed on the previous slide. If it
  412. // did, we will avoid adding it repeatedly.
  413. for( var j = 0; j < stateBefore.length; j++ ) {
  414. if( stateBefore[j] === state[i] ) {
  415. stateBefore.splice( j, 1 );
  416. continue stateLoop;
  417. }
  418. }
  419. document.documentElement.classList.add( state[i] );
  420. // Dispatch custom event
  421. var event = document.createEvent( "HTMLEvents" );
  422. event.initEvent( state[i], true, true );
  423. document.dispatchEvent( event );
  424. }
  425. // Clean up the remaints of the previous state
  426. while( stateBefore.length ) {
  427. document.documentElement.classList.remove( stateBefore.pop() );
  428. }
  429. // Update progress if enabled
  430. if( config.progress ) {
  431. dom.progressbar.style.width = ( indexh / ( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ).length - 1 ) ) * window.innerWidth + 'px';
  432. }
  433. // Close the overview if it's active
  434. if( overviewIsActive() ) {
  435. activateOverview();
  436. }
  437. updateControls();
  438. clearTimeout( writeURLTimeout );
  439. writeURLTimeout = setTimeout( writeURL, 1500 );
  440. }
  441. /**
  442. * Updates the state and link pointers of the controls.
  443. */
  444. function updateControls() {
  445. var routes = availableRoutes();
  446. // Remove the 'enabled' class from all directions
  447. [ dom.controlsLeft, dom.controlsRight, dom.controlsUp, dom.controlsDown ].forEach( function( node ) {
  448. node.classList.remove( 'enabled' );
  449. } )
  450. if( routes.left ) dom.controlsLeft.classList.add( 'enabled' );
  451. if( routes.right ) dom.controlsRight.classList.add( 'enabled' );
  452. if( routes.up ) dom.controlsUp.classList.add( 'enabled' );
  453. if( routes.down ) dom.controlsDown.classList.add( 'enabled' );
  454. }
  455. /**
  456. * Determine what available routes there are for navigation.
  457. *
  458. * @return {Object} containing four booleans: left/right/up/down
  459. */
  460. function availableRoutes() {
  461. var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR );
  462. var verticalSlides = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR );
  463. return {
  464. left: indexh > 0,
  465. right: indexh < horizontalSlides.length - 1,
  466. up: indexv > 0,
  467. down: indexv < verticalSlides.length - 1
  468. };
  469. }
  470. /**
  471. * Reads the current URL (hash) and navigates accordingly.
  472. */
  473. function readURL() {
  474. // Break the hash down to separate components
  475. var bits = window.location.hash.slice(2).split('/');
  476. // Read the index components of the hash
  477. indexh = parseInt( bits[0] ) || 0 ;
  478. indexv = parseInt( bits[1] ) || 0 ;
  479. navigateTo( indexh, indexv );
  480. }
  481. /**
  482. * Updates the page URL (hash) to reflect the current
  483. * state.
  484. */
  485. function writeURL() {
  486. if( config.history ) {
  487. var url = '/';
  488. // Only include the minimum possible number of components in
  489. // the URL
  490. if( indexh > 0 || indexv > 0 ) url += indexh;
  491. if( indexv > 0 ) url += '/' + indexv;
  492. window.location.hash = url;
  493. }
  494. }
  495. /**
  496. * Navigate to the next slide fragment.
  497. *
  498. * @return {Boolean} true if there was a next fragment,
  499. * false otherwise
  500. */
  501. function nextFragment() {
  502. // Vertical slides:
  503. if( document.querySelector( VERTICAL_SLIDES_SELECTOR + '.present' ) ) {
  504. var verticalFragments = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment:not(.visible)' );
  505. if( verticalFragments.length ) {
  506. verticalFragments[0].classList.add( 'visible' );
  507. return true;
  508. }
  509. }
  510. // Horizontal slides:
  511. else {
  512. var horizontalFragments = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.present .fragment:not(.visible)' );
  513. if( horizontalFragments.length ) {
  514. horizontalFragments[0].classList.add( 'visible' );
  515. return true;
  516. }
  517. }
  518. return false;
  519. }
  520. /**
  521. * Navigate to the previous slide fragment.
  522. *
  523. * @return {Boolean} true if there was a previous fragment,
  524. * false otherwise
  525. */
  526. function previousFragment() {
  527. // Vertical slides:
  528. if( document.querySelector( VERTICAL_SLIDES_SELECTOR + '.present' ) ) {
  529. var verticalFragments = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment.visible' );
  530. if( verticalFragments.length ) {
  531. verticalFragments[ verticalFragments.length - 1 ].classList.remove( 'visible' );
  532. return true;
  533. }
  534. }
  535. // Horizontal slides:
  536. else {
  537. var horizontalFragments = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.present .fragment.visible' );
  538. if( horizontalFragments.length ) {
  539. horizontalFragments[ horizontalFragments.length - 1 ].classList.remove( 'visible' );
  540. return true;
  541. }
  542. }
  543. return false;
  544. }
  545. /**
  546. * Triggers a navigation to the specified indices.
  547. *
  548. * @param {Number} h The horizontal index of the slide to show
  549. * @param {Number} v The vertical index of the slide to show
  550. */
  551. function navigateTo( h, v ) {
  552. indexh = h === undefined ? indexh : h;
  553. indexv = v === undefined ? indexv : v;
  554. slide();
  555. }
  556. function navigateLeft() {
  557. // Prioritize hiding fragments
  558. if( overviewIsActive() || previousFragment() === false ) {
  559. indexh --;
  560. indexv = 0;
  561. slide();
  562. }
  563. }
  564. function navigateRight() {
  565. // Prioritize revealing fragments
  566. if( overviewIsActive() || nextFragment() === false ) {
  567. indexh ++;
  568. indexv = 0;
  569. slide();
  570. }
  571. }
  572. function navigateUp() {
  573. // Prioritize hiding fragments
  574. if( overviewIsActive() || previousFragment() === false ) {
  575. indexv --;
  576. slide();
  577. }
  578. }
  579. function navigateDown() {
  580. // Prioritize revealing fragments
  581. if( overviewIsActive() || nextFragment() === false ) {
  582. indexv ++;
  583. slide();
  584. }
  585. }
  586. /**
  587. * Navigates backwards, prioritized in the following order:
  588. * 1) Previous fragment
  589. * 2) Previous vertical slide
  590. * 3) Previous horizontal slide
  591. */
  592. function navigatePrev() {
  593. // Prioritize revealing fragments
  594. if( previousFragment() === false ) {
  595. if( availableRoutes().up ) {
  596. navigateUp();
  597. }
  598. else {
  599. // Fetch the previous horizontal slide, if there is one
  600. var previousSlide = document.querySelector( '#reveal .slides>section.past:nth-child(' + indexh + ')' );
  601. if( previousSlide ) {
  602. indexv = ( previousSlide.querySelectorAll('section').length + 1 ) || 0;
  603. indexh --;
  604. slide();
  605. }
  606. }
  607. }
  608. }
  609. /**
  610. * Same as #navigatePrev() but navigates forwards.
  611. */
  612. function navigateNext() {
  613. // Prioritize revealing fragments
  614. if( nextFragment() === false ) {
  615. availableRoutes().down ? navigateDown() : navigateRight();
  616. }
  617. }
  618. // Expose some methods publicly
  619. return {
  620. initialize: initialize,
  621. navigateTo: navigateTo,
  622. navigateLeft: navigateLeft,
  623. navigateRight: navigateRight,
  624. navigateUp: navigateUp,
  625. navigateDown: navigateDown
  626. };
  627. })();