mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
refactor: restore animators api usage (#6403)
This commit is contained in:
@ -1,29 +1,28 @@
|
||||
import { Transition, AndroidTransitionType } from "./transition";
|
||||
|
||||
export class FadeTransition extends Transition {
|
||||
public createAndroidAnimation(transitionType: string): android.view.animation.Animation {
|
||||
const alphaValues = [];
|
||||
public createAndroidAnimator(transitionType: string): android.animation.Animator {
|
||||
const alphaValues = Array.create("float", 2);
|
||||
switch (transitionType) {
|
||||
case AndroidTransitionType.enter:
|
||||
case AndroidTransitionType.popEnter:
|
||||
alphaValues[0] = 0.0;
|
||||
alphaValues[1] = 1.0;
|
||||
alphaValues[0] = 0;
|
||||
alphaValues[1] = 1;
|
||||
break;
|
||||
case AndroidTransitionType.exit:
|
||||
case AndroidTransitionType.popExit:
|
||||
alphaValues[0] = 1.0;
|
||||
alphaValues[1] = 0.0;
|
||||
alphaValues[0] = 1;
|
||||
alphaValues[1] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
const animation = new android.view.animation.AlphaAnimation(alphaValues[0], alphaValues[1]);
|
||||
const animator = android.animation.ObjectAnimator.ofFloat(null, "alpha", alphaValues);
|
||||
const duration = this.getDuration();
|
||||
if (duration !== undefined) {
|
||||
animation.setDuration(duration);
|
||||
animator.setDuration(duration);
|
||||
}
|
||||
|
||||
animation.setInterpolator(this.getCurve());
|
||||
|
||||
return animation;
|
||||
animator.setInterpolator(this.getCurve());
|
||||
return animator;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user