Merge branch 'feature/animation' into 'master'

Feature/animation



See merge request !38
This commit is contained in:
pengfeizhou 2019-11-29 20:48:37 +08:00
commit a559ba362d
5 changed files with 53 additions and 60 deletions

View File

@ -203,6 +203,17 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
prop.asObject().getProperty("color").asNumber().toInt());
}
break;
case "alpha":
if (isAnimating()) {
addAnimator(ObjectAnimator.ofFloat(
this,
name,
getAlpha(),
prop.asNumber().toFloat()));
} else {
setAlpha(prop.asNumber().toFloat());
}
break;
case "corners":
if (prop.isNumber()) {
if (isAnimating()) {
@ -270,6 +281,7 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
} else {
setScaleX(prop.asNumber().toFloat());
}
break;
case "scaleY":
if (isAnimating()) {
addAnimator(ObjectAnimator.ofFloat(
@ -280,6 +292,7 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
} else {
setScaleY(prop.asNumber().toFloat());
}
break;
case "pivotX":
if (isAnimating()) {
addAnimator(ObjectAnimator.ofFloat(
@ -313,28 +326,6 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
setRotation(prop.asNumber().toFloat());
}
break;
case "rotationX":
if (isAnimating()) {
addAnimator(ObjectAnimator.ofFloat(
this,
name,
getRotationX(),
prop.asNumber().toFloat()));
} else {
setRotationX(prop.asNumber().toFloat());
}
break;
case "rotationY":
if (isAnimating()) {
addAnimator(ObjectAnimator.ofFloat(
this,
name,
getRotationY(),
prop.asNumber().toFloat()));
} else {
setRotationY(prop.asNumber().toFloat());
}
break;
default:
break;
}
@ -540,6 +531,16 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
mView.setBackgroundColor(color);
}
@DoricMethod
public void setAlpha(float alpha) {
getNodeView().setAlpha(alpha);
}
@DoricMethod
public float getAlpha() {
return getNodeView().getAlpha();
}
@DoricMethod
public void setCorners(float corner) {
requireDoricLayer().setCornerRadius(DoricUtils.dp2px(corner));
@ -601,26 +602,6 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
return getNodeView().getRotation() / 180;
}
@DoricMethod
public void setRotationX(float rotation) {
getNodeView().setRotationX(rotation * 180);
}
@DoricMethod
public float getRotationX() {
return getNodeView().getRotationX() / 180;
}
@DoricMethod
public void setRotationY(float rotation) {
getNodeView().setRotationY(rotation * 180);
}
@DoricMethod
public float getRotationY() {
return getNodeView().getRotationY() / 180;
}
@DoricMethod
public void setPivotX(float v) {
getNodeView().setPivotX(v * getNodeView().getWidth());

View File

@ -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),

View File

@ -73,8 +73,6 @@ @interface DoricViewNode ()
@property(nonatomic, copy) NSNumber *scaleX;
@property(nonatomic, copy) NSNumber *scaleY;
@property(nonatomic, copy) NSNumber *rotation;
@property(nonatomic, copy) NSNumber *rotationX;
@property(nonatomic, copy) NSNumber *rotationY;
@property(nonatomic, copy) NSNumber *pivotX;
@property(nonatomic, copy) NSNumber *pivotY;
@end
@ -152,6 +150,8 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
view.y = [(NSNumber *) prop floatValue];
} else if ([name isEqualToString:@"bgColor"]) {
view.backgroundColor = DoricColor(prop);
} else if ([name isEqualToString:@"alpha"]) {
view.alpha = [prop floatValue];
} else if ([name isEqualToString:@"layoutConfig"]) {
if (self.superNode && [prop isKindOfClass:[NSDictionary class]]) {
[self.superNode blendSubNode:self layoutConfig:prop];
@ -222,10 +222,6 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
self.pivotY = prop;
} else if ([name isEqualToString:@"rotation"]) {
self.rotation = prop;
} else if ([name isEqualToString:@"rotationX"]) {
self.rotationX = prop;
} else if ([name isEqualToString:@"rotationY"]) {
self.rotationY = prop;
} else {
DoricLog(@"Blend View error for View Type :%@, prop is %@", self.class, name);
}

View File

@ -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
}

View File

@ -31,6 +31,9 @@ export interface IView {
corners?: number | { leftTop?: number; rightTop?: number; leftBottom?: number; rightBottom?: number }
border?: { width: number; color: Color; }
shadow?: { color: Color; opacity: number; radius: number; offsetX: number; offsetY: number }
/**
* float [0,..1]
*/
alpha?: number
hidden?: boolean
padding?: {
@ -59,12 +62,10 @@ export interface IView {
* float [0,..1]
*/
pivotY?: number
/**
* rotation*PI
*/
rotation?: number
rotationX?: number
rotationY?: number
/**----------transform----------*/
}
@ -331,12 +332,6 @@ export abstract class View implements Modeling, IView {
@Property
rotation?: number
@Property
rotationX?: number
@Property
rotationY?: number
/**----------transform----------*/
}