Created
March 5, 2012 05:06
-
-
Save imakewebthings/1976702 to your computer and use it in GitHub Desktop.
Dirty hack to fake overloading of next/prev to invoke arbitrary JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This is the same principle used in a previous gist: https://gist.github.com/1955854 | |
In this case, we use blank elements in the slide to provide an animation "step." | |
The presenter explicitly hits next/prev to reveal and unravel the animation instead | |
of it happening automatically when the slide is made current and leaves the screen. | |
The HTML structure be: | |
<section class="slide"> | |
<p>Some normal slide content...</p> | |
<div class="slide" id="some-animation"></div> | |
</section> | |
*/ | |
$(document).bind('deck.change', function(event, from, to) { | |
var $entering = $.deck('getSlide', to); | |
$leaving = $.deck('getSlide', from); | |
/* | |
If there are multiple animations and they are all unique, set | |
up each of the animations by id. If each animation is the same | |
for any slides that have them, you should use a class instead. | |
*/ | |
if ($entering[0].id === 'some-animation') { | |
// The animation has become current, start the animation | |
} | |
if ($leaving[0].id === 'some-animation') { | |
// The animation is no longer current, animate back | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment