metafizzy / flickity

:leaves: Touch, responsive, flickable carousels
https://flickity.metafizzy.co
7.52k stars 605 forks source link

Change auto-scroll direction left to right? Possible? #974

Closed josh-jeffrey closed 4 years ago

josh-jeffrey commented 5 years ago

Is there a way to change the auto scroll which moves by default, right to left. I see the option rightToLeft, however, it seems that the pagination changes direction and starts from the last slide to first (in reverse), but the scrolling of the image goes the same direction.

Thanks.

desandro commented 4 years ago

Try adding this JS before you initialize Flickity

Flickity.Player.prototype.tick = function() {
  // do not tick if not playing
  if ( this.state != 'playing' ) {
    return;
  }

  var time = this.parent.options.autoPlay;
  // default to 3 seconds
  time = typeof time == 'number' ? time : 3000;
  var _this = this;
  // HACK: reset ticks if stopped and started within interval
  this.clear();
  this.timeout = setTimeout( function() {
    _this.parent.previous( true );
    _this.tick();
  }, time );
};

What I'm doing is re-writing Flickity, changing _this.parent.next() to _this.parent.previous()