threesixty-slider
threesixty-slider copied to clipboard
Slider freezes on first slide when disableWrap option is set to true
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.
Hey, I fixed it by doing this onReady callback
onReady: function(){ this.currentFrame = 52; this.endFrame = 52; }
@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;
};