New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for stepNext and stepPrev for in-slide "animations": enables for custom animations, SVG animations, video play/pause, etc... #80
Conversation
…ons [backport] * stepNext is stepping within a slide (if meaningfull) while the existing "next" is skipping the current slide and going to the next one * select some key binding for those (borrowed from the "next") * there is also a stepPrev to undo animations * the in-slide animations can be defined in a dedicated "pre" element in the slide itself * animations are optionally init-able and undo-able * animations are initialized and undone in reverse order
…ly (or refreshing) a slide even if it has svg animations [backport]
…a jasmine test failed by previous modifications)
Hi Rémi, Sorry it's taken so long to address this. Busy times, and all that. Here's what I'd like to get out of this thread: What do I need to provide in core that could make this work as an extension. At least one change will be necessary, and I want to make it regardless of this ticket anyway. You need a way to hijack the next and previous actions and run your step code instead of change slides. There IS a way to prevent slide change right now, but it's just awful. Currently if you prevent default inside of a I'd like to add an event that fires before Can you think of anything else I'm missing that would need to be changed in core to facilitate this? |
Hi Caleb, I understand your motivation to keep the core as simple as possible. I originally started my implementation touching the core minimally but I ended up doing dirty stuffs like overriding the next() method (maybe by ignorance on how to do it differently). To overcome this overriding, the deck.beforeChange event might be sufficient, I guess. Nevertheless, if I try to decompose the pull request, there are the following main aspects: For (1) and (2) I guess that as you said there is no problem to move it as a “animation-controller” extension (provided there is deck.beforeChange). For (3) and the associated bindings, I actually see it more as a end-user requirement than a hack to play animations. Overall for (3), I really like the concept and think it would fit in the core... but then it might try to pull (1) with it. Making (3) as an extension would only require a way to add the stepNext (and stepPrev) and to override the key bindings. For (4), I would need to think more about it to see how it could fit out of the core... I am open to your insights. Rémi |
Rémi, I fully understand your issues with large slide counts (no one wants to see "1/100" when someone starts up their presentation), but unless I'm misunderstanding you couldn't you just use extra subslides for your animations instead of bolting on "steps"? You can use the extension deck.events.js to bind javascript to a slide, which I believe would work for each of your animations.
This does not let you "skip" animations, since they have the same weight as a regular slide, so we'd need to find a solution to that. |
Replies for @twitwi first:
That's completely reasonable. But if you want wholly separate methods and UI elements for going through steps, you don't even need
Yup, but just so you know this is already an option: $.deck('.slide', {
countNested: false
}) For (4), does the loading of external SVG resources behave any different than the loading of, say, a large I think what should and shouldn't be considered a "slide" is open to interpretation. But this isn't the first time I've had a request to basically override the next action in order to do something else, and there are cases where making them subslides make no sense. How about a video. Let's say a presenter has bound a presentation remote to the next/prev key bindings, and they have a slide with a video in it. What if they just want to press the next button on the remote to play the video. Next again to make it stop. And then one last time to advance the slides. This seems more natural than having to create another key binding to play/pause in-slide videos, or make the presenter walk over to the computer. That said, I could see Rémi implementing this using any of the methods we've gone over so far:
And I agree that using deck.events would make any of these resulting extensions more readable and easier to organize. |
Subslides is a poor term for it, I agree, but as I mentioned before your video example (if javascript can start/pause the video) can be handled by deck.events without making the presenter use different keybindings. Just add something like this:
When you hit the "next" key to move to the play-video and pause-video slides, the corresponding javascript is run automatically. It requires no other actions on the presenter's part. I did not know about countNested -- that's nifty. |
@nemec Yep, that's how I would do it personally as well. And in this theoretical video plugin, I might inject the necessary pseudo-slides in the I do still plan on adding this Plus it would be nice to have this event fire on any $(document).bind('deck.beforeChange', function(event, from, to) {
var onLast = from === $.deck('getSlides').length - 1;
var isNextAction = to === from + 1;
if (onLast && isNextAction) {
$.deck('go', 0);
}
}); |
Hi @imakewebthings and @nemec, |
I didn't know about neither deck.events.js and the countNested option: these are very nice. I think, I can refactor things to use these two in a proper way. @nemec, what I called animation container was basically a list of animations for a slide. Related to my "animations" (i.e., the evented sub-slides), they can be "executed", "reversed" but also "inited". I actually use the play/pause actions where a first "next" is starting a video the next "next" stops it and the following one e.g. changes slide. This is indeed very convenient and was a motivation (outside SVG animations) of my animation code. Overall, I would like to integrate at best, using subslides (with countNested=false) and deck.events.js. Cheers |
Hey @twitwi, a couple quick responses:
No, the async load would not prevent the window.load. If you want to prevent the user from navigating a deck until all the SVGs load, it's quite possible. You would bind an event to prevent all deck movement (via beforeChange in the future, change right now). Then create a counter equal to the number of SVG animation slides. jquery-svg provides an onLoad callback for each SVG load, so in that callback you would decrement that counter and then check if it is equal to 0. When it hits 0 that means all the SVGs have loaded, and you can then unbind the prevent function, allowing movement again. If that sounds as confusing in text as I think it does, let me know and I can post an example gist.
You just redefine the defaults for both: $.extend(true, $.deck.defaults, {
keys: {
next: [...],
previous: [...],
skipNext: [...],
skipPrev: [...]
}
}); I'm going to close this ticket out right now, and open one specifically about implementing |
Hi,
As quickly mentioned on the mailing list, I extended deck.js to allow for interesting animation-like extensions.
An demo of such extension (SVG animations) can be found there:
http://home.heeere.com/data/deck-js-demo/examples/svg-animations.html
This pull-request offers the cleaned version of my changes.
Feel free to pull it (or not) or to discuss it.
Thanks,
Rémi