Skip to content

Commit

Permalink
fix: 🐛 playback ends on lastFrame
Browse files Browse the repository at this point in the history
This fix ends playback on lastFrame - 1.
  • Loading branch information
afsalz committed Mar 21, 2024
1 parent 2e3cfcb commit a175d6d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/common/src/dotlottie-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down

0 comments on commit a175d6d

Please sign in to comment.