-
Notifications
You must be signed in to change notification settings - Fork 444
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
deck.slide(-1) should go to last slide #59
Comments
wdyt @markdalgleish? Should we add this convenience or is this just something plugin authors need to live with? I don't want to add unnecessary bloat to bespoke.js core, so if you think we can live without this API, I'm willing to accept that. |
I agree with you @mojavelinux, I think this could be helpful. This helper was present is DZslides 😉 |
I'm pretty sure I got the idea from DZSlides (or, perhaps I should say, DZSlides had spoiled me). One of the key arguments for this change is that it really starts to add up across a collection of plugins. The property "length" doesn't get minimized, and it takes two steps to get to it. And many plugins have this somewhere in the code. (That may even be a strong case for "first" and "last" methods, though those are harder to work with in dynamic code). |
We would need something like this then : deck = {
on: on,
off: off,
fire: fire,
slide: slide,
next: step.bind(null, 1),
prev: step.bind(null, -1),
// new helpers here :
first: slide.bind(null, 0),
last: function () {
deck.slide(deck.slides.length - 1);
},
// new helpers !
slides: slides
}; I think that this way, it would be truly dynamic. |
Or as you proposed, we do not add new helpers and we just use 0 and -1. This would require to update We would need something like this then : activate = function(index, customData) {
if (index === -1) {
index = deck.slides.length - 1;
}
else if (!slides[index]) {
return;
}
fire('deactivate', createEventData(activeSlide, customData));
activeSlide = slides[index];
fire('activate', createEventData(activeSlide, customData));
}, |
To make life for plugin authors simpler, it would be nice if
deck.slide(-1)
went to the last slide to avoid having to constantly type:If this isn't acceptable, a reasonable compromise might be to add a
deck.end()
method to advance to the last slide.The text was updated successfully, but these errors were encountered: