RLottie change render flow (curFrame)
This commit is contained in:
parent
add128017f
commit
f4fa88308c
@ -179,11 +179,13 @@ export class RLottiePlayer extends EventListenerBase<{
|
|||||||
this.setMainLoop();
|
this.setMainLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public pause() {
|
public pause(clearPendingRAF = true) {
|
||||||
if(this.paused) return;
|
if(this.paused) return;
|
||||||
|
|
||||||
this.paused = true;
|
this.paused = true;
|
||||||
clearTimeout(this.rafId);
|
if(clearPendingRAF) {
|
||||||
|
clearTimeout(this.rafId);
|
||||||
|
}
|
||||||
//window.cancelAnimationFrame(this.rafId);
|
//window.cancelAnimationFrame(this.rafId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,38 +294,34 @@ export class RLottiePlayer extends EventListenerBase<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private mainLoopForwards() {
|
private mainLoopForwards() {
|
||||||
const frame = this.curFrame;
|
const frame = this.curFrame >= this.frameCount ? this.curFrame = 0 : this.curFrame += this.skipDelta;
|
||||||
this.curFrame += this.skipDelta;
|
//console.log('mainLoopForwards', this.curFrame, this.skipDelta, frame);
|
||||||
|
|
||||||
this.requestFrame(frame);
|
this.requestFrame(frame);
|
||||||
if(this.curFrame >= this.frameCount) {
|
if((frame + this.skipDelta) >= this.frameCount) {
|
||||||
//this.playedTimes++;
|
//this.playedTimes++;
|
||||||
|
|
||||||
if(!this.loop) {
|
if(!this.loop) {
|
||||||
this.pause();
|
this.pause(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.curFrame = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private mainLoopBackwards() {
|
private mainLoopBackwards() {
|
||||||
const frame = this.curFrame;
|
const frame = this.curFrame < 0 ? this.curFrame = this.frameCount - 1 : this.curFrame -= this.skipDelta;
|
||||||
this.curFrame -= this.skipDelta;
|
//console.log('mainLoopBackwards', this.curFrame, this.skipDelta, frame);
|
||||||
|
|
||||||
this.requestFrame(frame);
|
this.requestFrame(frame);
|
||||||
if(this.curFrame < 0) {
|
if((frame - this.skipDelta) < 0) {
|
||||||
//this.playedTimes++;
|
//this.playedTimes++;
|
||||||
|
|
||||||
if(!this.loop) {
|
if(!this.loop) {
|
||||||
this.pause();
|
this.pause(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.curFrame = this.frameCount - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user