[LottieWeb] Fix frames
goToAndStop() apparently just counts from frame 0 to frame n, so no need to do complicated in/out stuff. Bug: skia: Change-Id: Ia9c9e2b29377ea0f41fee72a6f0677e236ebcedc Reviewed-on: https://skia-review.googlesource.com/150360 Reviewed-by: Kevin Lubick <kjlubick@google.com>
This commit is contained in:
parent
273b74a858
commit
085e8ea15b
@ -59,9 +59,7 @@
|
|||||||
// Once the first tile is loaded, calculate what
|
// Once the first tile is loaded, calculate what
|
||||||
// the filmstrip should look like.
|
// the filmstrip should look like.
|
||||||
let animationData = anim.animationData;
|
let animationData = anim.animationData;
|
||||||
|
let totalFrames = anim.totalFrames;
|
||||||
let inPoint = (anim.animationData.ip || 0);
|
|
||||||
let outPoint = (anim.animationData.op || (anim.animationData.totalFrames));
|
|
||||||
// t_rate mimics DMSrcSink.cpp::SkottieSrc::draw
|
// t_rate mimics DMSrcSink.cpp::SkottieSrc::draw
|
||||||
let t_rate = 1.0 / (TILE_COUNT * TILE_COUNT - 1);
|
let t_rate = 1.0 / (TILE_COUNT * TILE_COUNT - 1);
|
||||||
|
|
||||||
@ -96,12 +94,12 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
let t = Math.max(Math.min(t_rate * i, 1.0), 0.0);
|
let t = Math.max(Math.min(t_rate * i, 1.0), 0.0);
|
||||||
let seekToFrame = inPoint + t * (outPoint - inPoint);
|
let seekToFrame = totalFrames * t;
|
||||||
if (seekToFrame >= outPoint) {
|
if (seekToFrame >= totalFrames) {
|
||||||
// bodymovin player sometimes draws blank when requesting
|
// bodymovin player sometimes draws blank when requesting
|
||||||
// to draw the very last frame. Subtracting a small value
|
// to draw the very last frame. Subtracting a small value
|
||||||
// seems to fix this and make it draw the last frame.
|
// seems to fix this and make it draw the last frame.
|
||||||
seekToFrame -= .1;
|
seekToFrame -= .001;
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't need to wait for data_ready because it's instantly ready.
|
// don't need to wait for data_ready because it's instantly ready.
|
||||||
|
Loading…
Reference in New Issue
Block a user