Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): make rotation animatable #13934

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public class TiAnimationBuilder
protected String width = null, height = null;
protected Integer backgroundColor = null;
protected Integer color = null;
protected float rotationY, rotationX = -1;
private float INITIAL_ROTATION = 999999f;
protected float rotationY, rotationX, rotation = INITIAL_ROTATION;
protected TiAnimationCurve curve = TiAnimationBuilder.DEFAULT_CURVE;

protected TiAnimation animationProxy;
Expand Down Expand Up @@ -245,11 +246,15 @@ public void applyOptions(HashMap options)
}

if (options.containsKey(TiC.PROPERTY_ROTATION_Y)) {
rotationY = TiConvert.toFloat(options, TiC.PROPERTY_ROTATION_Y, -1);
rotationY = TiConvert.toFloat(options, TiC.PROPERTY_ROTATION_Y, INITIAL_ROTATION);
}

if (options.containsKey(TiC.PROPERTY_ROTATION_X)) {
rotationX = TiConvert.toFloat(options, TiC.PROPERTY_ROTATION_X, -1);
rotationX = TiConvert.toFloat(options, TiC.PROPERTY_ROTATION_X, INITIAL_ROTATION);
}

if (options.containsKey(TiC.PROPERTY_ROTATION)) {
rotation = TiConvert.toFloat(options, TiC.PROPERTY_ROTATION, INITIAL_ROTATION);
}
this.options = options;
}
Expand Down Expand Up @@ -313,12 +318,15 @@ private AnimatorSet buildPropertyAnimators(int x, int y, int w, int h, int paren
addAnimator(animators, ObjectAnimator.ofFloat(view, "elevation", elevation));
}

if (rotationY >= 0) {
if (rotationY != INITIAL_ROTATION) {
addAnimator(animators, ObjectAnimator.ofFloat(view, "rotationY", rotationY));
}
if (rotationX >= 0) {
if (rotationX != INITIAL_ROTATION) {
addAnimator(animators, ObjectAnimator.ofFloat(view, "rotationX", rotationX));
}
if (rotation != INITIAL_ROTATION) {
addAnimator(animators, ObjectAnimator.ofFloat(view, "rotation", rotation));
}

if (backgroundColor != null) {
View bgView = view;
Expand Down
6 changes: 6 additions & 0 deletions apidoc/Titanium/UI/Animation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ properties:
summary: Duration of the animation, in milliseconds.
type: Number

- name: rotation
summary: Value of the `rotation` property at the end of the animation.
type: Number
platforms: [android]
since: { android: "12.6.0" }

- name: rotationY
summary: Value of the `rotationY` property at the end of the animation.
type: Number
Expand Down
Loading