Skip to content

Commit

Permalink
fix: 初始time不生效
Browse files Browse the repository at this point in the history
  • Loading branch information
xuying.xu committed Jun 27, 2024
1 parent 33713d7 commit 0b1c60b
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/f-engine/src/canvas/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Timeline extends EE {

constructor(props) {
super();
const { animUnits, playState, root, speed = 1, goto } = props;
const { animUnits, playState, root, speed = 1, time } = props;
this.animator = new Animator();
const rootShape = new Group();
this.animator.reset(rootShape);
Expand All @@ -28,7 +28,7 @@ class Timeline extends EE {
this.playState = playState;
this.endFrame = animUnits.length - 1;
this.speed = speed;
this.time = goto;
this.time = time;
}

start() {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 85 additions & 0 deletions packages/f-engine/test/timeline/player.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,89 @@ describe('clip animation', () => {

expect(context).toMatchImageSnapshot();
});

it('跳转超出总时长', async () => {
const context = createContext('跳转超出总时长');

//结束后重播
const { props } = (
<Canvas context={context}>
<Player
state="finish"
keyFrames={[
{
view: {
to: {
visible: true,
},
duration: 1000,
},
},
]}
>
<View key={'view'} visible={false} />
</Player>
</Canvas>
);

const canvas = new Canvas(props);
await canvas.render();
await delay(100);

const { props: newProps } = (
<Canvas context={context}>
<Player
state="pause"
goTo={1200}
keyFrames={[
{
view: {
to: {
visible: true,
},
duration: 1000,
},
},
]}
>
<View key={'view'} visible={false} />
</Player>
</Canvas>
);

await canvas.update(newProps);
await delay(100);
expect(context).toMatchImageSnapshot();
});

it('暂停', async () => {
const context = createContext('暂停');

const { props } = (
<Canvas context={context}>
<Player
state="pause"
goTo={200}
keyFrames={[
{
view: {
to: {
visible: true,
},
duration: 1000,
},
},
]}
>
<View key={'view'} visible={false} />
</Player>
</Canvas>
);

const canvas = new Canvas(props);
await canvas.render();
await delay(100);

expect(context).toMatchImageSnapshot();
});
});

0 comments on commit 0b1c60b

Please sign in to comment.