jcarousel icon indicating copy to clipboard operation
jcarousel copied to clipboard

Circular mode: prepare -=1 slide?

Open gl03 opened this issue 12 years ago • 11 comments

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...

gl03 avatar Feb 06 '13 17:02 gl03

Yes, i also thought about that. But to be honest, don't expect this to be implemented soon, if ever :)

jsor avatar Feb 13 '13 15:02 jsor

+1 for this. Could you point me in the right direction to implement this?

NotARobit avatar Feb 19 '13 19:02 NotARobit

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.

gl03 avatar Feb 27 '13 09:02 gl03

+1

JayCarney avatar May 12 '14 05:05 JayCarney

+1

prasmalla avatar Sep 23 '14 14:09 prasmalla

+1

Craigy- avatar Sep 25 '14 11:09 Craigy-

+1

unbrokenclayman avatar Oct 23 '14 10:10 unbrokenclayman

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 avatar Feb 18 '15 01:02 nankrah

nankrah i was looking for this solution some time, thx. But now I need the same result with pagination bullets, any ideas?

ghost avatar Feb 20 '15 09:02 ghost

+1

unused avatar Mar 03 '15 17:03 unused

+1

fgrs avatar Apr 27 '17 18:04 fgrs