[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:
Kevin Lubick 2018-08-29 13:52:10 -04:00
parent 273b74a858
commit 085e8ea15b

View File

@ -59,9 +59,7 @@
// Once the first tile is loaded, calculate what
// the filmstrip should look like.
let animationData = anim.animationData;
let inPoint = (anim.animationData.ip || 0);
let outPoint = (anim.animationData.op || (anim.animationData.totalFrames));
let totalFrames = anim.totalFrames;
// t_rate mimics DMSrcSink.cpp::SkottieSrc::draw
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 seekToFrame = inPoint + t * (outPoint - inPoint);
if (seekToFrame >= outPoint) {
let seekToFrame = totalFrames * t;
if (seekToFrame >= totalFrames) {
// bodymovin player sometimes draws blank when requesting
// to draw the very last frame. Subtracting a small value
// 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.