From a175d6d226a88e63411f9cd949689bc9277c66a4 Mon Sep 17 00:00:00 2001 From: Afsal Date: Thu, 21 Mar 2024 12:51:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20playback=20ends=20on=20la?= =?UTF-8?q?stFrame?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fix ends playback on lastFrame - 1. --- packages/common/src/dotlottie-player.ts | 2 +- .../cypress/component/interactivity/enable-interactivity.cy.ts | 2 +- .../cypress/component/interactivity/state-toggle.cy.ts | 2 +- .../cypress/component/interactivity/enable-interactivity.cy.tsx | 2 +- .../cypress/component/interactivity/state-toggle.cy.tsx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/common/src/dotlottie-player.ts b/packages/common/src/dotlottie-player.ts index e832d9f9..e306ea6e 100644 --- a/packages/common/src/dotlottie-player.ts +++ b/packages/common/src/dotlottie-player.ts @@ -1564,7 +1564,7 @@ export class DotLottieCommonPlayer { // If loop = number, and animation has reached the end, call stop to go to frame 0 if (typeof this._loop === 'number') this.stop(); - const lastFrame = this.direction === -1 ? 0 : this.totalFrames; + const lastFrame = this.direction === -1 ? 0 : this.totalFrames - 1; this.goToAndStop(lastFrame, true); diff --git a/packages/player-component/cypress/component/interactivity/enable-interactivity.cy.ts b/packages/player-component/cypress/component/interactivity/enable-interactivity.cy.ts index 35b0fff8..047a52ac 100644 --- a/packages/player-component/cypress/component/interactivity/enable-interactivity.cy.ts +++ b/packages/player-component/cypress/component/interactivity/enable-interactivity.cy.ts @@ -53,7 +53,7 @@ describe('Interactivity: enter/exit interactivity', () => { cy.get('[name="currentState"]').should('have.value', PlayerState.Playing); cy.get('[name="loop"]').should('have.value', 'false'); cy.get('[name="autoplay"]').should('have.value', 'false'); - cy.get('[name="frame"]').should('have.value', 30); + cy.get('[name="frame"]').should('have.value', 29); cy.get('[name="speed"]').should('have.value', 1); // State: playReverse diff --git a/packages/player-component/cypress/component/interactivity/state-toggle.cy.ts b/packages/player-component/cypress/component/interactivity/state-toggle.cy.ts index 4a5dd949..9758e4d7 100644 --- a/packages/player-component/cypress/component/interactivity/state-toggle.cy.ts +++ b/packages/player-component/cypress/component/interactivity/state-toggle.cy.ts @@ -40,7 +40,7 @@ describe('Interactivity: state_toggle (onClick)', () => { cy.get('[name="currentState"]').should('have.value', PlayerState.Playing); cy.get('[name="loop"]').should('have.value', "false"); cy.get('[name="autoplay"]').should('have.value', "false"); - cy.get('[name="frame"]').should('have.value', 30); + cy.get('[name="frame"]').should('have.value', 29); // State: playReverse cy.get('[data-testid="testPlayer"]').shadow().find('.animation').click({force:true}); diff --git a/packages/react-player/cypress/component/interactivity/enable-interactivity.cy.tsx b/packages/react-player/cypress/component/interactivity/enable-interactivity.cy.tsx index 1c5b4fa9..ffe7c2c5 100644 --- a/packages/react-player/cypress/component/interactivity/enable-interactivity.cy.tsx +++ b/packages/react-player/cypress/component/interactivity/enable-interactivity.cy.tsx @@ -78,7 +78,7 @@ describe('Interactivity: enter/exit interactivity', () => { cy.get('[name="currentState"]').should('have.value', PlayerState.Playing); cy.get('[name="loop"]').should('have.value', 'false'); cy.get('[name="autoplay"]').should('have.value', 'false'); - cy.get('[name="frame"]').should('have.value', 30); + cy.get('[name="frame"]').should('have.value', 29); cy.get('[name="speed"]').should('have.value', 1); // State: playReverse diff --git a/packages/react-player/cypress/component/interactivity/state-toggle.cy.tsx b/packages/react-player/cypress/component/interactivity/state-toggle.cy.tsx index 4120847d..4a92eefc 100644 --- a/packages/react-player/cypress/component/interactivity/state-toggle.cy.tsx +++ b/packages/react-player/cypress/component/interactivity/state-toggle.cy.tsx @@ -58,7 +58,7 @@ describe('Interactivity: state_toggle (onClick)', () => { cy.get('[name="currentState"]').should('have.value', PlayerState.Playing); cy.get('[name="loop"]').should('have.value', 'false'); cy.get('[name="autoplay"]').should('have.value', 'false'); - cy.get('[name="frame"]').should('have.value', 30); + cy.get('[name="frame"]').should('have.value', 29); // State: playReverse cy.get('.animation').click({ force: true });