Skip to content

Commit

Permalink
Merge pull request #92 from LottieFiles/fix/err-on-react
Browse files Browse the repository at this point in the history
Fix: destroy call on null player
  • Loading branch information
samuelOsborne authored Jul 11, 2022
2 parents 9a72cd0 + c6debc2 commit 7fc80bf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
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

0 comments on commit 7fc80bf

Please sign in to comment.