From 6b4bc9cd0f77daa0e2b5dae9447800078890c32d Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 29 Nov 2019 20:47:42 +0800 Subject: [PATCH] feat:fix Android animation problem --- .../main/java/pub/doric/shader/ViewNode.java | 2 ++ demo/src/AnimatorDemo.ts | 5 ++++- js-framework/src/ui/animation.ts | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Android/doric/src/main/java/pub/doric/shader/ViewNode.java b/Android/doric/src/main/java/pub/doric/shader/ViewNode.java index 7fd377aa..ac2283ae 100644 --- a/Android/doric/src/main/java/pub/doric/shader/ViewNode.java +++ b/Android/doric/src/main/java/pub/doric/shader/ViewNode.java @@ -281,6 +281,7 @@ public abstract class ViewNode extends DoricContextHolder { } else { setScaleX(prop.asNumber().toFloat()); } + break; case "scaleY": if (isAnimating()) { addAnimator(ObjectAnimator.ofFloat( @@ -291,6 +292,7 @@ public abstract class ViewNode extends DoricContextHolder { } else { setScaleY(prop.asNumber().toFloat()); } + break; case "pivotX": if (isAnimating()) { addAnimator(ObjectAnimator.ofFloat( diff --git a/demo/src/AnimatorDemo.ts b/demo/src/AnimatorDemo.ts index dd86961d..27dca175 100644 --- a/demo/src/AnimatorDemo.ts +++ b/demo/src/AnimatorDemo.ts @@ -17,6 +17,7 @@ function thisLabel(str: string) { class AnimatorDemo extends Panel { build(rootView: Group): void { const view = box(2) + const view2 = box(3) let idx = 0 vlayout([ title("Animator zDemo"), @@ -54,6 +55,7 @@ class AnimatorDemo extends Panel { animations: () => { view.x = view.x || 0 view.x += 100 + view2.x += 50 }, duration: 1000, }) @@ -65,6 +67,7 @@ class AnimatorDemo extends Panel { animations: () => { view.y = view.y || 0 view.y += 100 + view2.y += 50 }, duration: 1000, }) @@ -165,7 +168,7 @@ class AnimatorDemo extends Panel { ] ).apply({ space: 10 } as IVLayout), stack([ - view + view, ]).apply({ layoutConfig: layoutConfig().atmost(), bgColor: colors[1].alpha(0.3 * 255), diff --git a/js-framework/src/ui/animation.ts b/js-framework/src/ui/animation.ts index 1a5d753a..1cbadb59 100644 --- a/js-framework/src/ui/animation.ts +++ b/js-framework/src/ui/animation.ts @@ -20,9 +20,27 @@ export enum RepeatMode { } export class Animation { + + translationX?: number + + translationY?: number + + scaleX?: number + + scaleY?: number + + pivotX?: number + + pivotY?: number + + rotation?: number + duration = 100 + startDelay = 0 + repeatCount = 1 + repeatMode = RepeatMode.RESTART }