update reveal.js
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
<script src="../dist/reveal.js"></script>
|
||||
<script>
|
||||
|
||||
QUnit.config.testTimeout = 30000;
|
||||
QUnit.config.reorder = false;
|
||||
|
||||
const slides = Array.prototype.map.call( document.querySelectorAll( '.slides section' ), slide => {
|
||||
@@ -109,21 +110,6 @@
|
||||
Reveal.configure({ autoAnimate: true });
|
||||
});
|
||||
|
||||
QUnit.test( 'Carries forward matching fragment visibility', assert => {
|
||||
Reveal.slide(4);
|
||||
assert.ok( !slides[5].h1.classList.contains( 'visible' ) )
|
||||
Reveal.next();
|
||||
Reveal.next();
|
||||
Reveal.next();
|
||||
assert.ok( slides[5].h1.classList.contains( 'visible' ) )
|
||||
assert.ok( slides[5].h2.classList.contains( 'visible' ) )
|
||||
assert.ok( !slides[5].h3.classList.contains( 'visible' ) )
|
||||
Reveal.next();
|
||||
assert.ok( slides[5].h3.classList.contains( 'visible' ) )
|
||||
Reveal.next();
|
||||
assert.ok( slides[6].slide === Reveal.getCurrentSlide() )
|
||||
});
|
||||
|
||||
QUnit.test( 'Slide specific data-auto-animate-duration', assert => {
|
||||
assert.timeout( 400 );
|
||||
assert.expect( 1 );
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
var externalScriptSequence = '';
|
||||
var scriptCount = 0;
|
||||
|
||||
QUnit.config.testTimeout = 30000;
|
||||
QUnit.config.autostart = false;
|
||||
QUnit.module( 'Async Dependencies' );
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
<script>
|
||||
window.externalScriptSequence = '';
|
||||
|
||||
QUnit.config.testTimeout = 30000;
|
||||
QUnit.config.autostart = false;
|
||||
QUnit.module( 'Dependencies' );
|
||||
|
||||
Reveal.initialize({
|
||||
dependencies: [
|
||||
{ src: 'assets/external-script-a.js' },
|
||||
@@ -38,7 +42,7 @@
|
||||
]
|
||||
}).then( () => {
|
||||
|
||||
QUnit.module( 'Dependencies' );
|
||||
QUnit.start();
|
||||
|
||||
QUnit.test( 'Load synchronous scripts', function( assert ) {
|
||||
assert.strictEqual( window.externalScriptSequence, 'ABC', 'Loaded and executed in order' );
|
||||
|
||||
97
scripts/reveal.js/test/test-destroy.html
Normal file
97
scripts/reveal.js/test/test-destroy.html
Normal file
@@ -0,0 +1,97 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>reveal.js - Test Dependencies</title>
|
||||
|
||||
<link rel="stylesheet" href="../dist/reveal.css">
|
||||
<link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css">
|
||||
<script src="../node_modules/qunit/qunit/qunit.js"></script>
|
||||
</head>
|
||||
|
||||
<body style="overflow: auto;">
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
|
||||
<div class="reveal deck1" style="display: none;">
|
||||
<div class="slides">
|
||||
<section>Slide content</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="reveal deck2" style="display: none;">
|
||||
<div class="slides">
|
||||
<section>Slide content</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="module">
|
||||
import Reveal from '../dist/reveal.esm.js'
|
||||
import Markdown from '../plugin/markdown/markdown.esm.js'
|
||||
|
||||
QUnit.module( 'Destroy' );
|
||||
|
||||
QUnit.test( 'Destruction during initialization', function( assert ) {
|
||||
|
||||
let deck = new Reveal( document.querySelector( '.deck1' ) );
|
||||
|
||||
deck.initialize({ plugins: [ Markdown ] });
|
||||
|
||||
let firstAttemptSuccess = false;
|
||||
let repeatedAttemptSuccess = false;
|
||||
|
||||
try {
|
||||
deck.destroy();
|
||||
firstAttemptSuccess = true;
|
||||
}
|
||||
catch( error ) {
|
||||
console.error( error );
|
||||
}
|
||||
|
||||
assert.ok( firstAttemptSuccess, 'was successful' );
|
||||
|
||||
// should be able to destroy twice with no side effect
|
||||
try {
|
||||
deck.destroy();
|
||||
repeatedAttemptSuccess = true;
|
||||
}
|
||||
catch( error ) {
|
||||
console.error( error );
|
||||
}
|
||||
|
||||
assert.ok( repeatedAttemptSuccess, 'destroyed twice with no exceptions' );
|
||||
|
||||
} );
|
||||
|
||||
QUnit.test( 'Destruction after initialization', function( assert ) {
|
||||
|
||||
assert.expect( 1 );
|
||||
let done = assert.async( 1 );
|
||||
let deck = new Reveal( document.querySelector( '.deck2' ) );
|
||||
|
||||
deck.initialize({ plugins: [ Markdown ] }).then(() => {
|
||||
let wasSuccessful = false;
|
||||
|
||||
try {
|
||||
deck.destroy();
|
||||
wasSuccessful = true;
|
||||
}
|
||||
catch( error ) {
|
||||
console.error( error );
|
||||
}
|
||||
|
||||
if( wasSuccessful ) {
|
||||
assert.ok( true, 'was successful' );
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -40,9 +40,13 @@
|
||||
|
||||
<script src="../dist/reveal.js"></script>
|
||||
<script>
|
||||
QUnit.config.testTimeout = 30000;
|
||||
QUnit.config.autostart = false;
|
||||
QUnit.module( 'Grid Navigation' );
|
||||
|
||||
Reveal.initialize().then( () => {
|
||||
|
||||
QUnit.module( 'Grid Navigation' );
|
||||
QUnit.start();
|
||||
|
||||
QUnit.test( 'Disabled', function( assert ) {
|
||||
Reveal.right();
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
<script src="../dist/reveal.js"></script>
|
||||
<script>
|
||||
|
||||
QUnit.config.testTimeout = 30000;
|
||||
|
||||
Reveal.initialize({ viewDistance: 3 }).then( () => {
|
||||
|
||||
function getIframe( index ) {
|
||||
|
||||
@@ -34,68 +34,68 @@
|
||||
<script src="../dist/reveal.js"></script>
|
||||
<script>
|
||||
|
||||
Reveal.initialize({ viewDistance: 2 }).then( () => {
|
||||
QUnit.config.testTimeout = 30000;
|
||||
|
||||
var defaultIframe = document.querySelector( '.default-iframe' ),
|
||||
preloadIframe = document.querySelector( '.preload-iframe' );
|
||||
Reveal.initialize({ viewDistance: 2 });
|
||||
|
||||
QUnit.module( 'Iframe' );
|
||||
var defaultIframe = document.querySelector( '.default-iframe' ),
|
||||
preloadIframe = document.querySelector( '.preload-iframe' );
|
||||
|
||||
QUnit.test( 'Using default settings', function( assert ) {
|
||||
QUnit.module( 'Iframe' );
|
||||
|
||||
Reveal.slide(1);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), false, 'not preloaded when within viewDistance' );
|
||||
QUnit.test( 'Using default settings', function( assert ) {
|
||||
|
||||
Reveal.slide(2);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
|
||||
Reveal.slide(1);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), false, 'not preloaded when within viewDistance' );
|
||||
|
||||
Reveal.slide(1);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), false, 'unloaded when slide becomes invisible' );
|
||||
Reveal.slide(2);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
|
||||
|
||||
});
|
||||
Reveal.slide(1);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), false, 'unloaded when slide becomes invisible' );
|
||||
|
||||
QUnit.test( 'Using data-preload', function( assert ) {
|
||||
});
|
||||
|
||||
Reveal.slide(1);
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
|
||||
QUnit.test( 'Using data-preload', function( assert ) {
|
||||
|
||||
Reveal.slide(2);
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'loaded when slide becoems visible' );
|
||||
Reveal.slide(1);
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
|
||||
|
||||
Reveal.slide(0);
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), false, 'unloads outside of viewDistance' );
|
||||
Reveal.slide(2);
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
|
||||
|
||||
});
|
||||
Reveal.slide(0);
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), false, 'unloads outside of viewDistance' );
|
||||
|
||||
QUnit.test( 'Using preloadIframes: true', function( assert ) {
|
||||
});
|
||||
|
||||
Reveal.configure({ preloadIframes: true });
|
||||
QUnit.test( 'Using preloadIframes: true', function( assert ) {
|
||||
|
||||
Reveal.slide(1);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
|
||||
Reveal.configure({ preloadIframes: true });
|
||||
|
||||
Reveal.slide(2);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
|
||||
Reveal.slide(1);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
|
||||
|
||||
});
|
||||
Reveal.slide(2);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
|
||||
|
||||
QUnit.test( 'Using preloadIframes: false', function( assert ) {
|
||||
});
|
||||
|
||||
Reveal.configure({ preloadIframes: false });
|
||||
QUnit.test( 'Using preloadIframes: false', function( assert ) {
|
||||
|
||||
Reveal.slide(0);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), false, 'not preloaded within viewDistance' );
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), false, 'not preloaded within viewDistance' );
|
||||
Reveal.configure({ preloadIframes: false });
|
||||
|
||||
Reveal.slide(2);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
|
||||
Reveal.slide(0);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), false, 'not preloaded within viewDistance' );
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), false, 'not preloaded within viewDistance' );
|
||||
|
||||
});
|
||||
Reveal.slide(2);
|
||||
assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
|
||||
assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
|
||||
|
||||
} );
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -274,6 +274,13 @@
|
||||
```
|
||||
</script>
|
||||
</section>
|
||||
<section data-markdown class="with-offset">
|
||||
<script type="text/template">
|
||||
```[123:]
|
||||
code
|
||||
```
|
||||
</script>
|
||||
</section>
|
||||
<section data-markdown class="with-line-highlights-and-lanugage">
|
||||
<script type="text/template">
|
||||
```javascript [1,2,3]
|
||||
@@ -281,6 +288,20 @@
|
||||
```
|
||||
</script>
|
||||
</section>
|
||||
<section data-markdown class="with-line-highlights-offset-and-lanugage">
|
||||
<script type="text/template">
|
||||
```javascript [456: 3,4,5]
|
||||
code
|
||||
```
|
||||
</script>
|
||||
</section>
|
||||
<section data-markdown class="with-line-offset-and-lanugage">
|
||||
<script type="text/template">
|
||||
```javascript [756:]
|
||||
code
|
||||
```
|
||||
</script>
|
||||
</section>
|
||||
<section data-markdown class="with-code-in-fragment">
|
||||
<script type="text/template">
|
||||
```js
|
||||
@@ -298,6 +319,8 @@
|
||||
import Markdown from '../plugin/markdown/markdown.esm.js'
|
||||
import Highlight from '../plugin/highlight/highlight.esm.js'
|
||||
|
||||
QUnit.config.testTimeout = 30000;
|
||||
|
||||
let deck1 = new Reveal( document.querySelector( '.deck1' ), { plugins: [ Markdown ] })
|
||||
deck1.addEventListener( 'ready', function() {
|
||||
|
||||
@@ -458,9 +481,22 @@
|
||||
assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-line-highlights .hljs[data-line-numbers="1,2,3"]' ).length, 1 );
|
||||
});
|
||||
|
||||
QUnit.test( '```[234: ] line offset only', function( assert ) {
|
||||
assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-offset .hljs[data-ln-start-from="123"]' ).length, 1 );
|
||||
});
|
||||
|
||||
QUnit.test( '```javascript [1,2,3] enables line highlights and sets language', function( assert ) {
|
||||
assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-line-highlights-and-lanugage .hljs.javascript[data-line-numbers="1,2,3"]' ).length, 1 );
|
||||
});
|
||||
|
||||
QUnit.test( '```javascript [123: 3,4,5] add line offset and enables line highlights and sets language', function( assert ) {
|
||||
assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-line-highlights-offset-and-lanugage .hljs.javascript[data-line-numbers="3,4,5"]' ).length, 1 );
|
||||
assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-line-highlights-offset-and-lanugage .hljs.javascript[data-ln-start-from="456"]' ).length, 1 );
|
||||
});
|
||||
|
||||
QUnit.test( '```javascript [756:] add line offset and sets no line highlights and sets language', function( assert ) {
|
||||
assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-line-offset-and-lanugage .hljs.javascript[data-ln-start-from="756"]' ).length, 1 );
|
||||
});
|
||||
|
||||
QUnit.test( '```block should allow custom fragment', function( assert ) {
|
||||
assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-code-in-fragment pre.fragment' ).length, 1 );
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
<script src="../plugin/zoom/zoom.js"></script>
|
||||
<script>
|
||||
|
||||
QUnit.config.testTimeout = 30000;
|
||||
QUnit.module( 'Multiple reveal.js instances' );
|
||||
|
||||
let r1 = new Reveal( document.querySelector( '.deck1 .reveal' ), {
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
import Reveal from '../dist/reveal.esm.js';
|
||||
import Zoom from '../plugin/zoom/zoom.esm.js';
|
||||
|
||||
QUnit.config.testTimeout = 30000;
|
||||
QUnit.module( 'Multiple reveal.js instances' );
|
||||
|
||||
let r1 = new Reveal( document.querySelector( '.deck1 .reveal' ), {
|
||||
|
||||
@@ -75,8 +75,13 @@
|
||||
|
||||
<script src="../dist/reveal.js"></script>
|
||||
<script>
|
||||
QUnit.config.testTimeout = 30000;
|
||||
QUnit.config.autostart = false;
|
||||
|
||||
Reveal.initialize({ pdf: true }).then( function() {
|
||||
|
||||
QUnit.start();
|
||||
|
||||
// Only one test for now, we're mainly ensuring that there
|
||||
// are no execution errors when running PDF mode
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<script src="../dist/reveal.js"></script>
|
||||
<script>
|
||||
|
||||
QUnit.config.testTimeout = 30000;
|
||||
QUnit.module( 'Plugins' );
|
||||
|
||||
var initCounter = { PluginB: 0, PluginC: 0, PluginD: 0 };
|
||||
|
||||
162
scripts/reveal.js/test/test-scroll.html
Normal file
162
scripts/reveal.js/test/test-scroll.html
Normal file
@@ -0,0 +1,162 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>reveal.js - Test Scroll View</title>
|
||||
|
||||
<link rel="stylesheet" href="../dist/reveal.css">
|
||||
<link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css">
|
||||
<script src="../node_modules/qunit/qunit/qunit.js"></script>
|
||||
</head>
|
||||
|
||||
<body style="overflow: auto;">
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
|
||||
<div class="reveal" style="opacity: 0; pointer-events: none;">
|
||||
|
||||
<div class="slides">
|
||||
|
||||
<section>
|
||||
<h1>slide 1</h1>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h1>slide 2</h1>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h1>slide 3</h1>
|
||||
<p class="fragment">fragment 1</p>
|
||||
<p class="fragment">fragment 2</p>
|
||||
<p class="fragment">fragment 3</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h1>slide 4</h1>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="../dist/reveal.js"></script>
|
||||
<script>
|
||||
|
||||
QUnit.config.testTimeout = 30000;
|
||||
QUnit.config.reorder = false;
|
||||
|
||||
function getScrollHeight() {
|
||||
return Reveal.getViewportElement().scrollHeight;
|
||||
}
|
||||
|
||||
function getViewportHeight() {
|
||||
return Reveal.getViewportElement().offsetHeight;
|
||||
}
|
||||
|
||||
Reveal.initialize({ view: 'scroll' }).then( async () => {
|
||||
|
||||
QUnit.module( 'Scroll View' );
|
||||
|
||||
QUnit.test( 'Activates', assert => {
|
||||
assert.ok( getScrollHeight() > getViewportHeight(), 'Is overflowing' );
|
||||
});
|
||||
|
||||
QUnit.test( 'Can be toggled via API', assert => {
|
||||
Reveal.toggleScrollView( false );
|
||||
assert.ok( getScrollHeight() <= getViewportHeight(), 'Is not overflowing' );
|
||||
Reveal.toggleScrollView( true );
|
||||
assert.ok( getScrollHeight() > getViewportHeight(), 'Is overflowing' );
|
||||
});
|
||||
|
||||
QUnit.test( 'Changes present slide when scrolling', assert => {
|
||||
assert.timeout( 200 );
|
||||
assert.expect( 2 );
|
||||
|
||||
const slides = document.querySelectorAll( '.reveal .slides section' );
|
||||
|
||||
assert.ok( slides[0].classList.contains( 'present' ), 'First slide is present' );
|
||||
Reveal.getViewportElement().scrollTop = getViewportHeight() * 1;
|
||||
|
||||
return new Promise( resolve => {
|
||||
setTimeout(() => {
|
||||
assert.ok( slides[1].classList.contains( 'present' ), 'Second slide is present' );
|
||||
resolve();
|
||||
}, 100);
|
||||
} );
|
||||
});
|
||||
|
||||
QUnit.test( 'Fires slideschanged event when scrolling', assert => {
|
||||
assert.timeout( 200 );
|
||||
assert.expect( 2 );
|
||||
|
||||
const slides = document.querySelectorAll( '.reveal .slides section' );
|
||||
|
||||
return new Promise( resolve => {
|
||||
let callback = ( event ) => {
|
||||
Reveal.off( 'slidechanged', callback );
|
||||
assert.ok( true, 'slidechanged event fired' );
|
||||
assert.ok( event.currentSlide.classList.contains( 'present' ), 'slidechanged provides reference to currentSlide' );
|
||||
resolve();
|
||||
}
|
||||
|
||||
Reveal.on( 'slidechanged', callback );
|
||||
Reveal.getViewportElement().scrollTop = getViewportHeight() * 2;
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test( 'Fires fragmentshown event when scrolling', assert => {
|
||||
assert.timeout( 200 );
|
||||
assert.expect( 2 );
|
||||
|
||||
const slides = document.querySelectorAll( '.reveal .slides section' );
|
||||
|
||||
return new Promise( resolve => {
|
||||
let callback = ( event ) => {
|
||||
Reveal.off( 'fragmentshown', callback );
|
||||
assert.ok( true, 'fragmentshown event fired' );
|
||||
assert.ok( event.fragments.length > 0, 'fragmentshown provides reference to fragment nodes' );
|
||||
resolve();
|
||||
}
|
||||
|
||||
Reveal.on( 'fragmentshown', callback );
|
||||
|
||||
Reveal.getViewportElement().scrollTop = 0;
|
||||
Reveal.next();
|
||||
Reveal.next();
|
||||
Reveal.getViewportElement().scrollTop += getViewportHeight();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test( 'Fires fragmenthidden event when scrolling', assert => {
|
||||
assert.timeout( 200 );
|
||||
assert.expect( 2 );
|
||||
|
||||
const slides = document.querySelectorAll( '.reveal .slides section' );
|
||||
|
||||
return new Promise( resolve => {
|
||||
let callback = ( event ) => {
|
||||
Reveal.off( 'fragmenthidden', callback );
|
||||
assert.ok( true, 'fragmenthidden event fired' );
|
||||
assert.ok( event.fragments.length > 0, 'fragmenthidden provides reference to fragment nodes' );
|
||||
resolve();
|
||||
}
|
||||
|
||||
Reveal.on( 'fragmenthidden', callback );
|
||||
|
||||
Reveal.getViewportElement().scrollTop = 0;
|
||||
Reveal.next();
|
||||
Reveal.next();
|
||||
Reveal.next();
|
||||
Reveal.getViewportElement().scrollTop -= getViewportHeight();
|
||||
});
|
||||
});
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -39,97 +39,95 @@
|
||||
<script src="../dist/reveal.js"></script>
|
||||
<script>
|
||||
|
||||
Reveal.initialize().then( function() {
|
||||
console.log(Reveal);
|
||||
Reveal.initialize();
|
||||
|
||||
QUnit.module( 'State' );
|
||||
QUnit.module( 'State' );
|
||||
|
||||
QUnit.test( 'Fire events when changing slide', function( assert ) {
|
||||
assert.expect( 2 );
|
||||
var state1 = assert.async();
|
||||
var state2 = assert.async();
|
||||
QUnit.test( 'Fire events when changing slide', function( assert ) {
|
||||
assert.expect( 2 );
|
||||
var state1 = assert.async();
|
||||
var state2 = assert.async();
|
||||
|
||||
var _onState1 = function( event ) {
|
||||
assert.ok( true, 'state1 fired' );
|
||||
state1();
|
||||
}
|
||||
var _onState1 = function( event ) {
|
||||
assert.ok( true, 'state1 fired' );
|
||||
state1();
|
||||
}
|
||||
|
||||
var _onState2 = function( event ) {
|
||||
assert.ok( true, 'state2 fired' );
|
||||
state2();
|
||||
}
|
||||
var _onState2 = function( event ) {
|
||||
assert.ok( true, 'state2 fired' );
|
||||
state2();
|
||||
}
|
||||
|
||||
Reveal.on( 'state1', _onState1 );
|
||||
Reveal.on( 'state2', _onState2 );
|
||||
Reveal.on( 'state1', _onState1 );
|
||||
Reveal.on( 'state2', _onState2 );
|
||||
|
||||
Reveal.slide( 1 );
|
||||
Reveal.slide( 3 );
|
||||
Reveal.slide( 1 );
|
||||
Reveal.slide( 3 );
|
||||
|
||||
Reveal.off( 'state1', _onState1 );
|
||||
Reveal.off( 'state2', _onState2 );
|
||||
});
|
||||
Reveal.off( 'state1', _onState1 );
|
||||
Reveal.off( 'state2', _onState2 );
|
||||
});
|
||||
|
||||
QUnit.test( 'Fire state events for vertical slides', function( assert ) {
|
||||
assert.expect( 2 );
|
||||
var done = assert.async( 2 );
|
||||
QUnit.test( 'Fire state events for vertical slides', function( assert ) {
|
||||
assert.expect( 2 );
|
||||
var done = assert.async( 2 );
|
||||
|
||||
var _onState1 = function( event ) {
|
||||
assert.ok( true, 'state1 fired' );
|
||||
done();
|
||||
}
|
||||
var _onState1 = function( event ) {
|
||||
assert.ok( true, 'state1 fired' );
|
||||
done();
|
||||
}
|
||||
|
||||
var _onState3 = function( event ) {
|
||||
assert.ok( true, 'state3 fired' );
|
||||
done();
|
||||
}
|
||||
var _onState3 = function( event ) {
|
||||
assert.ok( true, 'state3 fired' );
|
||||
done();
|
||||
}
|
||||
|
||||
Reveal.on( 'state1', _onState1 );
|
||||
Reveal.on( 'state3', _onState3 );
|
||||
Reveal.on( 'state1', _onState1 );
|
||||
Reveal.on( 'state3', _onState3 );
|
||||
|
||||
Reveal.slide( 0 );
|
||||
Reveal.slide( 4, 1 );
|
||||
Reveal.slide( 4, 2 );
|
||||
Reveal.slide( 0 );
|
||||
Reveal.slide( 4, 1 );
|
||||
Reveal.slide( 4, 2 );
|
||||
|
||||
Reveal.off( 'state1', _onState1 );
|
||||
Reveal.off( 'state3', _onState3 );
|
||||
});
|
||||
Reveal.off( 'state1', _onState1 );
|
||||
Reveal.off( 'state3', _onState3 );
|
||||
});
|
||||
|
||||
QUnit.test( 'No events if state remains unchanged', function( assert ) {
|
||||
var stateChanges = 0;
|
||||
QUnit.test( 'No events if state remains unchanged', function( assert ) {
|
||||
var stateChanges = 0;
|
||||
|
||||
var _onEvent = function( event ) {
|
||||
stateChanges += 1;
|
||||
}
|
||||
var _onEvent = function( event ) {
|
||||
stateChanges += 1;
|
||||
}
|
||||
|
||||
Reveal.on( 'state1', _onEvent );
|
||||
Reveal.on( 'state1', _onEvent );
|
||||
|
||||
Reveal.slide( 0 ); // no state
|
||||
Reveal.slide( 1 ); // state1
|
||||
Reveal.slide( 2 ); // state1
|
||||
Reveal.prev(); // state1
|
||||
Reveal.next(); // state1
|
||||
Reveal.slide( 4, 1 ); // state1
|
||||
Reveal.slide( 0 ); // no state
|
||||
Reveal.slide( 0 ); // no state
|
||||
Reveal.slide( 1 ); // state1
|
||||
Reveal.slide( 2 ); // state1
|
||||
Reveal.prev(); // state1
|
||||
Reveal.next(); // state1
|
||||
Reveal.slide( 4, 1 ); // state1
|
||||
Reveal.slide( 0 ); // no state
|
||||
|
||||
Reveal.off( 'state1', _onEvent );
|
||||
Reveal.off( 'state1', _onEvent );
|
||||
|
||||
assert.strictEqual( stateChanges, 1, 'no event was fired when going to slide with same state' );
|
||||
});
|
||||
assert.strictEqual( stateChanges, 1, 'no event was fired when going to slide with same state' );
|
||||
});
|
||||
|
||||
QUnit.test( 'Event order', function( assert ) {
|
||||
var _onEvent = function( event ) {
|
||||
assert.ok( Reveal.getCurrentSlide() == document.querySelector( '#slide2' ), 'correct current slide immediately after state event' );
|
||||
}
|
||||
QUnit.test( 'Event order', function( assert ) {
|
||||
var _onEvent = function( event ) {
|
||||
assert.ok( Reveal.getCurrentSlide() == document.querySelector( '#slide2' ), 'correct current slide immediately after state event' );
|
||||
}
|
||||
|
||||
Reveal.on( 'state1', _onEvent );
|
||||
Reveal.on( 'state1', _onEvent );
|
||||
|
||||
Reveal.slide( 0 );
|
||||
Reveal.slide( 1 );
|
||||
Reveal.slide( 0 );
|
||||
Reveal.slide( 1 );
|
||||
|
||||
Reveal.off( 'state1', _onEvent );
|
||||
});
|
||||
Reveal.off( 'state1', _onEvent );
|
||||
});
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -83,6 +83,8 @@
|
||||
|
||||
<script src="../dist/reveal.js"></script>
|
||||
<script>
|
||||
QUnit.config.testTimeout = 30000;
|
||||
|
||||
window.location.hash = '';
|
||||
|
||||
Reveal.configure({maxScale: 1.11});
|
||||
|
||||
Reference in New Issue
Block a user