Skip to content

Commit

Permalink
added stop method support
Browse files Browse the repository at this point in the history
  • Loading branch information
bodymovin committed Nov 9, 2021
1 parent f50f0fa commit c79773f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions player/js/module_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ function workerContent() {
elements: changedElements,
id: payload.id,
currentTime: event.currentTime,
totalFrames: event.totalFrames,
},
});
});
Expand Down Expand Up @@ -294,6 +293,10 @@ function workerContent() {
if (animations[payload.id]) {
animations[payload.id].play();
}
} else if (type === 'stop') {
if (animations[payload.id]) {
animations[payload.id].stop();
}
} else if (type === 'setSpeed') {
if (animations[payload.id]) {
animations[payload.id].setSpeed(payload.value);
Expand Down Expand Up @@ -460,8 +463,7 @@ var lottie = (function () {
updateElementStyles(element, elementData.styles);
updateElementAttributes(element, elementData.attributes);
}
animation.animInstance.currentTime = payload.currentTime;
animation.animInstance.totalFrames = payload.totalFrames;
animation.animInstance.currentFrame = payload.currentTime;
}
}

Expand Down Expand Up @@ -541,6 +543,14 @@ var lottie = (function () {
},
});
},
stop: function () {
workerInstance.postMessage({
type: 'stop',
payload: {
id: animationId,
},
});
},
setSpeed: function (value) {
workerInstance.postMessage({
type: 'setSpeed',
Expand Down

0 comments on commit c79773f

Please sign in to comment.