diff --git a/apps/app/ui-tests-app/animation/animation-army-100.ts b/apps/app/ui-tests-app/animation/animation-army-100.ts
deleted file mode 100644
index 994d811ec..000000000
--- a/apps/app/ui-tests-app/animation/animation-army-100.ts
+++ /dev/null
@@ -1,114 +0,0 @@
-import * as view from 'tns-core-modules/ui/core/view';
-import {View} from 'tns-core-modules/ui/core/view';
-import * as pages from 'tns-core-modules/ui/page';
-import {Button} from 'tns-core-modules/ui/button';
-import {SegmentedBar, SegmentedBarItem} from 'tns-core-modules/ui/segmented-bar';
-import {Label} from 'tns-core-modules/ui/label';
-import {Animation, AnimationDefinition} from 'tns-core-modules/ui/animation';
-import * as fpsMeter from 'tns-core-modules/fps-meter';
-
-let fpsCallbackId;
-export function onLoaded(args) {
- const page = args.object;
- const fpsLabel = view.getViewById(page, 'fps') as Label;
- fpsCallbackId = fpsMeter.addCallback((fps: number, minFps: number) => {
- fpsLabel.text = `${fps.toFixed(2)}/${minFps.toFixed(2)}`;
- });
- fpsMeter.start();
-}
-
-export function onUnloaded() {
- fpsMeter.removeCallback(fpsCallbackId);
- fpsMeter.stop();
-}
-
-export function getBoxPropertyAnimationData(property: string,
- animateEase: string,
- target: View,
- extentX: number = 128,
- extentY: number = 128) {
- let animateKey;
- let animateValueTo;
- let animateValueFrom;
- let animateDuration = animateEase === 'spring' ? 800 : 500;
- let animateReturnDelay = animateEase === 'spring' ? 0 : 200;
-
- // Determine the full animation property name (some are shortened in UI), and the demo to/from values
- switch (property) {
- case 'height':
- target.originX = target.originY = 0.5;
- animateKey = 'height';
- animateValueTo = 0;
- animateValueFrom = extentY;
- break;
- case 'width':
- target.originX = target.originY = 0.5;
- animateKey = 'width';
- animateValueTo = 0;
- animateValueFrom = extentX;
- break;
- case 'opacity':
- animateKey = 'opacity';
- animateValueTo = 0;
- animateValueFrom = 1;
- break;
- case 'color':
- animateKey = 'backgroundColor';
- animateValueTo = 'blue';
- animateValueFrom = 'purple';
- break;
- case 'rotate':
- target.originX = target.originY = 0.5;
- animateKey = 'rotate';
- animateValueTo = 180;
- animateValueFrom = 0;
- break;
- case 'scale':
- target.originX = target.originY = 0.5;
- animateKey = 'scale';
- animateValueTo = {x: 0.1, y: 0.1};
- animateValueFrom = {x: 1, y: 1};
- break;
- default:
- throw new Error(`demo animation for '${property}' is not implemented`);
- }
-
- return {
- animateEase,
- animateKey,
- animateValueTo,
- animateValueFrom,
- animateReturnDelay,
- animateDuration
- };
-}
-
-export function easeAnimate(args) {
- const clicked = args.object as Button;
- const page: pages.Page = clicked.page;
- const select = view.getViewById(page, 'select') as SegmentedBar;
- const item: SegmentedBarItem = select.items[select.selectedIndex];
- const animsIn: AnimationDefinition[] = [];
- const animsOut: AnimationDefinition[] = [];
- for (let i = 0; i < 100; i++) {
- const box = view.getViewById(page, 'el-' + i) as Label;
- const prop = getBoxPropertyAnimationData(item.title, clicked.text, box, 32, 24);
- animsIn.push({
- [prop.animateKey]: prop.animateValueTo,
- delay: 15 * i,
- target: box,
- duration: prop.animateDuration,
- curve: prop.animateEase
- });
- animsOut.push({
- [prop.animateKey]: prop.animateValueFrom,
- target: box,
- delay: prop.animateReturnDelay + (5 * (Math.abs(i - 100))),
- duration: prop.animateDuration,
- curve: prop.animateEase
- });
- }
- new Animation(animsIn, false).play()
- .then(() => new Animation(animsOut, false).play())
- .catch((e) => console.log(e));
-}
diff --git a/apps/app/ui-tests-app/animation/animation-army-100.xml b/apps/app/ui-tests-app/animation/animation-army-100.xml
deleted file mode 100644
index d56f1558b..000000000
--- a/apps/app/ui-tests-app/animation/animation-army-100.xml
+++ /dev/null
@@ -1,157 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/apps/app/ui-tests-app/animation/animation-curves.ts b/apps/app/ui-tests-app/animation/animation-curves.ts
deleted file mode 100644
index d261ee66a..000000000
--- a/apps/app/ui-tests-app/animation/animation-curves.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import * as view from 'tns-core-modules/ui/core/view';
-import * as pages from 'tns-core-modules/ui/page';
-import {Button} from 'tns-core-modules/ui/button';
-import {SegmentedBar, SegmentedBarItem} from 'tns-core-modules/ui/segmented-bar';
-import {Label} from 'tns-core-modules/ui/label';
-
-export function easeAnimate(args) {
- const clicked = args.object as Button;
- const page: pages.Page = clicked.page;
- const target = view.getViewById(page, 'target') as Label;
- const select = view.getViewById(page, 'select') as SegmentedBar;
- const item: SegmentedBarItem = select.items[select.selectedIndex];
- const easeType: string = clicked.text;
- const extent = 128;
- let duration = easeType === 'spring' ? 800 : 500;
- let delay = easeType === 'spring' ? 0 : 200;
- let animateKey: string = null;
- let animateValueTo: any = null;
- let animateValueFrom: any = null;
-
- switch (item.title) {
- case 'height':
- animateKey = 'height';
- target.originX = target.originY = 0;
- animateValueTo = 0;
- animateValueFrom = extent;
- break;
- case 'width':
- animateKey = 'width';
- target.originX = target.originY = 0;
- animateValueTo = 0;
- animateValueFrom = extent;
- break;
- case 'opacity':
- animateKey = 'opacity';
- animateValueTo = 0;
- animateValueFrom = 1;
- break;
- case 'color':
- animateKey = 'backgroundColor';
- animateValueTo = 'blue';
- animateValueFrom = 'purple';
- break;
- case 'rotate':
- animateKey = 'rotate';
- target.originX = target.originY = 0.5;
- animateValueTo = 180;
- animateValueFrom = 0;
- break;
- case 'scale':
- animateKey = 'scale';
- target.originX = target.originY = 0.5;
- animateValueTo = {x: 1.5, y: 1.5};
- animateValueFrom = {x: 1, y: 1};
- break;
- }
- target
- .animate({
- [animateKey]: animateValueTo,
- duration,
- curve: easeType
- })
- .then(() => {
- return target.animate({
- [animateKey]: animateValueFrom,
- delay,
- duration,
- curve: easeType
- });
- })
- .catch((e) => console.log(e));
-}
diff --git a/apps/app/ui-tests-app/animation/animation-curves.xml b/apps/app/ui-tests-app/animation/animation-curves.xml
deleted file mode 100644
index 58f58d686..000000000
--- a/apps/app/ui-tests-app/animation/animation-curves.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/apps/app/ui-tests-app/animation/effect-summary-details.ts b/apps/app/ui-tests-app/animation/effect-summary-details.ts
deleted file mode 100644
index 30fb15b83..000000000
--- a/apps/app/ui-tests-app/animation/effect-summary-details.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-import * as view from 'tns-core-modules/ui/core/view';
-import * as pages from 'tns-core-modules/ui/page';
-import * as platform from 'tns-core-modules/platform';
-import {Animation} from 'tns-core-modules/ui/animation';
-import {TextView} from 'tns-core-modules/ui/text-view';
-import {isIOS} from 'tns-core-modules/platform';
-
-let toggle = false;
-
-export function pageLoaded(args) {
- const page = args.object;
- const screenHeight = platform.screen.mainScreen.heightDIPs;
- const screenYCenter = (screenHeight / 2);
- page.bindingContext = {
- screenHeight,
- screenYCenter,
- detailsHeight: 96,
- summary: 'Space! 🌌',
- ipsum: `Houston, Tranquillity Base here. The Eagle has landed.
-
-For those who have seen the Earth from space, and for the hundreds and perhaps thousands more who will, the experience most certainly changes your perspective. The things that we share in our world are far more valuable than those which divide us.
-
-As we got further and further away, it [the Earth] diminished in size. Finally it shrank to the size of a marble, the most beautiful you can imagine. That beautiful, warm, living object looked so fragile, so delicate, that if you touched it with a finger it would crumble and fall apart. Seeing this has to change a man.
-
-What was most significant about the lunar voyage was not that man set foot on the Moon but that they set eye on the earth.
-
-Spaceflights cannot be stopped. This is not the work of any one man or even a group of men. It is a historical process which mankind is carrying out in accordance with the natural laws of human development.
-
-NASA is not about the ‘Adventure of Human Space Exploration’…We won’t be doing it just to get out there in space – we’ll be doing it because the things we learn out there will be making life better for a lot of people who won’t be able to go.
-
-Science has not yet mastered prophecy. We predict too much for the next year and yet far too little for the next 10.
-
-Science cuts two ways, of course; its products can be used for both good and evil. But there's no turning back from science. The early warnings about technological dangers also come from science.
-
-Here men from the planet Earth first set foot upon the Moon. July 1969 AD. We came in peace for all mankind.
-
-When I orbited the Earth in a spaceship, I saw for the first time how beautiful our planet is. Mankind, let us preserve and increase this beauty, and not destroy it!
-
-http://spaceipsum.com`
- };
-}
-
-export function theFinalFrontier(args) {
- const clicked = args.object as view.View;
- const page: pages.Page = clicked.page;
- const details = view.getViewById(page, 'details') as TextView;
- const ctx = page.bindingContext;
- const detailHeaderHeight: number = ctx.detailsHeight;
-
- let statusBar = 0;
- if(isIOS) {
- const {ios} = require('tns-core-modules/ui/utils');
- statusBar = ios.getStatusBarHeight();
- }
-
- const textViewHeight: number = ctx.screenHeight - statusBar - detailHeaderHeight;
- const transitions = [
- {
- target: clicked,
- height: toggle ? '100%' : detailHeaderHeight,
- duration: 200,
- curve: 'ease'
- },
- {
- target: details,
- opacity: toggle ? 0 : 1,
- height: textViewHeight,
- translate: {
- x: 0,
- y: toggle ? 50 : 0,
- },
- duration: 200,
- curve: 'easeIn'
- }
- ];
- const animationSet = new Animation(transitions, false);
- animationSet.play();
- toggle = !toggle;
-}
diff --git a/apps/app/ui-tests-app/animation/effect-summary-details.xml b/apps/app/ui-tests-app/animation/effect-summary-details.xml
deleted file mode 100644
index 7800314d9..000000000
--- a/apps/app/ui-tests-app/animation/effect-summary-details.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
diff --git a/apps/app/ui-tests-app/animation/height-basic.ts b/apps/app/ui-tests-app/animation/height-basic.ts
deleted file mode 100644
index a8fa41154..000000000
--- a/apps/app/ui-tests-app/animation/height-basic.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import {Label} from 'tns-core-modules/ui/label';
-
-let toggle = false;
-
-export function animateHeight(args) {
- const clicked = args.object as Label;
- clicked
- .animate({
- height: toggle ? 128 : '100%',
- duration: 200,
- curve: 'easeInOut'
- })
- .then(() => {
- clicked.text = toggle ? "Cool." : "Tap here";
- });
- toggle = !toggle;
-}
diff --git a/apps/app/ui-tests-app/animation/height-basic.xml b/apps/app/ui-tests-app/animation/height-basic.xml
deleted file mode 100644
index 3fa67d708..000000000
--- a/apps/app/ui-tests-app/animation/height-basic.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
diff --git a/apps/app/ui-tests-app/animation/layout-stack-height.ts b/apps/app/ui-tests-app/animation/layout-stack-height.ts
deleted file mode 100644
index 732891a37..000000000
--- a/apps/app/ui-tests-app/animation/layout-stack-height.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import * as view from 'tns-core-modules/ui/core/view';
-
-export function tapLabel(args) {
- const clicked: view.View = args.object;
- const graffiti = clicked as any;
- clicked.animate({
- height: graffiti.toggle ? 64 : 128,
- duration: 200,
- curve: 'easeOut'
- });
- graffiti.toggle = !graffiti.toggle;
-}
diff --git a/apps/app/ui-tests-app/animation/layout-stack-height.xml b/apps/app/ui-tests-app/animation/layout-stack-height.xml
deleted file mode 100644
index 4d7d91dd6..000000000
--- a/apps/app/ui-tests-app/animation/layout-stack-height.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
diff --git a/apps/app/ui-tests-app/animation/main-page.ts b/apps/app/ui-tests-app/animation/main-page.ts
deleted file mode 100644
index 56d2ee64e..000000000
--- a/apps/app/ui-tests-app/animation/main-page.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { EventData } from "tns-core-modules/data/observable";
-import { SubMainPageViewModel } from "../sub-main-page-view-model";
-import { WrapLayout } from "tns-core-modules/ui/layouts/wrap-layout";
-import { Page } from "tns-core-modules/ui/page";
-
-export function pageLoaded(args: EventData) {
- const page = args.object;
- const wrapLayout = page.getViewById("wrapLayoutWithExamples");
- page.bindingContext = new SubMainPageViewModel(wrapLayout, loadExamples());
-}
-
-export function loadExamples() {
- const examples = new Map();
- examples.set("animation-curves", "animation/animation-curves");
- examples.set("animation-army-100", "animation/animation-army-100");
- examples.set("height-basic", "animation/height-basic");
- examples.set("layout-stack-height", "animation/layout-stack-height");
- examples.set("effect-summary-details", "animation/effect-summary-details");
- return examples;
-}
diff --git a/apps/app/ui-tests-app/animation/main-page.xml b/apps/app/ui-tests-app/animation/main-page.xml
deleted file mode 100644
index 33306f0d0..000000000
--- a/apps/app/ui-tests-app/animation/main-page.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/apps/app/ui-tests-app/main-page.ts b/apps/app/ui-tests-app/main-page.ts
index a0e6209b4..b030a14d3 100644
--- a/apps/app/ui-tests-app/main-page.ts
+++ b/apps/app/ui-tests-app/main-page.ts
@@ -8,7 +8,6 @@ export function pageLoaded(args: EventData) {
const page = args.object;
const wrapLayout = page.getViewById("wrapLayoutWithExamples");
const examples: Map = new Map();
- examples.set("animation", "animation/main-page");
examples.set("action-bar", "action-bar/main-page");
examples.set("bindings", "bindings/main-page");
examples.set("button", "button/main-page");
@@ -47,4 +46,4 @@ export function pageLoaded(args: EventData) {
}else{
parent.style.marginBottom=10;
}
-}
+}
\ No newline at end of file
diff --git a/apps/app/ui-tests-app/test-page-main-view-model.ts b/apps/app/ui-tests-app/test-page-main-view-model.ts
index bdd6faa1e..8ba190bfb 100644
--- a/apps/app/ui-tests-app/test-page-main-view-model.ts
+++ b/apps/app/ui-tests-app/test-page-main-view-model.ts
@@ -35,7 +35,6 @@ export class TestPageMainViewModel extends Observable {
try {
frame.topmost().navigate(TestPageMainViewModel.APP_NAME + "/" + exampleFullPath);
} catch (error) {
- console.log("EXAMPLE LOAD FAILED:" + error);
alert("Cannot find example: " + exampleFullPath);
}
diff --git a/tests/app/testRunner.ts b/tests/app/testRunner.ts
index 2556fdbf8..5b6101f97 100644
--- a/tests/app/testRunner.ts
+++ b/tests/app/testRunner.ts
@@ -471,4 +471,4 @@ class TestInfo implements TKUnit.TestInfoEntry {
this.testTimeout = testTimeout;
this.duration = duration;
}
-}
+}
\ No newline at end of file
diff --git a/tests/app/ui/animation/animation-tests.ts b/tests/app/ui/animation/animation-tests.ts
index 789ac8121..7b4c7af3f 100644
--- a/tests/app/ui/animation/animation-tests.ts
+++ b/tests/app/ui/animation/animation-tests.ts
@@ -9,22 +9,14 @@ import { AnimationPromise } from "tns-core-modules/ui/animation";
// >> animation-require
import * as animation from "tns-core-modules/ui/animation";
-import {PercentLength} from "tns-core-modules/ui/styling/style-properties";
// << animation-require
-function prepareTest(parentHeight?: number, parentWidth?: number): Label {
+function prepareTest(): Label {
let mainPage = helper.getCurrentPage();
let label = new Label();
label.text = "label";
let stackLayout = new StackLayout();
- // optionally size the parent extent to make assertions about percentage values
- if (parentHeight !== undefined) {
- stackLayout.height = PercentLength.parse(parentHeight + '');
- }
- if (parentWidth !== undefined) {
- stackLayout.width = PercentLength.parse(parentWidth + '');
- }
stackLayout.addChild(label);
mainPage.content = stackLayout;
TKUnit.waitUntilReady(() => label.isLoaded);
@@ -378,110 +370,6 @@ export function test_AnimateRotate(done) {
});
}
-function animateExtentAndAssertExpected(along: 'height' | 'width', value: PercentLength, pixelExpected: PercentLength): Promise {
- function pretty(val) {
- return JSON.stringify(val, null, 2);
- }
- const parentExtent = 200;
- const height = along === 'height' ? parentExtent : undefined;
- const width = along === 'height' ? undefined : parentExtent;
- const label = prepareTest(height, width);
- const props = {
- duration: 5,
- [along]: value
- };
- return label.animate(props).then(() => {
- const observedString: string = PercentLength.convertToString(label[along]);
- const inputString: string = PercentLength.convertToString(value);
- TKUnit.assertEqual(
- observedString,
- inputString,
- `PercentLength.convertToString(${pretty(value)}) should be '${inputString}' but is '${observedString}'`
- );
- // assert that the animated view's calculated pixel extent matches the expected pixel value
- const observedNumber: number = PercentLength.toDevicePixels(label[along], parentExtent, parentExtent);
- const expectedNumber: number = PercentLength.toDevicePixels(pixelExpected, parentExtent, parentExtent);
- TKUnit.assertEqual(
- observedNumber,
- expectedNumber,
- `PercentLength.toDevicePixels(${inputString}) should be '${expectedNumber}' but is '${observedNumber}'`
- );
- assertIOSNativeTransformIsCorrect(label);
- });
-}
-
-export function test_AnimateExtent_Should_ResolvePercentageStrings(done) {
- let promise: Promise = Promise.resolve();
- const pairs: [string, string][] = [
- ['100%', '200px'],
- ['50%', '100px'],
- ['25%', '50px'],
- ['-25%', '-50px'],
- ['-50%', '-100px'],
- ['-100%', '-200px'],
- ];
- pairs.forEach((pair) => {
- const input = PercentLength.parse(pair[0]);
- const expected = PercentLength.parse(pair[1]);
- promise = promise.then(() => {
- return animateExtentAndAssertExpected('height', input, expected);
- });
- promise = promise.then(() => {
- return animateExtentAndAssertExpected('width', input, expected);
- });
- });
- promise.then(() => done()).catch(done);
-}
-
-export function test_AnimateExtent_Should_AcceptStringPixelValues(done) {
- let promise: Promise = Promise.resolve();
- const pairs: [string, number][] = [
- ['100px', 100],
- ['50px', 50]
- ];
- pairs.forEach((pair) => {
- const input = PercentLength.parse(pair[0]);
- const expected = {
- unit: 'px',
- value: pair[1]
- } as PercentLength;
- promise = promise.then(() => {
- return animateExtentAndAssertExpected('height', input, expected);
- });
- promise = promise.then(() => {
- return animateExtentAndAssertExpected('width', input, expected);
- });
- });
- promise.then(() => done()).catch(done);
-}
-
-export function test_AnimateExtent_Should_AcceptNumberValuesAsDip(done) {
- let promise: Promise = Promise.resolve();
- const inputs: any[] = [200, 150, 100, 50, 0];
- inputs.forEach((value) => {
- const parsed = PercentLength.parse(value);
- promise = promise.then(() => {
- return animateExtentAndAssertExpected('height', parsed, parsed);
- });
- promise = promise.then(() => {
- return animateExtentAndAssertExpected('width', parsed, parsed);
- });
- });
- promise.then(() => done()).catch(done);
-}
-
-export function test_AnimateExtent_Should_ThrowIfCannotParsePercentLength() {
- const label = new Label();
- helper.buildUIAndRunTest(label, (views: Array) => {
- TKUnit.assertThrows(() => {
- label.animate({width: '-frog%'});
- }, "Invalid percent string should throw");
- TKUnit.assertThrows(() => {
- label.animate({height: '-frog%'});
- }, "Invalid percent string should throw");
- });
-}
-
export function test_AnimateTranslateScaleAndRotateSimultaneously(done) {
let label = prepareTest();
diff --git a/tests/app/ui/styling/style-properties-tests.ts b/tests/app/ui/styling/style-properties-tests.ts
index adf2b5b26..1c2b7f19f 100644
--- a/tests/app/ui/styling/style-properties-tests.ts
+++ b/tests/app/ui/styling/style-properties-tests.ts
@@ -10,7 +10,6 @@ import { isAndroid, isIOS } from "tns-core-modules/platform";
import { View } from "tns-core-modules/ui/core/view";
import { Length, PercentLength } from "tns-core-modules/ui/core/view";
import * as fontModule from "tns-core-modules/ui/styling/font";
-import { LengthPercentUnit, LengthPxUnit } from "tns-core-modules/ui/styling/style-properties";
export function test_setting_textDecoration_property_from_CSS_is_applied_to_Style() {
test_property_from_CSS_is_applied_to_style("textDecoration", "text-decoration", "underline");
@@ -863,57 +862,3 @@ export function test_border_radius() {
TKUnit.assertTrue(Length.equals(testView.style.borderBottomRightRadius, expected), "bottom");
TKUnit.assertTrue(Length.equals(testView.style.borderBottomLeftRadius, expected), "left");
}
-
-function assertPercentLengthParseInputOutputPairs(pairs: [string, any][]) {
- pairs.forEach((pair: [string, any]) => {
- const output = PercentLength.parse(pair[0]) as LengthPxUnit | LengthPercentUnit;
- TKUnit.assertEqual(pair[1].unit, output.unit,
- `PercentLength.parse('${pair[0]}') should return unit '${pair[1].unit}' but returned '${output.unit}'`
- );
- TKUnit.assertEqual(pair[1].value.toFixed(2), output.value.toFixed(2),
- `PercentLength.parse('${pair[0]}') should return value '${pair[1].value}' but returned '${output.value}'`
- );
- });
-}
-
-export function test_PercentLength_parses_pixel_values_from_string_input() {
- assertPercentLengthParseInputOutputPairs([
- ['4px', {unit: 'px', value: 4}],
- ['-4px', {unit: 'px', value: -4}],
- ]);
-}
-
-export function test_PercentLength_parses_percentage_values_from_string_input() {
- assertPercentLengthParseInputOutputPairs([
- ['4%', {unit: '%', value: 0.04}],
- ['17%', {unit: '%', value: 0.17}],
- ['-27%', {unit: '%', value: -0.27}],
- ]);
-}
-
-export function test_PercentLength_parse_throws_given_string_input_it_cannot_parse() {
- const inputs: any[] = [
- '-l??%',
- 'qre%',
- 'undefinedpx',
- 'undefined',
- '-frog%'
- ];
- inputs.forEach((input) => {
- TKUnit.assertThrows(() => {
- PercentLength.parse(input);
- }, `PercentLength.parse('${input}') should throw.`);
- });
-}
-
-export function test_PercentLength_returns_unsupported_types_untouched() {
- const inputs: any[] = [
- null,
- undefined,
- {baz: true}
- ];
- inputs.forEach((input) => {
- const result = PercentLength.parse(input);
- TKUnit.assertEqual(input, result, `PercentLength.parse(${input}) should return input value`);
- });
-}
diff --git a/tns-core-modules/globals/globals.ts b/tns-core-modules/globals/globals.ts
index eb94e645d..9e31f7b11 100644
--- a/tns-core-modules/globals/globals.ts
+++ b/tns-core-modules/globals/globals.ts
@@ -182,7 +182,7 @@ export function install() {
registerOnGlobalContext("Response", "fetch");
// check whether the 'android' namespace is exposed
- // if positive - the current device is an Android
+ // if positive - the current device is an Android
// so a custom implementation of the global 'console' object is attached.
// otherwise do nothing on iOS - the NS runtime provides a native 'console' functionality.
if ((global).android) {
diff --git a/tns-core-modules/ui/animation/animation-common.ts b/tns-core-modules/ui/animation/animation-common.ts
index c04fece7b..ded11ba50 100644
--- a/tns-core-modules/ui/animation/animation-common.ts
+++ b/tns-core-modules/ui/animation/animation-common.ts
@@ -11,19 +11,16 @@ import { View } from "../core/view";
// Types.
import { Color } from "../../color";
import { isEnabled as traceEnabled, write as traceWrite, categories as traceCategories } from "../../trace";
-import { PercentLength } from "../styling/style-properties";
export { Color, traceEnabled, traceWrite, traceCategories };
export { AnimationPromise } from ".";
export module Properties {
- export const opacity = "opacity";
- export const backgroundColor = "backgroundColor";
- export const translate = "translate";
- export const rotate = "rotate";
- export const scale = "scale";
- export const height = "height";
- export const width = "width";
+ export var opacity = "opacity";
+ export var backgroundColor = "backgroundColor";
+ export var translate = "translate";
+ export var rotate = "rotate";
+ export var scale = "scale";
}
export interface PropertyAnimation {
@@ -166,9 +163,6 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
throw new Error(`Property ${item} must be valid Pair. Value: ${animationDefinition[item]}`);
} else if (item === Properties.backgroundColor && !Color.isValid(animationDefinition.backgroundColor)) {
throw new Error(`Property ${item} must be valid color. Value: ${animationDefinition[item]}`);
- } else if (item === Properties.width || item === Properties.height) {
- // Coerce input into a PercentLength object in case it's a string.
- animationDefinition[item] = PercentLength.parse(animationDefinition[item]);
}
}
@@ -240,34 +234,8 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
});
}
- // height
- if (animationDefinition.height !== undefined) {
- propertyAnimations.push({
- target: animationDefinition.target,
- property: Properties.height,
- value: animationDefinition.height,
- duration: animationDefinition.duration,
- delay: animationDefinition.delay,
- iterations: animationDefinition.iterations,
- curve: animationDefinition.curve
- });
- }
-
- // width
- if (animationDefinition.width !== undefined) {
- propertyAnimations.push({
- target: animationDefinition.target,
- property: Properties.width,
- value: animationDefinition.width,
- duration: animationDefinition.duration,
- delay: animationDefinition.delay,
- iterations: animationDefinition.iterations,
- curve: animationDefinition.curve
- });
- }
-
if (propertyAnimations.length === 0) {
- throw new Error('No known animation properties specified');
+ throw new Error("No animation property specified.");
}
return propertyAnimations;
@@ -284,4 +252,4 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
curve: animation.curve
});
}
-}
+}
\ No newline at end of file
diff --git a/tns-core-modules/ui/animation/animation.android.ts b/tns-core-modules/ui/animation/animation.android.ts
index 9ee84e268..2f5c75d46 100644
--- a/tns-core-modules/ui/animation/animation.android.ts
+++ b/tns-core-modules/ui/animation/animation.android.ts
@@ -5,13 +5,12 @@ import { View } from "../core/view";
import { AnimationBase, Properties, PropertyAnimation, CubicBezierAnimationCurve, AnimationPromise, Color, traceWrite, traceEnabled, traceCategories } from "./animation-common";
import {
opacityProperty, backgroundColorProperty, rotateProperty,
- translateXProperty, translateYProperty, scaleXProperty, scaleYProperty,
- heightProperty, widthProperty, PercentLength
+ translateXProperty, translateYProperty, scaleXProperty, scaleYProperty
} from "../styling/style-properties";
import { layout } from "../../utils/utils";
import lazy from "../../utils/lazy";
-import * as platform from '../../platform';
+
export * from "./animation-common";
interface AnimationDefinitionInternal extends AnimationDefinition {
@@ -38,8 +37,6 @@ propertyKeys[Properties.opacity] = Symbol(keyPrefix + Properties.opacity);
propertyKeys[Properties.rotate] = Symbol(keyPrefix + Properties.rotate);
propertyKeys[Properties.scale] = Symbol(keyPrefix + Properties.scale);
propertyKeys[Properties.translate] = Symbol(keyPrefix + Properties.translate);
-propertyKeys[Properties.height] = Symbol(keyPrefix + Properties.height);
-propertyKeys[Properties.width] = Symbol(keyPrefix + Properties.width);
export function _resolveAnimationCurve(curve: string | CubicBezierAnimationCurve | android.view.animation.Interpolator | android.view.animation.LinearInterpolator): android.view.animation.Interpolator {
switch (curve) {
@@ -198,7 +195,7 @@ export class Animation extends AnimationBase {
}
}
- private _onAndroidAnimationCancel() { // tslint:disable-line
+ private _onAndroidAnimationCancel() { // tslint:disable-line
this._propertyResetCallbacks.forEach(v => v());
this._rejectAnimationFinishedPromise();
@@ -304,7 +301,7 @@ export class Animation extends AnimationBase {
} else {
propertyAnimation.target.style[backgroundColorProperty.keyframe] = originalValue1;
}
-
+
if (propertyAnimation.target.nativeViewProtected && propertyAnimation.target[backgroundColorProperty.setNative]) {
propertyAnimation.target[backgroundColorProperty.setNative](propertyAnimation.target.style.backgroundColor);
}
@@ -417,55 +414,16 @@ export class Animation extends AnimationBase {
} else {
propertyAnimation.target.style[rotateProperty.keyframe] = originalValue1;
}
-
+
if (propertyAnimation.target.nativeViewProtected) {
propertyAnimation.target[rotateProperty.setNative](propertyAnimation.target.style.rotate);
}
}));
animators.push(android.animation.ObjectAnimator.ofFloat(nativeView, "rotation", nativeArray));
break;
- case Properties.width:
- case Properties.height: {
- const isVertical: boolean = propertyAnimation.property === 'height';
- const extentProperty = isVertical ? heightProperty : widthProperty;
-
- extentProperty._initDefaultNativeValue(style);
- nativeArray = Array.create("float", 2);
- let toValue = propertyAnimation.value;
- let parent = propertyAnimation.target.parent as View;
- if (!parent) {
- throw new Error(`cannot animate ${propertyAnimation.property} on root view`);
- }
- const parentExtent: number = isVertical ? parent.getMeasuredHeight() : parent.getMeasuredWidth();
- toValue = PercentLength.toDevicePixels(toValue, parentExtent, parentExtent) / platform.screen.mainScreen.scale;
- const nativeHeight: number = isVertical ? nativeView.getHeight() : nativeView.getWidth();
- const targetStyle: string = setLocal ? extentProperty.name : extentProperty.keyframe;
- originalValue1 = nativeHeight / platform.screen.mainScreen.scale;
- nativeArray[0] = originalValue1;
- nativeArray[1] = toValue;
- let extentAnimator = android.animation.ValueAnimator.ofFloat(nativeArray);
- extentAnimator.addUpdateListener(new android.animation.ValueAnimator.AnimatorUpdateListener({
- onAnimationUpdate(animator: android.animation.ValueAnimator) {
- const argb = (animator.getAnimatedValue()).floatValue();
- propertyAnimation.target.style[setLocal ? extentProperty.name : extentProperty.keyframe] = argb;
- }
- }));
- propertyUpdateCallbacks.push(checkAnimation(() => {
- propertyAnimation.target.style[targetStyle] = propertyAnimation.value;
- }));
- propertyResetCallbacks.push(checkAnimation(() => {
- propertyAnimation.target.style[targetStyle] = originalValue1;
- if (propertyAnimation.target.nativeViewProtected) {
- const setter = propertyAnimation.target[extentProperty.setNative];
- setter(propertyAnimation.target.style[propertyAnimation.property]);
- }
- }));
- animators.push(extentAnimator);
- break;
- }
default:
- throw new Error(`Animating property '${propertyAnimation.property}' is unsupported`);
+ throw new Error("Cannot animate " + propertyAnimation.property);
}
for (let i = 0, length = animators.length; i < length; i++) {
diff --git a/tns-core-modules/ui/animation/animation.d.ts b/tns-core-modules/ui/animation/animation.d.ts
index f4eb79cc4..43edb439e 100644
--- a/tns-core-modules/ui/animation/animation.d.ts
+++ b/tns-core-modules/ui/animation/animation.d.ts
@@ -3,7 +3,6 @@
*/ /** */
import { View, Color } from "../core/view";
-import {PercentLength} from '../styling/style-properties';
/**
* Defines animation options for the View.animate method.
@@ -34,16 +33,6 @@ export interface AnimationDefinition {
*/
scale?: Pair;
- /**
- * Animates the height of a view.
- */
- height?: PercentLength | string;
-
- /**
- * Animates the width of a view.
- */
- width?: PercentLength | string;
-
/**
* Animates the rotate affine transform of the view. Value should be a number specifying the rotation amount in degrees.
*/
diff --git a/tns-core-modules/ui/animation/animation.ios.ts b/tns-core-modules/ui/animation/animation.ios.ts
index bc4187e08..397309615 100644
--- a/tns-core-modules/ui/animation/animation.ios.ts
+++ b/tns-core-modules/ui/animation/animation.ios.ts
@@ -4,12 +4,10 @@ import { View } from "../core/view";
import { AnimationBase, Properties, PropertyAnimation, CubicBezierAnimationCurve, AnimationPromise, traceWrite, traceEnabled, traceCategories } from "./animation-common";
import {
opacityProperty, backgroundColorProperty, rotateProperty,
- translateXProperty, translateYProperty, scaleXProperty, scaleYProperty,
- heightProperty, widthProperty, PercentLength
+ translateXProperty, translateYProperty, scaleXProperty, scaleYProperty
} from "../styling/style-properties";
import { ios } from "../../utils/utils";
-import * as platform from "../../platform";
export * from "./animation-common";
@@ -86,12 +84,6 @@ class AnimationDelegateImpl extends NSObject implements CAAnimationDelegate {
targetStyle[setLocal ? translateXProperty.name : translateXProperty.keyframe] = value;
targetStyle[setLocal ? translateYProperty.name : translateYProperty.keyframe] = value;
break;
- case Properties.height:
- targetStyle[setLocal ? heightProperty.name : heightProperty.keyframe] = value;
- break;
- case Properties.width:
- targetStyle[setLocal ? widthProperty.name : widthProperty.keyframe] = value;
- break;
case Properties.scale:
targetStyle[setLocal ? scaleXProperty.name : scaleXProperty.keyframe] = value.x === 0 ? 0.001 : value.x;
targetStyle[setLocal ? scaleYProperty.name : scaleYProperty.keyframe] = value.y === 0 ? 0.001 : value.y;
@@ -270,10 +262,8 @@ export class Animation extends AnimationBase {
let nativeView = animation.target.nativeViewProtected;
let propertyNameToAnimate = animation.property;
- let toValue = animation.value;
- let fromValue;
- const parent = animation.target.parent as View;
- const screenScale: number = platform.screen.mainScreen.scale;
+ let value = animation.value;
+ let originalValue;
let tempRotate = (animation.target.rotate || 0) * Math.PI / 180;
let abs;
@@ -286,18 +276,18 @@ export class Animation extends AnimationBase {
animation._propertyResetCallback = (value, valueSource) => {
animation.target.style[setLocal ? backgroundColorProperty.name : backgroundColorProperty.keyframe] = value;
};
- fromValue = nativeView.layer.backgroundColor;
+ originalValue = nativeView.layer.backgroundColor;
if (nativeView instanceof UILabel) {
nativeView.setValueForKey(getter(UIColor, UIColor.clearColor), "backgroundColor");
}
- toValue = toValue.CGColor;
+ value = value.CGColor;
break;
case Properties.opacity:
animation._originalValue = animation.target.opacity;
animation._propertyResetCallback = (value, valueSource) => {
animation.target.style[setLocal ? opacityProperty.name : opacityProperty.keyframe] = value;
};
- fromValue = nativeView.layer.opacity;
+ originalValue = nativeView.layer.opacity;
break;
case Properties.rotate:
animation._originalValue = animation.target.rotate !== undefined ? animation.target.rotate : 0;
@@ -305,44 +295,44 @@ export class Animation extends AnimationBase {
animation.target.style[setLocal ? rotateProperty.name : rotateProperty.keyframe] = value;
};
propertyNameToAnimate = "transform.rotation";
- fromValue = nativeView.layer.valueForKeyPath("transform.rotation");
- if (animation.target.rotate !== undefined && animation.target.rotate !== 0 && Math.floor(toValue / 360) - toValue / 360 === 0) {
- fromValue = animation.target.rotate * Math.PI / 180;
+ originalValue = nativeView.layer.valueForKeyPath("transform.rotation");
+ if (animation.target.rotate !== undefined && animation.target.rotate !== 0 && Math.floor(value / 360) - value / 360 === 0) {
+ originalValue = animation.target.rotate * Math.PI / 180;
}
- toValue = toValue * Math.PI / 180;
- abs = fabs(fromValue - toValue);
- if (abs < 0.001 && fromValue !== tempRotate) {
- fromValue = tempRotate;
+ value = value * Math.PI / 180;
+ abs = fabs(originalValue - value);
+ if (abs < 0.001 && originalValue !== tempRotate) {
+ originalValue = tempRotate;
}
break;
case Properties.translate:
- animation._originalValue = {x: animation.target.translateX, y: animation.target.translateY};
+ animation._originalValue = { x: animation.target.translateX, y: animation.target.translateY };
animation._propertyResetCallback = (value, valueSource) => {
animation.target.style[setLocal ? translateXProperty.name : translateXProperty.keyframe] = value.x;
animation.target.style[setLocal ? translateYProperty.name : translateYProperty.keyframe] = value.y;
};
propertyNameToAnimate = "transform";
- fromValue = NSValue.valueWithCATransform3D(nativeView.layer.transform);
- toValue = NSValue.valueWithCATransform3D(CATransform3DTranslate(nativeView.layer.transform, toValue.x, toValue.y, 0));
+ originalValue = NSValue.valueWithCATransform3D(nativeView.layer.transform);
+ value = NSValue.valueWithCATransform3D(CATransform3DTranslate(nativeView.layer.transform, value.x, value.y, 0));
break;
case Properties.scale:
- if (toValue.x === 0) {
- toValue.x = 0.001;
+ if (value.x === 0) {
+ value.x = 0.001;
}
- if (toValue.y === 0) {
- toValue.y = 0.001;
+ if (value.y === 0) {
+ value.y = 0.001;
}
- animation._originalValue = {x: animation.target.scaleX, y: animation.target.scaleY};
+ animation._originalValue = { x: animation.target.scaleX, y: animation.target.scaleY };
animation._propertyResetCallback = (value, valueSource) => {
animation.target.style[setLocal ? scaleXProperty.name : scaleXProperty.keyframe] = value.x;
animation.target.style[setLocal ? scaleYProperty.name : scaleYProperty.keyframe] = value.y;
};
propertyNameToAnimate = "transform";
- fromValue = NSValue.valueWithCATransform3D(nativeView.layer.transform);
- toValue = NSValue.valueWithCATransform3D(CATransform3DScale(nativeView.layer.transform, toValue.x, toValue.y, 1));
+ originalValue = NSValue.valueWithCATransform3D(nativeView.layer.transform);
+ value = NSValue.valueWithCATransform3D(CATransform3DScale(nativeView.layer.transform, value.x, value.y, 1));
break;
case _transform:
- fromValue = NSValue.valueWithCATransform3D(nativeView.layer.transform);
+ originalValue = NSValue.valueWithCATransform3D(nativeView.layer.transform);
animation._originalValue = {
xs: animation.target.scaleX, ys: animation.target.scaleY,
xt: animation.target.translateX, yt: animation.target.translateY
@@ -354,33 +344,10 @@ export class Animation extends AnimationBase {
animation.target.style[setLocal ? scaleYProperty.name : scaleYProperty.keyframe] = value.ys;
};
propertyNameToAnimate = "transform";
- toValue = NSValue.valueWithCATransform3D(Animation._createNativeAffineTransform(animation));
- break;
- case Properties.width:
- case Properties.height:
- const direction: string = animation.property;
- const isHeight: boolean = direction === 'height';
- propertyNameToAnimate = "bounds";
- if (!parent) {
- throw new Error(`cannot animate ${direction} on root view`);
- }
- const parentExtent: number = isHeight ? parent.getMeasuredHeight() : parent.getMeasuredWidth();
- const asNumber = PercentLength.toDevicePixels(PercentLength.parse(toValue), parentExtent, parentExtent) / screenScale;
- let currentBounds = nativeView.layer.bounds;
- let extentX = isHeight ? currentBounds.size.width : asNumber;
- let extentY = isHeight ? asNumber : currentBounds.size.height;
- fromValue = NSValue.valueWithCGRect(currentBounds);
- toValue = NSValue.valueWithCGRect(
- CGRectMake(currentBounds.origin.x, currentBounds.origin.y, extentX, extentY)
- );
- animation._originalValue = animation.target.height;
- animation._propertyResetCallback = (value, valueSource) => {
- const prop = isHeight ? heightProperty : widthProperty;
- animation.target.style[setLocal ? prop.name : prop.keyframe] = value;
- };
+ value = NSValue.valueWithCATransform3D(Animation._createNativeAffineTransform(animation));
break;
default:
- throw new Error(`Animating property '${animation.property}' is unsupported`);
+ throw new Error("Cannot animate " + animation.property);
}
let duration = 0.3;
@@ -405,8 +372,8 @@ export class Animation extends AnimationBase {
return {
propertyNameToAnimate: propertyNameToAnimate,
- fromValue: fromValue,
- toValue: toValue,
+ fromValue: originalValue,
+ toValue: value,
duration: duration,
repeatCount: repeatCount,
delay: delay
@@ -482,14 +449,6 @@ export class Animation extends AnimationBase {
case Properties.opacity:
animation.target.opacity = args.toValue;
break;
- case Properties.height:
- case Properties.width:
- animation._originalValue = animation.target[animation.property];
- nativeView.layer.setValueForKey(args.toValue, args.propertyNameToAnimate);
- animation._propertyResetCallback = function (value) {
- animation.target[animation.property] = value;
- };
- break;
case Properties.rotate:
nativeView.layer.setValueForKey(args.toValue, args.propertyNameToAnimate);
break;
@@ -498,11 +457,11 @@ export class Animation extends AnimationBase {
nativeView.layer.setValueForKey(args.toValue, args.propertyNameToAnimate);
animation._propertyResetCallback = function (value) {
nativeView.layer.transform = value;
- };
+ }
break;
}
- }, function (animationDidFinish: boolean) {
- if (animationDidFinish) {
+ }, function (finished: boolean) {
+ if (finished) {
if (animation.property === _transform) {
if (animation.value[Properties.translate] !== undefined) {
animation.target.translateX = animation.value[Properties.translate].x;
@@ -520,10 +479,10 @@ export class Animation extends AnimationBase {
}
}
if (finishedCallback) {
- let cancelled = !animationDidFinish;
+ let cancelled = !finished;
finishedCallback(cancelled);
}
- if (animationDidFinish && nextAnimation) {
+ if (finished && nextAnimation) {
nextAnimation();
}
});
diff --git a/tns-core-modules/ui/animation/keyframe-animation.ts b/tns-core-modules/ui/animation/keyframe-animation.ts
index cac01a59a..578b7f220 100644
--- a/tns-core-modules/ui/animation/keyframe-animation.ts
+++ b/tns-core-modules/ui/animation/keyframe-animation.ts
@@ -19,8 +19,7 @@ import {
backgroundColorProperty,
scaleXProperty, scaleYProperty,
translateXProperty, translateYProperty,
- rotateProperty, opacityProperty,
- widthProperty, heightProperty, PercentLength
+ rotateProperty, opacityProperty
} from "../styling/style-properties";
export class Keyframes implements KeyframesDefinition {
@@ -61,8 +60,6 @@ interface Keyframe {
translate?: { x: number, y: number };
rotate?: number;
opacity?: number;
- width?: PercentLength;
- height?: PercentLength;
valueSource?: "keyframe" | "animation";
duration?: number;
curve?: any;
@@ -210,12 +207,6 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
if ("opacity" in animation) {
view.style[opacityProperty.keyframe] = animation.opacity;
}
- if ("height" in animation) {
- view.style[heightProperty.keyframe] = animation.height;
- }
- if ("width" in animation) {
- view.style[widthProperty.keyframe] = animation.width;
- }
setTimeout(() => this.animate(view, 1, iterations), 1);
}
@@ -280,11 +271,5 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
if ("opacity" in animation) {
view.style[opacityProperty.keyframe] = unsetValue;
}
- if ("height" in animation) {
- view.style[heightProperty.keyframe] = unsetValue;
- }
- if ("width" in animation) {
- view.style[widthProperty.keyframe] = unsetValue;
- }
}
}
diff --git a/tns-core-modules/ui/styling/style-properties.d.ts b/tns-core-modules/ui/styling/style-properties.d.ts
index e0b907ace..163df0cdd 100644
--- a/tns-core-modules/ui/styling/style-properties.d.ts
+++ b/tns-core-modules/ui/styling/style-properties.d.ts
@@ -85,8 +85,8 @@ export const opacityProperty: CssAnimationProperty