Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: destroy call on null player #92

Merged
merged 2 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.6.1

### Patch Changes

- fixed stop error, added playOnce to scroll

## 1.6.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@lottiefiles/lottie-interactivity",
"description": "This is a small effects and interactivity library written to be paired with the Lottie Web Player",
"version": "1.6.0",
"version": "1.6.1",
"license": "MIT",
"main": "./dist/lottie-interactivity.min.js",
"module": "./dist/lottie-interactivity.es.js",
Expand Down
18 changes: 14 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ export class LottieInteractivity {
}
}
}
this.player = null;
if (this.player) {
this.player.destroy();
this.player = null;
}
}

/**
Expand Down Expand Up @@ -742,7 +745,6 @@ export class LottieInteractivity {
} else {
if (window.lottie) {
this.stop();
this.player.destroy();
// Removes svg animation contained inside
this.container.innerHTML = "";

Expand Down Expand Up @@ -938,16 +940,24 @@ export class LottieInteractivity {
}
}
}
} else if (action.type === 'play') {
} else if (action.type === 'play' || action.type === 'playOnce') {
// Play: Reset segments and continue playing full animation from current position
if (!this.scrolledAndPlayed) {
if (action.type === 'playOnce' && !this.scrolledAndPlayed) {
this.scrolledAndPlayed = true;
this.player.resetSegments(true);
if (action.frames) {
this.player.playSegments(action.frames, true);
} else {
this.player.play();
}
return;
} else if (action.type === 'play' && this.player.isPaused) {
this.player.resetSegments(true);
if (action.frames) {
this.player.playSegments(action.frames, true);
} else {
this.player.play();
}
}
} else if (action.type === 'stop') {
// Stop: Stop playback
Expand Down
4 changes: 2 additions & 2 deletions tests/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ <h3 class="font-bold font-lf-bold text-3xl md:text-4xl text-center leading-norma
<div class="w-full md:w-1/2 mx-auto">
<pre class="prettyprint lang-javascript" style="overflow: scroll;">
LottieInteractivity.create({
mode:"cursor",
mode:"scroll",
player:'#twelfthLottie',
actions: [{
visibility: [0.50, 1.0],
Expand Down Expand Up @@ -474,7 +474,7 @@ <h3 class="font-bold font-lf-bold text-3xl md:text-4xl text-center leading-norma
<div class="w-full md:w-1/2 mx-auto">
<pre class="prettyprint lang-javascript" style="overflow: scroll;">
LottieInteractivity.create({
mode:"cursor",
mode:"scroll",
player:'#twelfthLottie',
actions: [{
visibility: [0.50, 1.0],
Expand Down