mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Fixed: iOS animations combining several affine transform properties set only the first property on our view after they finish. #835
This commit is contained in:
@ -344,10 +344,10 @@ export var test_AnimateScale = function (done) {
|
|||||||
helper.navigate(pageFactory);
|
helper.navigate(pageFactory);
|
||||||
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
||||||
|
|
||||||
label.animate({ scale: { x: 1, y: 2 } })
|
label.animate({ scale: { x: 2, y: 3 } })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
TKUnit.assert(label.scaleX === 1);
|
TKUnit.assert(label.scaleX === 2);
|
||||||
TKUnit.assert(label.scaleY === 2);
|
TKUnit.assert(label.scaleY === 3);
|
||||||
helper.goBack();
|
helper.goBack();
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
@ -385,6 +385,42 @@ export var test_AnimateRotate = function (done) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export var test_AnimateTranslateScaleAndRotateSimultaneously = function (done) {
|
||||||
|
var mainPage: pageModule.Page;
|
||||||
|
var label: labelModule.Label;
|
||||||
|
var pageFactory = function (): pageModule.Page {
|
||||||
|
label = new labelModule.Label();
|
||||||
|
label.text = "label";
|
||||||
|
var stackLayout = new stackLayoutModule.StackLayout();
|
||||||
|
stackLayout.addChild(label);
|
||||||
|
mainPage = new pageModule.Page();
|
||||||
|
mainPage.content = stackLayout;
|
||||||
|
return mainPage;
|
||||||
|
};
|
||||||
|
|
||||||
|
helper.navigate(pageFactory);
|
||||||
|
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
||||||
|
|
||||||
|
label.animate({
|
||||||
|
translate: { x: 100, y: 200 },
|
||||||
|
scale: { x: 2, y: 3 },
|
||||||
|
rotate: 123
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
TKUnit.assert(label.translateX === 100);
|
||||||
|
TKUnit.assert(label.translateY === 200);
|
||||||
|
TKUnit.assert(label.scaleX === 2);
|
||||||
|
TKUnit.assert(label.scaleY === 3);
|
||||||
|
TKUnit.assert(label.rotate === 123);
|
||||||
|
helper.goBack();
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
helper.goBack();
|
||||||
|
done(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export var test_AnimationsAreAlwaysPlayed = function (done) {
|
export var test_AnimationsAreAlwaysPlayed = function (done) {
|
||||||
var mainPage: pageModule.Page;
|
var mainPage: pageModule.Page;
|
||||||
var label: labelModule.Label;
|
var label: labelModule.Label;
|
||||||
|
@ -257,42 +257,43 @@ export class Animation extends common.Animation implements definition.Animation
|
|||||||
var j;
|
var j;
|
||||||
var length = propertyAnimations.length;
|
var length = propertyAnimations.length;
|
||||||
for (; i < length; i++) {
|
for (; i < length; i++) {
|
||||||
if (propertyAnimations[i].property !== _skip) {
|
if (propertyAnimations[i][_skip]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Animation._isAffineTransform(propertyAnimations[i].property)) {
|
if (!Animation._isAffineTransform(propertyAnimations[i].property)) {
|
||||||
// This is not an affine transform animation, so there is nothing to merge.
|
// This is not an affine transform animation, so there is nothing to merge.
|
||||||
result.push(propertyAnimations[i]);
|
result.push(propertyAnimations[i]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// This animation has not been merged anywhere. Create a new transform animation.
|
// This animation has not been merged anywhere. Create a new transform animation.
|
||||||
var newTransformAnimation: common.PropertyAnimation = {
|
var newTransformAnimation: common.PropertyAnimation = {
|
||||||
target: propertyAnimations[i].target,
|
target: propertyAnimations[i].target,
|
||||||
property: _transform,
|
property: _transform,
|
||||||
value: Animation._affineTransform(CGAffineTransformIdentity, propertyAnimations[i].property, propertyAnimations[i].value),
|
value: Animation._affineTransform(CGAffineTransformIdentity, propertyAnimations[i].property, propertyAnimations[i].value),
|
||||||
duration: propertyAnimations[i].duration,
|
duration: propertyAnimations[i].duration,
|
||||||
delay: propertyAnimations[i].delay,
|
delay: propertyAnimations[i].delay,
|
||||||
iterations: propertyAnimations[i].iterations
|
iterations: propertyAnimations[i].iterations
|
||||||
};
|
};
|
||||||
trace.write("Created new transform animation: " + common.Animation._getAnimationInfo(newTransformAnimation), trace.categories.Animation);
|
trace.write("Created new transform animation: " + common.Animation._getAnimationInfo(newTransformAnimation), trace.categories.Animation);
|
||||||
|
|
||||||
j = i + 1;
|
j = i + 1;
|
||||||
if (j < length) {
|
if (j < length) {
|
||||||
// Merge all compatible affine transform animations to the right into this new animation.
|
// Merge all compatible affine transform animations to the right into this new animation.
|
||||||
for (; j < length; j++) {
|
for (; j < length; j++) {
|
||||||
if (Animation._canBeMerged(propertyAnimations[i], propertyAnimations[j])) {
|
if (Animation._canBeMerged(propertyAnimations[i], propertyAnimations[j])) {
|
||||||
trace.write("Merging animations: " + common.Animation._getAnimationInfo(newTransformAnimation) + " + " + common.Animation._getAnimationInfo(propertyAnimations[j]) + " = ", trace.categories.Animation);
|
trace.write("Merging animations: " + common.Animation._getAnimationInfo(newTransformAnimation) + " + " + common.Animation._getAnimationInfo(propertyAnimations[j]) + " = ", trace.categories.Animation);
|
||||||
trace.write("New native transform is: " + NSStringFromCGAffineTransform(newTransformAnimation.value), trace.categories.Animation);
|
trace.write("New native transform is: " + NSStringFromCGAffineTransform(newTransformAnimation.value), trace.categories.Animation);
|
||||||
newTransformAnimation.value = Animation._affineTransform(newTransformAnimation.value, propertyAnimations[j].property, propertyAnimations[j].value);
|
newTransformAnimation.value = Animation._affineTransform(newTransformAnimation.value, propertyAnimations[j].property, propertyAnimations[j].value);
|
||||||
|
|
||||||
// Mark that it has been merged so we can skip it on our outer loop.
|
// Mark that it has been merged so we can skip it on our outer loop.
|
||||||
propertyAnimations[j].property = _skip;
|
propertyAnimations[j][_skip] = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.push(newTransformAnimation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.push(newTransformAnimation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user