fixing totalFrames for loops
diff --git a/player/index.html b/player/index.html
index 9dd7192..237fc50 100644
--- a/player/index.html
+++ b/player/index.html
@@ -133,7 +133,7 @@
var animData = {
container: elem,
renderer: 'svg',
- loop: true,
+ loop: false,
autoplay: true,
rendererSettings: {
progressiveLoad:false
@@ -141,7 +141,7 @@
path: 'exports/render/data.json'
};
anim = lottie.loadAnimation(animData);
- //anim.setSpeed(0.1)
+ anim.setSpeed(0.1)
</script>
</body>
diff --git a/player/js/animation/AnimationItem.js b/player/js/animation/AnimationItem.js
index 218885b..4e21856 100644
--- a/player/js/animation/AnimationItem.js
+++ b/player/js/animation/AnimationItem.js
@@ -137,7 +137,7 @@
AnimationItem.prototype.includeLayers = function(data) {
if(data.op > this.animationData.op){
this.animationData.op = data.op;
- this.totalFrames = Math.floor(data.op - this.animationData.ip);
+ this.totalFrames = Math.floor(data.op - this.animationData.ip) - 1;
this.animationData.tf = this.totalFrames;
}
var layers = this.animationData.layers;
@@ -223,7 +223,7 @@
//animData.w = Math.round(animData.w/blitter);
//animData.h = Math.round(animData.h/blitter);
this.animationData = animData;
- this.totalFrames = Math.floor(this.animationData.op - this.animationData.ip);
+ this.totalFrames = Math.floor(this.animationData.op - this.animationData.ip) - 1;
this.animationData.tf = this.totalFrames;
this.renderer.configAnimation(animData);
if(!animData.assets){
@@ -427,9 +427,9 @@
this.setDirection(-1);
}
}
- this.totalFrames = arr[0] - arr[1];
+ this.totalFrames = arr[0] - arr[1] - 1;
this.firstFrame = arr[1];
- this.setCurrentRawFrameValue(this.totalFrames - 0.01);
+ this.setCurrentRawFrameValue(this.totalFrames);
} else if(arr[1] > arr[0]){
if(this.frameModifier < 0){
if(this.playSpeed < 0){
@@ -438,7 +438,7 @@
this.setDirection(1);
}
}
- this.totalFrames = arr[1] - arr[0];
+ this.totalFrames = arr[1] - arr[0] - 1;
this.firstFrame = arr[0];
this.setCurrentRawFrameValue(0);
}
@@ -450,12 +450,12 @@
if (this.currentRawFrame + this.firstFrame < init) {
pendingFrame = init;
} else if (this.currentRawFrame + this.firstFrame > end) {
- pendingFrame = end - init - 0.01;
+ pendingFrame = end - init;
}
}
this.firstFrame = init;
- this.totalFrames = end - init;
+ this.totalFrames = end - init - 1;
if(pendingFrame !== -1) {
this.goToAndStop(pendingFrame,true);
}
@@ -516,13 +516,13 @@
if (this.currentRawFrame >= this.totalFrames) {
this.checkSegments();
if(this.loop === false){
- this.currentRawFrame = this.totalFrames - 0.01;
+ this.currentRawFrame = this.totalFrames;
_completeFlag = true;
}else{
this.trigger('loopComplete');
this.playCount += 1;
if((this.loop !== true && this.playCount == this.loop) || this.pendingSegment){
- this.currentRawFrame = this.totalFrames - 0.01;
+ this.currentRawFrame = this.totalFrames;
_completeFlag = true;
} else {
this.currentRawFrame = this.currentRawFrame % this.totalFrames;