From 8973a6febde4a4b41637d80b17506a7d25ffebf8 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Thu, 7 Dec 2017 12:11:24 +0200 Subject: [PATCH] Revert "feat(animation): support animating width/height properties (WIP) (#4917)" (#5136) This reverts commit 57ed0cf405be44e31358ff17f372b5d926e63639. --- .../animation/animation-army-100.ts | 114 ------------- .../animation/animation-army-100.xml | 157 ------------------ .../animation/animation-curves.ts | 72 -------- .../animation/animation-curves.xml | 31 ---- .../animation/effect-summary-details.ts | 79 --------- .../animation/effect-summary-details.xml | 13 -- .../ui-tests-app/animation/height-basic.ts | 17 -- .../ui-tests-app/animation/height-basic.xml | 10 -- .../animation/layout-stack-height.ts | 12 -- .../animation/layout-stack-height.xml | 16 -- apps/app/ui-tests-app/animation/main-page.ts | 20 --- apps/app/ui-tests-app/animation/main-page.xml | 6 - apps/app/ui-tests-app/main-page.ts | 3 +- .../ui-tests-app/test-page-main-view-model.ts | 1 - tests/app/testRunner.ts | 2 +- tests/app/ui/animation/animation-tests.ts | 114 +------------ .../app/ui/styling/style-properties-tests.ts | 55 ------ tns-core-modules/globals/globals.ts | 2 +- .../ui/animation/animation-common.ts | 46 +---- .../ui/animation/animation.android.ts | 54 +----- tns-core-modules/ui/animation/animation.d.ts | 11 -- .../ui/animation/animation.ios.ts | 107 ++++-------- .../ui/animation/keyframe-animation.ts | 17 +- .../ui/styling/style-properties.d.ts | 4 +- .../ui/styling/style-properties.ts | 34 +--- 25 files changed, 56 insertions(+), 941 deletions(-) delete mode 100644 apps/app/ui-tests-app/animation/animation-army-100.ts delete mode 100644 apps/app/ui-tests-app/animation/animation-army-100.xml delete mode 100644 apps/app/ui-tests-app/animation/animation-curves.ts delete mode 100644 apps/app/ui-tests-app/animation/animation-curves.xml delete mode 100644 apps/app/ui-tests-app/animation/effect-summary-details.ts delete mode 100644 apps/app/ui-tests-app/animation/effect-summary-details.xml delete mode 100644 apps/app/ui-tests-app/animation/height-basic.ts delete mode 100644 apps/app/ui-tests-app/animation/height-basic.xml delete mode 100644 apps/app/ui-tests-app/animation/layout-stack-height.ts delete mode 100644 apps/app/ui-tests-app/animation/layout-stack-height.xml delete mode 100644 apps/app/ui-tests-app/animation/main-page.ts delete mode 100644 apps/app/ui-tests-app/animation/main-page.xml 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 @@ - - - - -