Closed krnlde closed 11 years ago
Thanks! It's such a great feeling to know your work is appreciated. :)
At present, Revolver is not able to do this, but it's an awesome suggestion! Currently that code is managed in the constructor so all that's needed is to extract that logic and encapsulate it inside a new method, say rebuild(), or something like that.
There's also some other things to consider. Like what happens to the current state of the slider when the slider is rebuilt? And I have to do it in Mootools and jQuery.
I'm going to leave this issue open for now, and I'll try to get to this as soon as I can.
what about .update(); or alternatively implement it like Jquery.live() like in the click event:
$('#button1').live('click', function(e) {});
You would get something like this:
$('#revolver').live('revolver', {/* options */});
Idk exactly, but It's a suggestion though.
The current state (slide) should be preserved, all others may change and the index has to scale accordingly.
Yeah, .update() is probably a better name for this.
I don't like the .live('revolver') idea at all though. Live() is meant for delegating browser events, not updating an instance of a plugin. Nice try though. :)
I agree about preserving the current slide and state. Now I just have to pick my brain about the best way to implement all this in both frameworks.
Happy coding dude :)
So for now this is how you would add a new slide:
$my_slider = $('#my_slider');
$my_new_slide = $('#my_new_slide');
// instantiate revolver
my_slider = new Revolver($my_slider);
// ... then, at some point in the future,
// add the new slide to the slider ...
$my_slider.append($my_new_slide); // update dom
my_slider.addSlide($my_new_slide); // update revolver instance
The addSlide()
method will accept a jQuery object (like shown above) or a plain 'ol HTMLElement object; Your choice.
Hey Johnny!
At first congrats for this very nice and easy-to-use slider! I like it.
Second, is it possible to live-insert new slides? revolver.reset() and revolver.restart() doesn't provide this ability. It would be great for async data like twitter feeds.
Greets, krnl