2020-02-11 09:40:17 +00:00
|
|
|
<!doctype html>
|
|
|
|
<html lang="en">
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
|
|
|
<title>reveal.js - Test Auto-Animate</title>
|
|
|
|
|
2020-03-06 19:12:20 +00:00
|
|
|
<link rel="stylesheet" href="../dist/reveal.css">
|
2020-02-11 09:40:17 +00:00
|
|
|
<link rel="stylesheet" href="qunit-2.5.0.css">
|
2020-03-07 17:19:08 +00:00
|
|
|
<script src="qunit-2.5.0.js"></script>
|
2020-02-11 09:40:17 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body style="overflow: auto;">
|
|
|
|
|
|
|
|
<div id="qunit"></div>
|
|
|
|
<div id="qunit-fixture"></div>
|
|
|
|
|
|
|
|
<div class="reveal">
|
|
|
|
|
|
|
|
<div class="slides">
|
|
|
|
|
|
|
|
<section data-auto-animate>
|
|
|
|
<h1>h1</h1>
|
|
|
|
<h2>h2</h2>
|
|
|
|
<h3 style="position: absolute; left: 0;">h3</h2>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section data-auto-animate>
|
2020-04-06 12:07:24 +00:00
|
|
|
<h1 data-auto-animate-duration="0.1">h1</h1>
|
2020-02-11 09:40:17 +00:00
|
|
|
<h2 style="opacity: 0;">h2</h2>
|
|
|
|
<h3 style="position: absolute; left: 100px;">h3</h2>
|
|
|
|
</section>
|
|
|
|
|
2020-04-06 12:07:24 +00:00
|
|
|
<section data-auto-animate data-auto-animate-duration="0.1">
|
2020-02-11 09:40:17 +00:00
|
|
|
<h1>h1</h1>
|
|
|
|
<h2>h2</h2>
|
|
|
|
<h3>h3</h2>
|
|
|
|
</section>
|
|
|
|
|
2020-02-16 18:14:46 +00:00
|
|
|
<section>
|
|
|
|
<h1>Non-auto-animate slide</h1>
|
|
|
|
</section>
|
|
|
|
|
2020-03-19 14:18:14 +00:00
|
|
|
<section data-auto-animate>
|
|
|
|
<h1 class="fragment">h1</h1>
|
|
|
|
<h2 class="fragment">h2</h2>
|
|
|
|
<h3>h3</h3>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section data-auto-animate>
|
|
|
|
<h1 class="fragment">h1</h1>
|
|
|
|
<h2 class="fragment">h2</h2>
|
|
|
|
<h3 class="fragment">h3</h3>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<h1>Non-auto-animate slide</h1>
|
|
|
|
</section>
|
|
|
|
|
2020-02-11 09:40:17 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2020-04-17 08:59:55 +00:00
|
|
|
<script src="../dist/reveal.es5.js"></script>
|
2020-02-11 09:40:17 +00:00
|
|
|
<script>
|
2020-02-11 14:31:17 +00:00
|
|
|
|
2020-02-16 18:14:46 +00:00
|
|
|
const slides = Array.prototype.map.call( document.querySelectorAll( '.slides section' ), slide => {
|
2020-02-11 14:31:17 +00:00
|
|
|
return {
|
2020-02-17 09:19:47 +00:00
|
|
|
slide: slide,
|
2020-02-11 14:31:17 +00:00
|
|
|
h1: slide.querySelector( 'h1' ),
|
|
|
|
h2: slide.querySelector( 'h2' ),
|
|
|
|
h3: slide.querySelector( 'h3' )
|
|
|
|
};
|
|
|
|
} );
|
2020-02-11 09:40:17 +00:00
|
|
|
|
2020-03-07 17:19:08 +00:00
|
|
|
Reveal.initialize().then( () => {
|
2020-02-11 09:40:17 +00:00
|
|
|
|
|
|
|
QUnit.module( 'Auto-Animate' );
|
|
|
|
|
|
|
|
QUnit.test( 'Adds data-auto-animate-target', assert => {
|
2020-02-11 09:52:39 +00:00
|
|
|
Reveal.slide(1);
|
2020-02-11 09:40:17 +00:00
|
|
|
assert.strictEqual( slides[0].h1.getAttribute( 'data-auto-animate-target' ), '', 'From elements have blank data-auto-animate-target' );
|
|
|
|
assert.ok( slides[1].h1.getAttribute( 'data-auto-animate-target' ).length > 0, 'To elements have a data-auto-animate-target value' );
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test( 'Ends on correct target styles', assert => {
|
2020-02-11 09:52:39 +00:00
|
|
|
Reveal.slide(1);
|
2020-02-11 09:40:17 +00:00
|
|
|
assert.strictEqual( slides[1].h2.style.opacity, "0" );
|
|
|
|
assert.strictEqual( slides[1].h3.offsetLeft, 100 );
|
|
|
|
});
|
|
|
|
|
2020-02-11 09:52:39 +00:00
|
|
|
QUnit.test( 'Slide specific data-auto-animate-duration', assert => {
|
2020-02-11 14:31:17 +00:00
|
|
|
assert.timeout( 400 );
|
|
|
|
let done = assert.async();
|
|
|
|
let callback = () => {
|
|
|
|
slides[2].h3.removeEventListener( 'transitionend', callback );
|
|
|
|
assert.ok( true, 'Transition ended within time window' );
|
|
|
|
done();
|
|
|
|
}
|
2020-02-11 09:40:17 +00:00
|
|
|
|
2020-02-11 09:52:39 +00:00
|
|
|
Reveal.slide(2);
|
2020-02-11 09:40:17 +00:00
|
|
|
|
2020-02-11 14:31:17 +00:00
|
|
|
slides[2].h3.addEventListener( 'transitionend', callback );
|
2020-02-11 09:40:17 +00:00
|
|
|
});
|
|
|
|
|
2020-02-11 09:52:39 +00:00
|
|
|
QUnit.test( 'Element specific data-auto-animate-duration', assert => {
|
2020-02-11 14:31:17 +00:00
|
|
|
assert.timeout( 400 );
|
|
|
|
let done = assert.async();
|
|
|
|
let callback = () => {
|
|
|
|
slides[1].h1.removeEventListener( 'transitionend', callback );
|
|
|
|
assert.ok( true, 'Transition ended within time window' );
|
|
|
|
done();
|
|
|
|
}
|
2020-02-11 09:52:39 +00:00
|
|
|
|
|
|
|
Reveal.slide(1);
|
|
|
|
|
2020-02-11 14:31:17 +00:00
|
|
|
slides[1].h1.addEventListener( 'transitionend', callback );
|
2020-02-11 09:52:39 +00:00
|
|
|
});
|
|
|
|
|
2020-02-17 09:19:47 +00:00
|
|
|
QUnit.test( 'Does not add [data-auto-animate] on non auto-animated slides', assert => {
|
|
|
|
Reveal.slide(2);
|
|
|
|
Reveal.next();
|
|
|
|
assert.ok( slides[3].slide.hasAttribute( 'data-auto-animate' ) === false )
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test( 'autoAnimate config option', assert => {
|
|
|
|
Reveal.configure({ autoAnimate: false });
|
|
|
|
|
|
|
|
assert.ok( document.querySelectorAll( 'data-auto-animate-target' ).length === 0, 'Removes all [data-auto-animate-target]' )
|
|
|
|
assert.ok( Array.prototype.every.call( document.querySelectorAll( 'section[data-auto-animate]' ), el => {
|
|
|
|
return el.dataset.autoAnimate === '';
|
|
|
|
}, 'All data-auto-animate attributes are reset' ) );
|
|
|
|
|
|
|
|
Reveal.configure({ autoAnimate: true });
|
|
|
|
});
|
|
|
|
|
2020-03-19 14:18:14 +00:00
|
|
|
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() )
|
|
|
|
});
|
|
|
|
|
2020-02-11 09:40:17 +00:00
|
|
|
} );
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|