Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
xuying.xu committed Apr 26, 2024
1 parent 0a8189c commit 3d0e6d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
5 changes: 2 additions & 3 deletions packages/f-engine/src/canvas/render/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,14 @@ function updateAnimation(nextNode, lastNode, keyFrame?: any) {
children: nextChildren,
props: nextProps,
shape: nextShape,
// animator,
animate,
} = nextNode;
const {
tag: lastTag,
type: lastType,
style: lastStyle,
children: lastChildren,
shape: lastShape
shape: lastShape,
} = lastNode;
const animator = keyFrame ? new Animator() : nextNode.animator
animator.reset(nextShape);
Expand Down Expand Up @@ -337,7 +336,7 @@ function insertShape(parent: DisplayObject, shape: DisplayObject, nextSibling: I
function createAnimation(
parent: VNode,
nextChildren: VNode | VNode[],
lastChildren: VNode | VNode[]
lastChildren: VNode | VNode[],
) {
if (!nextChildren && !lastChildren) {
return [];
Expand Down
12 changes: 6 additions & 6 deletions packages/f-engine/src/canvas/render/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ function readComponentContext(vNodeType: ElementType, vNodeContext) {
}

function createVNode(parent: VNode, vNode: VNode) {
const { canvas, context: parentContext, updater, animate: parentAnimate, animator: parentAnimator } = parent;
const { canvas, context: parentContext, updater, animate: parentAnimate } = parent;

const { ref, type, props: originProps } = vNode;
const { animate, transformFrom, effect, ...props } = originProps;
const { animate, transformFrom, ...props } = originProps;

const tag = getWorkTag(type);
const context = readVNodeContext(type, parentContext);
Expand Down Expand Up @@ -149,10 +149,10 @@ function createVNode(parent: VNode, vNode: VNode) {
}

function updateVNode(parent, nextNode: VNode, lastNode: VNode) {
const { canvas, context, updater, animate: parentAnimate, animator: parentAnimator } = parent;
const { tag, animator, component, shape, children, props: lastProps } = lastNode;
const { canvas, context, updater, animate: parentAnimate } = parent;
const { tag, component, shape, children, props: lastProps } = lastNode;
const { type, props } = nextNode;
const { animate, effect } = props;
const { animate } = props;

// animator.vNode = nextNode;
nextNode.parent = parent;
Expand Down Expand Up @@ -206,7 +206,7 @@ function destroyElement(vNode: VNode | VNode[] | null) {
});
}

function updateElement(parent: VNode, nextElement: JSX.Element, lastElement: VNode, mode?: string) {
function updateElement(parent: VNode, nextElement: JSX.Element, lastElement: VNode) {
const { type: nextType, props: nextProps } = nextElement;
const { type: lastType, props: lastProps } = lastElement;

Expand Down
21 changes: 5 additions & 16 deletions packages/f-engine/src/canvas/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import EE from 'eventemitter3';
type AnimaUnit = {
childrenAnimation: Animator[];
totalTime: number;
// effect: {
// duration: number;
// delay: number;
// }
}
class Timeline extends EE {
animator: Animator;
Expand Down Expand Up @@ -38,30 +34,24 @@ class Timeline extends EE {
}
this.drawFrame();
animator.on('end', this.next);
this.run();
this.animator.run();
this.setPlayState(playState);
}

next = () => {
const { frame, playState, endFrame, animators } = this;
const { frame, playState, endFrame } = this;
if (playState !== "play") return

this.frame = frame + 1;
if (frame < endFrame) {
this.drawFrame();
this.run();
this.animator.run();
} else {
this.emit('end');
this.playState = "finish"
}
};

private run() {
const { animator, frame, animators } = this;
// const { effect } = animators[frame]
animator.run();
}


drawFrame() {
const { animator, animators, frame } = this;
Expand Down Expand Up @@ -95,12 +85,11 @@ class Timeline extends EE {
updateState(nextProps) {
// 播放状态不同
const { state } = nextProps;
const { animator } = this;
if (state === "finish") {

this.frame = this.endFrame
this.drawFrame();
this.run()
this.animator.run()
}
this.playState = state
this.setPlayState(state)
Expand Down Expand Up @@ -128,7 +117,7 @@ class Timeline extends EE {
if (frame !== target) {
this.frame = target
this.drawFrame()
this.run();
this.animator.run();
this.setPlayState(playState)
}
console.log(time)
Expand Down

0 comments on commit 3d0e6d3

Please sign in to comment.