From 3d0e6d325fceac8fb6b90cd5e2858e74322b5c93 Mon Sep 17 00:00:00 2001 From: "xuying.xu" Date: Fri, 26 Apr 2024 10:59:28 +0800 Subject: [PATCH] fix: lint --- .../f-engine/src/canvas/render/animation.ts | 5 ++--- packages/f-engine/src/canvas/render/index.ts | 12 +++++------ packages/f-engine/src/canvas/timeline.ts | 21 +++++-------------- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/packages/f-engine/src/canvas/render/animation.ts b/packages/f-engine/src/canvas/render/animation.ts index 9066568..6fa68e4 100644 --- a/packages/f-engine/src/canvas/render/animation.ts +++ b/packages/f-engine/src/canvas/render/animation.ts @@ -133,7 +133,6 @@ function updateAnimation(nextNode, lastNode, keyFrame?: any) { children: nextChildren, props: nextProps, shape: nextShape, - // animator, animate, } = nextNode; const { @@ -141,7 +140,7 @@ function updateAnimation(nextNode, lastNode, keyFrame?: any) { type: lastType, style: lastStyle, children: lastChildren, - shape: lastShape + shape: lastShape, } = lastNode; const animator = keyFrame ? new Animator() : nextNode.animator animator.reset(nextShape); @@ -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 []; diff --git a/packages/f-engine/src/canvas/render/index.ts b/packages/f-engine/src/canvas/render/index.ts index 4e22230..ea51891 100644 --- a/packages/f-engine/src/canvas/render/index.ts +++ b/packages/f-engine/src/canvas/render/index.ts @@ -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); @@ -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; @@ -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; diff --git a/packages/f-engine/src/canvas/timeline.ts b/packages/f-engine/src/canvas/timeline.ts index 0acfb73..16b9767 100644 --- a/packages/f-engine/src/canvas/timeline.ts +++ b/packages/f-engine/src/canvas/timeline.ts @@ -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; @@ -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; @@ -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) @@ -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)