Merge pull request #865 from NativeScript/animation-ios-skip-fix

Fixed:  iOS animations combining several affine transform properties …
This commit is contained in:
Rossen Hristov
2015-10-01 14:26:47 +03:00
2 changed files with 69 additions and 32 deletions

View File

@ -344,10 +344,10 @@ export var test_AnimateScale = function (done) {
helper.navigate(pageFactory);
TKUnit.waitUntilReady(() => { return label.isLoaded });
label.animate({ scale: { x: 1, y: 2 } })
label.animate({ scale: { x: 2, y: 3 } })
.then(() => {
TKUnit.assert(label.scaleX === 1);
TKUnit.assert(label.scaleY === 2);
TKUnit.assert(label.scaleX === 2);
TKUnit.assert(label.scaleY === 3);
helper.goBack();
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) {
var mainPage: pageModule.Page;
var label: labelModule.Label;

View File

@ -257,7 +257,9 @@ export class Animation extends common.Animation implements definition.Animation
var j;
var length = propertyAnimations.length;
for (; i < length; i++) {
if (propertyAnimations[i].property !== _skip) {
if (propertyAnimations[i][_skip]) {
continue;
}
if (!Animation._isAffineTransform(propertyAnimations[i].property)) {
// This is not an affine transform animation, so there is nothing to merge.
@ -286,7 +288,7 @@ export class Animation extends common.Animation implements definition.Animation
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.
propertyAnimations[j].property = _skip;
propertyAnimations[j][_skip] = true;
}
}
}
@ -294,7 +296,6 @@ export class Animation extends common.Animation implements definition.Animation
result.push(newTransformAnimation);
}
}
}
return result;
}