mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
FIX: Set both translate and scale values after animation end
This commit is contained in:
@ -83,9 +83,9 @@ allTests["REPEATER"] = require("./ui/repeater/repeater-tests");
|
|||||||
allTests["SEARCH-BAR"] = require('./ui/search-bar/search-bar-tests');
|
allTests["SEARCH-BAR"] = require('./ui/search-bar/search-bar-tests');
|
||||||
allTests["CONNECTIVITY"] = require("./connectivity-tests");
|
allTests["CONNECTIVITY"] = require("./connectivity-tests");
|
||||||
allTests["SEGMENTED-BAR"] = require("./ui/segmented-bar/segmented-bar-tests");
|
allTests["SEGMENTED-BAR"] = require("./ui/segmented-bar/segmented-bar-tests");
|
||||||
|
allTests["ANIMATION"] = require("./ui/animation/animation-tests");
|
||||||
|
|
||||||
if (!isRunningOnEmulator()) {
|
if (!isRunningOnEmulator()) {
|
||||||
allTests["ANIMATION"] = require("./ui/animation/animation-tests");
|
|
||||||
allTests["LOCATION"] = require("./location-tests");
|
allTests["LOCATION"] = require("./location-tests");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ function startLog(): void {
|
|||||||
function log(): void {
|
function log(): void {
|
||||||
let testsName: string = this.name;
|
let testsName: string = this.name;
|
||||||
let duration = TKUnit.time() - this.start;
|
let duration = TKUnit.time() - this.start;
|
||||||
TKUnit.write(testsName + " COMPLETED for " + duration, messageType.info);
|
TKUnit.write(testsName + " COMPLETED for " + duration + " BACKSTACK DEPTH: " + topmost().backStack.length, messageType.info);
|
||||||
}
|
}
|
||||||
|
|
||||||
export var runAll = function (moduleName?: string) {
|
export var runAll = function (moduleName?: string) {
|
||||||
@ -161,7 +161,7 @@ export var runAll = function (moduleName?: string) {
|
|||||||
|
|
||||||
var test = testModule.createTestCase ? testModule.createTestCase() : testModule;
|
var test = testModule.createTestCase ? testModule.createTestCase() : testModule;
|
||||||
test.name = name;
|
test.name = name;
|
||||||
|
|
||||||
|
|
||||||
testsQueue.push(new TestInfo(startLog, test));
|
testsQueue.push(new TestInfo(startLog, test));
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ export var test_AnimateOpacity = function (done) {
|
|||||||
|
|
||||||
label.animate({ opacity: 0.75 })
|
label.animate({ opacity: 0.75 })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
TKUnit.assert(label.opacity === 0.75);
|
TKUnit.assertEqual(label.opacity, 0.75, "label.opacity");
|
||||||
helper.goBack();
|
helper.goBack();
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
@ -326,8 +326,8 @@ export var test_AnimateTranslate = function (done) {
|
|||||||
|
|
||||||
label.animate({ translate: { x: 100, y: 200 } })
|
label.animate({ translate: { x: 100, y: 200 } })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
TKUnit.assert(label.translateX === 100);
|
TKUnit.assertEqual(label.translateX, 100, "label.translateX");
|
||||||
TKUnit.assert(label.translateY === 200);
|
TKUnit.assertEqual(label.translateY, 200, "label.translateY");
|
||||||
assertIOSNativeTransformIsCorrect(label);
|
assertIOSNativeTransformIsCorrect(label);
|
||||||
helper.goBack();
|
helper.goBack();
|
||||||
done();
|
done();
|
||||||
@ -356,8 +356,8 @@ export var test_AnimateScale = function (done) {
|
|||||||
|
|
||||||
label.animate({ scale: { x: 2, y: 3 } })
|
label.animate({ scale: { x: 2, y: 3 } })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
TKUnit.assert(label.scaleX === 2);
|
TKUnit.assertEqual(label.scaleX, 2,"label.scaleX");
|
||||||
TKUnit.assert(label.scaleY === 3);
|
TKUnit.assertEqual(label.scaleY, 3,"label.scaleY");
|
||||||
assertIOSNativeTransformIsCorrect(label);
|
assertIOSNativeTransformIsCorrect(label);
|
||||||
helper.goBack();
|
helper.goBack();
|
||||||
done();
|
done();
|
||||||
@ -386,7 +386,7 @@ export var test_AnimateRotate = function (done) {
|
|||||||
|
|
||||||
label.animate({ rotate: 123 })
|
label.animate({ rotate: 123 })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
TKUnit.assert(label.rotate === 123);
|
TKUnit.assertEqual(label.rotate, 123, "label.rotate");
|
||||||
assertIOSNativeTransformIsCorrect(label);
|
assertIOSNativeTransformIsCorrect(label);
|
||||||
helper.goBack();
|
helper.goBack();
|
||||||
done();
|
done();
|
||||||
@ -419,11 +419,11 @@ export var test_AnimateTranslateScaleAndRotateSimultaneously = function (done) {
|
|||||||
rotate: 123
|
rotate: 123
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
TKUnit.assert(label.translateX === 100);
|
TKUnit.assertEqual(label.translateX, 100, "label.translateX");
|
||||||
TKUnit.assert(label.translateY === 200);
|
TKUnit.assertEqual(label.translateY, 200, "label.translateY");
|
||||||
TKUnit.assert(label.scaleX === 2);
|
TKUnit.assertEqual(label.scaleX, 2, "label.scaleX");
|
||||||
TKUnit.assert(label.scaleY === 3);
|
TKUnit.assertEqual(label.scaleY, 3, "label.scaleY");
|
||||||
TKUnit.assert(label.rotate === 123);
|
TKUnit.assertEqual(label.rotate, 123, "label.rotate");
|
||||||
assertIOSNativeTransformIsCorrect(label);
|
assertIOSNativeTransformIsCorrect(label);
|
||||||
helper.goBack();
|
helper.goBack();
|
||||||
done();
|
done();
|
||||||
@ -450,35 +450,35 @@ export var test_AnimateTranslateScaleAndRotateSequentially = function (done) {
|
|||||||
helper.navigate(pageFactory);
|
helper.navigate(pageFactory);
|
||||||
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
||||||
|
|
||||||
label.animate({translate: { x: 100, y: 200 }})
|
label.animate({ translate: { x: 100, y: 200 } })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
TKUnit.assert(label.translateX === 100);
|
TKUnit.assertEqual(label.translateX, 100, "label.translateX");
|
||||||
TKUnit.assert(label.translateY === 200);
|
TKUnit.assertEqual(label.translateY, 200, "label.translateY");
|
||||||
assertIOSNativeTransformIsCorrect(label);
|
assertIOSNativeTransformIsCorrect(label);
|
||||||
return label.animate({ scale: { x: 2, y: 3 } });
|
return label.animate({ scale: { x: 2, y: 3 } });
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
TKUnit.assert(label.translateX === 100);
|
TKUnit.assertEqual(label.translateX, 100, "label.translateX");
|
||||||
TKUnit.assert(label.translateY === 200);
|
TKUnit.assertEqual(label.translateY, 200, "label.translateY");
|
||||||
TKUnit.assert(label.scaleX === 2);
|
TKUnit.assertEqual(label.scaleX, 2, "label.scaleX");
|
||||||
TKUnit.assert(label.scaleY === 3);
|
TKUnit.assertEqual(label.scaleY, 3, "label.scaleY");
|
||||||
assertIOSNativeTransformIsCorrect(label);
|
assertIOSNativeTransformIsCorrect(label);
|
||||||
return label.animate({ rotate: 123 });
|
return label.animate({ rotate: 123 });
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
TKUnit.assert(label.translateX === 100);
|
TKUnit.assertEqual(label.translateX, 100, "label.translateX");
|
||||||
TKUnit.assert(label.translateY === 200);
|
TKUnit.assertEqual(label.translateY, 200, "label.translateY");
|
||||||
TKUnit.assert(label.scaleX === 2);
|
TKUnit.assertEqual(label.scaleX, 2, "label.scaleX");
|
||||||
TKUnit.assert(label.scaleY === 3);
|
TKUnit.assertEqual(label.scaleY, 3, "label.scaleY");
|
||||||
TKUnit.assert(label.rotate === 123);
|
TKUnit.assertEqual(label.rotate, 123, "label.rotate");
|
||||||
assertIOSNativeTransformIsCorrect(label);
|
assertIOSNativeTransformIsCorrect(label);
|
||||||
helper.goBack();
|
helper.goBack();
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
helper.goBack();
|
helper.goBack();
|
||||||
done(e);
|
done(e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_AnimationsAreAlwaysPlayed = function (done) {
|
export var test_AnimationsAreAlwaysPlayed = function (done) {
|
||||||
|
@ -136,7 +136,8 @@ export class Animation extends common.Animation implements definition.Animation
|
|||||||
var animators = new Array<android.animation.Animator>();
|
var animators = new Array<android.animation.Animator>();
|
||||||
var propertyUpdateCallbacks = new Array<Function>();
|
var propertyUpdateCallbacks = new Array<Function>();
|
||||||
var propertyResetCallbacks = new Array<Function>();
|
var propertyResetCallbacks = new Array<Function>();
|
||||||
var originalValue;
|
var originalValue1;
|
||||||
|
var originalValue2;
|
||||||
var density = utils.layout.getDisplayDensity();
|
var density = utils.layout.getDisplayDensity();
|
||||||
var xyObjectAnimators: any;
|
var xyObjectAnimators: any;
|
||||||
var animatorSet: android.animation.AnimatorSet;
|
var animatorSet: android.animation.AnimatorSet;
|
||||||
@ -157,16 +158,16 @@ export class Animation extends common.Animation implements definition.Animation
|
|||||||
switch (propertyAnimation.property) {
|
switch (propertyAnimation.property) {
|
||||||
|
|
||||||
case common.Properties.opacity:
|
case common.Properties.opacity:
|
||||||
originalValue = nativeView.getAlpha();
|
originalValue1 = nativeView.getAlpha();
|
||||||
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
|
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
|
||||||
nativeArray[0] = propertyAnimation.value;
|
nativeArray[0] = propertyAnimation.value;
|
||||||
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.opacity = propertyAnimation.value }));
|
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.opacity = propertyAnimation.value }));
|
||||||
propertyResetCallbacks.push(checkAnimation(() => { nativeView.setAlpha(originalValue); }));
|
propertyResetCallbacks.push(checkAnimation(() => { nativeView.setAlpha(originalValue1); }));
|
||||||
animators.push(android.animation.ObjectAnimator.ofFloat(nativeView, "alpha", nativeArray));
|
animators.push(android.animation.ObjectAnimator.ofFloat(nativeView, "alpha", nativeArray));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case common.Properties.backgroundColor:
|
case common.Properties.backgroundColor:
|
||||||
originalValue = nativeView.getBackground();
|
originalValue1 = nativeView.getBackground();
|
||||||
nativeArray = java.lang.reflect.Array.newInstance(java.lang.Object.class, 2);
|
nativeArray = java.lang.reflect.Array.newInstance(java.lang.Object.class, 2);
|
||||||
nativeArray[0] = propertyAnimation.target.backgroundColor ? java.lang.Integer.valueOf((<color.Color>propertyAnimation.target.backgroundColor).argb) : java.lang.Integer.valueOf(-1);
|
nativeArray[0] = propertyAnimation.target.backgroundColor ? java.lang.Integer.valueOf((<color.Color>propertyAnimation.target.backgroundColor).argb) : java.lang.Integer.valueOf(-1);
|
||||||
nativeArray[1] = java.lang.Integer.valueOf((<color.Color>propertyAnimation.value).argb);
|
nativeArray[1] = java.lang.Integer.valueOf((<color.Color>propertyAnimation.value).argb);
|
||||||
@ -179,28 +180,35 @@ export class Animation extends common.Animation implements definition.Animation
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.backgroundColor = propertyAnimation.value; }));
|
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.backgroundColor = propertyAnimation.value; }));
|
||||||
propertyResetCallbacks.push(checkAnimation(() => { nativeView.setBackground(originalValue); }));
|
propertyResetCallbacks.push(checkAnimation(() => { nativeView.setBackground(originalValue1); }));
|
||||||
animators.push(animator);
|
animators.push(animator);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case common.Properties.translate:
|
case common.Properties.translate:
|
||||||
xyObjectAnimators = java.lang.reflect.Array.newInstance(android.animation.Animator.class, 2);
|
xyObjectAnimators = java.lang.reflect.Array.newInstance(android.animation.Animator.class, 2);
|
||||||
|
|
||||||
originalValue = nativeView.getTranslationX();
|
|
||||||
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
|
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
|
||||||
nativeArray[0] = propertyAnimation.value.x * density;
|
nativeArray[0] = propertyAnimation.value.x * density;
|
||||||
xyObjectAnimators[0] = android.animation.ObjectAnimator.ofFloat(nativeView, "translationX", nativeArray);
|
xyObjectAnimators[0] = android.animation.ObjectAnimator.ofFloat(nativeView, "translationX", nativeArray);
|
||||||
xyObjectAnimators[0].setRepeatCount(Animation._getAndroidRepeatCount(propertyAnimation.iterations));
|
xyObjectAnimators[0].setRepeatCount(Animation._getAndroidRepeatCount(propertyAnimation.iterations));
|
||||||
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.translateX = propertyAnimation.value.x; }));
|
|
||||||
propertyResetCallbacks.push(checkAnimation(() => { nativeView.setTranslationX(originalValue); }));
|
|
||||||
|
|
||||||
originalValue = nativeView.getTranslationY();
|
|
||||||
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
|
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
|
||||||
nativeArray[0] = propertyAnimation.value.y * density;
|
nativeArray[0] = propertyAnimation.value.y * density;
|
||||||
xyObjectAnimators[1] = android.animation.ObjectAnimator.ofFloat(nativeView, "translationY", nativeArray);
|
xyObjectAnimators[1] = android.animation.ObjectAnimator.ofFloat(nativeView, "translationY", nativeArray);
|
||||||
xyObjectAnimators[1].setRepeatCount(Animation._getAndroidRepeatCount(propertyAnimation.iterations));
|
xyObjectAnimators[1].setRepeatCount(Animation._getAndroidRepeatCount(propertyAnimation.iterations));
|
||||||
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.translateY = propertyAnimation.value.y; }));
|
|
||||||
propertyResetCallbacks.push(checkAnimation(() => { nativeView.setTranslationY(originalValue); }));
|
originalValue1 = nativeView.getTranslationX();
|
||||||
|
originalValue2 = nativeView.getTranslationY();
|
||||||
|
|
||||||
|
propertyUpdateCallbacks.push(checkAnimation(() => {
|
||||||
|
propertyAnimation.target.translateX = propertyAnimation.value.x;
|
||||||
|
propertyAnimation.target.translateY = propertyAnimation.value.y;
|
||||||
|
}));
|
||||||
|
|
||||||
|
propertyResetCallbacks.push(checkAnimation(() => {
|
||||||
|
nativeView.setTranslationX(originalValue1);
|
||||||
|
nativeView.setTranslationY(originalValue2);
|
||||||
|
}));
|
||||||
|
|
||||||
animatorSet = new android.animation.AnimatorSet();
|
animatorSet = new android.animation.AnimatorSet();
|
||||||
animatorSet.playTogether(xyObjectAnimators);
|
animatorSet.playTogether(xyObjectAnimators);
|
||||||
@ -211,21 +219,28 @@ export class Animation extends common.Animation implements definition.Animation
|
|||||||
case common.Properties.scale:
|
case common.Properties.scale:
|
||||||
xyObjectAnimators = java.lang.reflect.Array.newInstance(android.animation.Animator.class, 2);
|
xyObjectAnimators = java.lang.reflect.Array.newInstance(android.animation.Animator.class, 2);
|
||||||
|
|
||||||
originalValue = nativeView.getScaleX();
|
|
||||||
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
|
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
|
||||||
nativeArray[0] = propertyAnimation.value.x;
|
nativeArray[0] = propertyAnimation.value.x;
|
||||||
xyObjectAnimators[0] = android.animation.ObjectAnimator.ofFloat(nativeView, "scaleX", nativeArray);
|
xyObjectAnimators[0] = android.animation.ObjectAnimator.ofFloat(nativeView, "scaleX", nativeArray);
|
||||||
xyObjectAnimators[0].setRepeatCount(Animation._getAndroidRepeatCount(propertyAnimation.iterations));
|
xyObjectAnimators[0].setRepeatCount(Animation._getAndroidRepeatCount(propertyAnimation.iterations));
|
||||||
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.scaleX = propertyAnimation.value.x; }));
|
|
||||||
propertyResetCallbacks.push(checkAnimation(() => { nativeView.setScaleX(originalValue); }));
|
|
||||||
|
|
||||||
originalValue = nativeView.getScaleY();
|
|
||||||
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
|
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
|
||||||
nativeArray[0] = propertyAnimation.value.y;
|
nativeArray[0] = propertyAnimation.value.y;
|
||||||
xyObjectAnimators[1] = android.animation.ObjectAnimator.ofFloat(nativeView, "scaleY", nativeArray);
|
xyObjectAnimators[1] = android.animation.ObjectAnimator.ofFloat(nativeView, "scaleY", nativeArray);
|
||||||
xyObjectAnimators[1].setRepeatCount(Animation._getAndroidRepeatCount(propertyAnimation.iterations));
|
xyObjectAnimators[1].setRepeatCount(Animation._getAndroidRepeatCount(propertyAnimation.iterations));
|
||||||
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.scaleY = propertyAnimation.value.y; }));
|
|
||||||
propertyResetCallbacks.push(checkAnimation(() => { nativeView.setScaleY(originalValue); }));
|
originalValue1 = nativeView.getScaleX();
|
||||||
|
originalValue2 = nativeView.getScaleY();
|
||||||
|
|
||||||
|
propertyUpdateCallbacks.push(checkAnimation(() => {
|
||||||
|
propertyAnimation.target.scaleX = propertyAnimation.value.x;
|
||||||
|
propertyAnimation.target.scaleY = propertyAnimation.value.y;
|
||||||
|
}));
|
||||||
|
|
||||||
|
propertyResetCallbacks.push(checkAnimation(() => {
|
||||||
|
nativeView.setScaleY(originalValue1);
|
||||||
|
nativeView.setScaleY(originalValue2);
|
||||||
|
}));
|
||||||
|
|
||||||
animatorSet = new android.animation.AnimatorSet();
|
animatorSet = new android.animation.AnimatorSet();
|
||||||
animatorSet.playTogether(xyObjectAnimators);
|
animatorSet.playTogether(xyObjectAnimators);
|
||||||
@ -234,11 +249,11 @@ export class Animation extends common.Animation implements definition.Animation
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case common.Properties.rotate:
|
case common.Properties.rotate:
|
||||||
originalValue = nativeView.getRotation();
|
originalValue1 = nativeView.getRotation();
|
||||||
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
|
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
|
||||||
nativeArray[0] = propertyAnimation.value;
|
nativeArray[0] = propertyAnimation.value;
|
||||||
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.rotate = propertyAnimation.value; }));
|
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.rotate = propertyAnimation.value; }));
|
||||||
propertyResetCallbacks.push(checkAnimation(() => { nativeView.setRotation(originalValue); }));
|
propertyResetCallbacks.push(checkAnimation(() => { nativeView.setRotation(originalValue1); }));
|
||||||
animators.push(android.animation.ObjectAnimator.ofFloat(nativeView, "rotation", nativeArray));
|
animators.push(android.animation.ObjectAnimator.ofFloat(nativeView, "rotation", nativeArray));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user