jcarousel
jcarousel copied to clipboard
Circular mode: prepare -=1 slide?
I've been playing around with circular mode a bit and was wondering if it was possible to make sure one (or more) slides are rendered 'to the left' of the current slide before scrolling?
This would be useful when using 'center', as slides left of the current target should likely be visible (if the current slide is less wide then the viewport):
http://static.trust.at/jcarouseltest/circular.html http://static.trust.at/jcarouseltest/test.html
Sorry if i missed this in the docs...
Yes, i also thought about that. But to be honest, don't expect this to be implemented soon, if ever :)
+1 for this. Could you point me in the right direction to implement this?
Ok, that's too bad, I was hoping this wouldn't be too much of a fix. If you could supply some starting points I would have a look... Thanks.
+1
+1
+1
+1
ran into the same issue and solved it like so: The most interesting bit is in the scroll event where I check if the 'prev' button was clicked, find the last element in the list and prepend it to the carousel. Then I stole the code from the bit that resets the list and dimensions and such.
$('.jcarousel')
.on('jcarousel:targetin', 'li', function() {
$(this).addClass('active');
})
.on('jcarousel:targetout', 'li', function() {
$(this).removeClass('active');
})
.on('jcarousel:createend', function(event, carousel) {
$(this).jcarousel('scroll', 1, false);
})
.on('jcarousel:scroll', function(event, carousel, target, animate) {
if (target == "-=1") {
var $prev = $('.jcarousel ul li').not('.active').last();
carousel.list().prepend($prev);
carousel._items = null;
var dim = carousel.dimension($prev);
props = {};
props[carousel.lt] = -dim;
carousel.moveBy(props);
}
})
.jcarousel({
center: true,
wrap: 'circular'
});
$('.jcarousel-prev').jcarouselControl({
target: '-=1'
});
$('.jcarousel-next').jcarouselControl({
target: '+=1'
});
Not the most elegant, but works well for my purposes
nankrah i was looking for this solution some time, thx. But now I need the same result with pagination bullets, any ideas?
+1
+1