Skip to content

Commit

Permalink
fix: 动画闪烁问题 (#232)
Browse files Browse the repository at this point in the history
Co-authored-by: xuying.xu <[email protected]>
  • Loading branch information
tangying1027 and xuying.xu authored Sep 14, 2023
1 parent 02f9577 commit d17c9eb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/f-engine/src/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ class Player extends Component<PlayerProps> {
}

didMount(): void {
const { animator } = this;
const { animator, props } = this;
const { state } = props;
animator.on('end', this.next);
if (state === 'finish') {
this.setState(({ count }) => ({
index: count - 1,
}));
}
}

willUpdate(): void {
Expand All @@ -77,8 +83,9 @@ class Player extends Component<PlayerProps> {

next = () => {
const { index, count } = this.state;
const { onend = () => {} } = this.props;
if (index < count - 1) {
const { onend = () => {}, state } = this.props;

if (index < count - 1 && state === 'play') {
this.setState(() => ({
index: index + 1,
}));
Expand Down

0 comments on commit d17c9eb

Please sign in to comment.