threesixty-slider icon indicating copy to clipboard operation
threesixty-slider copied to clipboard

Slider freezes on first slide when disableWrap option is set to true

Open joshas opened this issue 9 years ago • 2 comments

Using latest version from repository (2.0.5). Added option disableWrap: true. When spinning with autoplay or manually, slider freezes on reaching first image. Error message:

TypeError: f[e.getNormalizedCurrentFrame(...)] is undefined

Here's an example to quickly reproduce this issue: https://jsfiddle.net/joshas/5vaenw0s/2/

Frames array is being accessed using values starting from 1, not from 0.

joshas avatar Nov 26 '15 19:11 joshas

Hey, I fixed it by doing this onReady callback

onReady: function(){ this.currentFrame = 52; this.endFrame = 52; }

MolloKhan avatar Apr 06 '16 18:04 MolloKhan

@larzuk91's suggestion didn't work either. I fixed this by replacing the function:

base.getNormalizedCurrentFrame = function () {
  var c, e;

  if ( !AppConfig.disableWrap ) {
    c = Math.ceil(AppConfig.currentFrame % AppConfig.totalFrames);
    if (c < 0) {
      c += AppConfig.totalFrames - (AppConfig.zeroBased ? 1 : 0);
    }
  } else {
    c = Math.min(AppConfig.currentFrame, AppConfig.totalFrames - (AppConfig.zeroBased ? 1 : 0));
    e = Math.min(AppConfig.endFrame, AppConfig.totalFrames - (AppConfig.zeroBased ? 1 : 0));
    c = Math.max(c, (AppConfig.zeroBased ? 0 : 1));
    e = Math.max(e, (AppConfig.zeroBased ? 0 : 1));
    if (c == AppConfig.totalFrames) {
      c--;
    }
    AppConfig.currentFrame = c;
    AppConfig.endFrame = e;
  }
  return c;
};

vemacs avatar Jun 14 '16 02:06 vemacs