Merge branch 'feature/animation' into 'master'
Feature/animation See merge request !38
This commit is contained in:
commit
a559ba362d
@ -203,6 +203,17 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
|
|||||||
prop.asObject().getProperty("color").asNumber().toInt());
|
prop.asObject().getProperty("color").asNumber().toInt());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "alpha":
|
||||||
|
if (isAnimating()) {
|
||||||
|
addAnimator(ObjectAnimator.ofFloat(
|
||||||
|
this,
|
||||||
|
name,
|
||||||
|
getAlpha(),
|
||||||
|
prop.asNumber().toFloat()));
|
||||||
|
} else {
|
||||||
|
setAlpha(prop.asNumber().toFloat());
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "corners":
|
case "corners":
|
||||||
if (prop.isNumber()) {
|
if (prop.isNumber()) {
|
||||||
if (isAnimating()) {
|
if (isAnimating()) {
|
||||||
@ -270,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(
|
||||||
@ -280,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(
|
||||||
@ -313,28 +326,6 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
|
|||||||
setRotation(prop.asNumber().toFloat());
|
setRotation(prop.asNumber().toFloat());
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -540,6 +531,16 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
|
|||||||
mView.setBackgroundColor(color);
|
mView.setBackgroundColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DoricMethod
|
||||||
|
public void setAlpha(float alpha) {
|
||||||
|
getNodeView().setAlpha(alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DoricMethod
|
||||||
|
public float getAlpha() {
|
||||||
|
return getNodeView().getAlpha();
|
||||||
|
}
|
||||||
|
|
||||||
@DoricMethod
|
@DoricMethod
|
||||||
public void setCorners(float corner) {
|
public void setCorners(float corner) {
|
||||||
requireDoricLayer().setCornerRadius(DoricUtils.dp2px(corner));
|
requireDoricLayer().setCornerRadius(DoricUtils.dp2px(corner));
|
||||||
@ -601,26 +602,6 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
|
|||||||
return getNodeView().getRotation() / 180;
|
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
|
@DoricMethod
|
||||||
public void setPivotX(float v) {
|
public void setPivotX(float v) {
|
||||||
getNodeView().setPivotX(v * getNodeView().getWidth());
|
getNodeView().setPivotX(v * getNodeView().getWidth());
|
||||||
|
@ -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),
|
||||||
|
@ -73,8 +73,6 @@ @interface DoricViewNode ()
|
|||||||
@property(nonatomic, copy) NSNumber *scaleX;
|
@property(nonatomic, copy) NSNumber *scaleX;
|
||||||
@property(nonatomic, copy) NSNumber *scaleY;
|
@property(nonatomic, copy) NSNumber *scaleY;
|
||||||
@property(nonatomic, copy) NSNumber *rotation;
|
@property(nonatomic, copy) NSNumber *rotation;
|
||||||
@property(nonatomic, copy) NSNumber *rotationX;
|
|
||||||
@property(nonatomic, copy) NSNumber *rotationY;
|
|
||||||
@property(nonatomic, copy) NSNumber *pivotX;
|
@property(nonatomic, copy) NSNumber *pivotX;
|
||||||
@property(nonatomic, copy) NSNumber *pivotY;
|
@property(nonatomic, copy) NSNumber *pivotY;
|
||||||
@end
|
@end
|
||||||
@ -152,6 +150,8 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
|
|||||||
view.y = [(NSNumber *) prop floatValue];
|
view.y = [(NSNumber *) prop floatValue];
|
||||||
} else if ([name isEqualToString:@"bgColor"]) {
|
} else if ([name isEqualToString:@"bgColor"]) {
|
||||||
view.backgroundColor = DoricColor(prop);
|
view.backgroundColor = DoricColor(prop);
|
||||||
|
} else if ([name isEqualToString:@"alpha"]) {
|
||||||
|
view.alpha = [prop floatValue];
|
||||||
} else if ([name isEqualToString:@"layoutConfig"]) {
|
} else if ([name isEqualToString:@"layoutConfig"]) {
|
||||||
if (self.superNode && [prop isKindOfClass:[NSDictionary class]]) {
|
if (self.superNode && [prop isKindOfClass:[NSDictionary class]]) {
|
||||||
[self.superNode blendSubNode:self layoutConfig:prop];
|
[self.superNode blendSubNode:self layoutConfig:prop];
|
||||||
@ -222,10 +222,6 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
|
|||||||
self.pivotY = prop;
|
self.pivotY = prop;
|
||||||
} else if ([name isEqualToString:@"rotation"]) {
|
} else if ([name isEqualToString:@"rotation"]) {
|
||||||
self.rotation = prop;
|
self.rotation = prop;
|
||||||
} else if ([name isEqualToString:@"rotationX"]) {
|
|
||||||
self.rotationX = prop;
|
|
||||||
} else if ([name isEqualToString:@"rotationY"]) {
|
|
||||||
self.rotationY = prop;
|
|
||||||
} else {
|
} else {
|
||||||
DoricLog(@"Blend View error for View Type :%@, prop is %@", self.class, name);
|
DoricLog(@"Blend View error for View Type :%@, prop is %@", self.class, name);
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,9 @@ export interface IView {
|
|||||||
corners?: number | { leftTop?: number; rightTop?: number; leftBottom?: number; rightBottom?: number }
|
corners?: number | { leftTop?: number; rightTop?: number; leftBottom?: number; rightBottom?: number }
|
||||||
border?: { width: number; color: Color; }
|
border?: { width: number; color: Color; }
|
||||||
shadow?: { color: Color; opacity: number; radius: number; offsetX: number; offsetY: number }
|
shadow?: { color: Color; opacity: number; radius: number; offsetX: number; offsetY: number }
|
||||||
|
/**
|
||||||
|
* float [0,..1]
|
||||||
|
*/
|
||||||
alpha?: number
|
alpha?: number
|
||||||
hidden?: boolean
|
hidden?: boolean
|
||||||
padding?: {
|
padding?: {
|
||||||
@ -59,12 +62,10 @@ export interface IView {
|
|||||||
* float [0,..1]
|
* float [0,..1]
|
||||||
*/
|
*/
|
||||||
pivotY?: number
|
pivotY?: number
|
||||||
|
/**
|
||||||
|
* rotation*PI
|
||||||
|
*/
|
||||||
rotation?: number
|
rotation?: number
|
||||||
|
|
||||||
rotationX?: number
|
|
||||||
|
|
||||||
rotationY?: number
|
|
||||||
/**----------transform----------*/
|
/**----------transform----------*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,12 +332,6 @@ export abstract class View implements Modeling, IView {
|
|||||||
|
|
||||||
@Property
|
@Property
|
||||||
rotation?: number
|
rotation?: number
|
||||||
|
|
||||||
@Property
|
|
||||||
rotationX?: number
|
|
||||||
|
|
||||||
@Property
|
|
||||||
rotationY?: number
|
|
||||||
/**----------transform----------*/
|
/**----------transform----------*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user