From 42b5d20242d7f95a348669e831953cdb6fb2dc4d Mon Sep 17 00:00:00 2001 From: samuelOsborne Date: Mon, 11 Jul 2022 12:35:30 +0200 Subject: [PATCH 1/2] feat: fixed stop method err, added playOnce to scroll --- src/main.js | 18 ++++++++++++++---- tests/public/index.html | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main.js b/src/main.js index 250784a..5a71294 100644 --- a/src/main.js +++ b/src/main.js @@ -272,7 +272,10 @@ export class LottieInteractivity { } } } - this.player = null; + if (this.player) { + this.player.destroy(); + this.player = null; + } } /** @@ -742,7 +745,6 @@ export class LottieInteractivity { } else { if (window.lottie) { this.stop(); - this.player.destroy(); // Removes svg animation contained inside this.container.innerHTML = ""; @@ -938,9 +940,9 @@ 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) { @@ -948,6 +950,14 @@ export class LottieInteractivity { } 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 diff --git a/tests/public/index.html b/tests/public/index.html index 03d86f3..6e83365 100644 --- a/tests/public/index.html +++ b/tests/public/index.html @@ -446,7 +446,7 @@

         LottieInteractivity.create({
-          mode:"cursor",
+          mode:"scroll",
           player:'#twelfthLottie',
           actions: [{
             visibility: [0.50, 1.0],
@@ -474,7 +474,7 @@ 

         LottieInteractivity.create({
-          mode:"cursor",
+          mode:"scroll",
           player:'#twelfthLottie',
           actions: [{
             visibility: [0.50, 1.0],

From c6debc2ee25c874aa4d3e28243327de1bb726da4 Mon Sep 17 00:00:00 2001
From: samuelOsborne 
Date: Mon, 11 Jul 2022 12:37:20 +0200
Subject: [PATCH 2/2] chore: version bump

---
 CHANGELOG.md | 6 ++++++
 package.json | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index e2835b0..ee43129 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
 # Changelog
 
+## 1.6.1
+
+### Patch Changes
+
+- fixed stop error, added playOnce to scroll
+
 ## 1.6.0
 
 ### Minor Changes
diff --git a/package.json b/package.json
index 74768b4..3a05298 100644
--- a/package.json
+++ b/package.json
@@ -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",