feat:fix Android animation problem

This commit is contained in:
pengfei.zhou 2019-11-29 20:47:42 +08:00
parent 7e8708a73b
commit 6b4bc9cd0f
3 changed files with 24 additions and 1 deletions

View File

@ -281,6 +281,7 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
} else { } else {
setScaleX(prop.asNumber().toFloat()); setScaleX(prop.asNumber().toFloat());
} }
break;
case "scaleY": case "scaleY":
if (isAnimating()) { if (isAnimating()) {
addAnimator(ObjectAnimator.ofFloat( addAnimator(ObjectAnimator.ofFloat(
@ -291,6 +292,7 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
} else { } else {
setScaleY(prop.asNumber().toFloat()); setScaleY(prop.asNumber().toFloat());
} }
break;
case "pivotX": case "pivotX":
if (isAnimating()) { if (isAnimating()) {
addAnimator(ObjectAnimator.ofFloat( addAnimator(ObjectAnimator.ofFloat(

View File

@ -17,6 +17,7 @@ function thisLabel(str: string) {
class AnimatorDemo extends Panel { class AnimatorDemo extends Panel {
build(rootView: Group): void { build(rootView: Group): void {
const view = box(2) const view = box(2)
const view2 = box(3)
let idx = 0 let idx = 0
vlayout([ vlayout([
title("Animator zDemo"), title("Animator zDemo"),
@ -54,6 +55,7 @@ class AnimatorDemo extends Panel {
animations: () => { animations: () => {
view.x = view.x || 0 view.x = view.x || 0
view.x += 100 view.x += 100
view2.x += 50
}, },
duration: 1000, duration: 1000,
}) })
@ -65,6 +67,7 @@ class AnimatorDemo extends Panel {
animations: () => { animations: () => {
view.y = view.y || 0 view.y = view.y || 0
view.y += 100 view.y += 100
view2.y += 50
}, },
duration: 1000, duration: 1000,
}) })
@ -165,7 +168,7 @@ class AnimatorDemo extends Panel {
] ]
).apply({ space: 10 } as IVLayout), ).apply({ space: 10 } as IVLayout),
stack([ stack([
view view,
]).apply({ ]).apply({
layoutConfig: layoutConfig().atmost(), layoutConfig: layoutConfig().atmost(),
bgColor: colors[1].alpha(0.3 * 255), bgColor: colors[1].alpha(0.3 * 255),

View File

@ -20,9 +20,27 @@ export enum RepeatMode {
} }
export class Animation { export class Animation {
translationX?: number
translationY?: number
scaleX?: number
scaleY?: number
pivotX?: number
pivotY?: number
rotation?: number
duration = 100 duration = 100
startDelay = 0 startDelay = 0
repeatCount = 1 repeatCount = 1
repeatMode = RepeatMode.RESTART repeatMode = RepeatMode.RESTART
} }