From e8f5ac8522954b4433fa8932032d9fc03d33819e Mon Sep 17 00:00:00 2001 From: Ryan Pendergast Date: Fri, 10 Jan 2020 04:59:46 -0600 Subject: [PATCH] feat: Add 3D rotation to view - takeover of PR# 5950 (#8136) * feat: add 3d rotation * chore: fix build errors * chore: fix tslint errors * chore: add @types/chai dev dep * chore: unused import cleanup * chore: update tests for x,y rotation * chore: rebase upstream/master * fix: iOS Affine Transform test verification * feat(css): Added optional css-tree parser (#8076) * feat(css): Added optional css-tree parser * test: css-tree parser compat tests * test: more css-tree compat tests * feat(dialogs): Setting the size of popup dialog thru dialog options (#8041) * Added iOS specific height and width attributes to ShowModalOptions * Set the height and width of the popup dialog to the presenting controller * dialog options ios attributes presentationStyle, height & width are made optional * Updated NativeScript.api.md for public API changes * Update with git properties * Public API * CLA update * fix: use iOS native-helper for 3d-rotate * test: Fix tests using _getTransformMismatchError * fix: view.__hasTransfrom not set updating properly * test: fix css-animations test page Co-authored-by: Alexander Vakrilov Co-authored-by: Darin Dimitrov Co-authored-by: Shailesh Lolam Co-authored-by: Dimitar Topuzov --- api-reports/NativeScript.api.md | 12 +- e2e/animation/app/3d-rotate/page.ts | 40 ++++ e2e/animation/app/3d-rotate/page.xml | 24 ++ .../app/css-animations/3d-rotate/page.css | 75 ++++++ .../app/css-animations/3d-rotate/page.ts | 35 +++ .../app/css-animations/3d-rotate/page.xml | 22 ++ e2e/animation/app/css-animations/page.ts | 2 +- e2e/animation/app/css-animations/page.xml | 1 + e2e/animation/app/home/home-page.xml | 3 +- nativescript-core/matrix/matrix.ts | 16 +- nativescript-core/package.json | 3 +- .../ui/animation/animation-common.ts | 47 ++-- .../ui/animation/animation.android.ts | 126 +++++----- nativescript-core/ui/animation/animation.d.ts | 18 +- .../ui/animation/animation.ios.ts | 223 ++++++++++++------ .../ui/animation/keyframe-animation.ts | 8 +- nativescript-core/ui/core/view/view-common.ts | 21 ++ .../ui/core/view/view.android.ts | 19 +- nativescript-core/ui/core/view/view.d.ts | 23 +- nativescript-core/ui/core/view/view.ios.ts | 59 +++-- .../ui/styling/style-properties.ts | 52 +++- nativescript-core/ui/styling/style-scope.ts | 2 + nativescript-core/ui/styling/style/style.d.ts | 3 + nativescript-core/ui/styling/style/style.ts | 4 + nativescript-core/utils/native-helper.d.ts | 11 +- nativescript-core/utils/native-helper.ios.ts | 28 ++- nativescript-core/utils/utils.d.ts | 1 + nativescript-core/utils/utils.ios.ts | 4 +- tests/app/ui/animation/animation-tests.ts | 1 + tests/app/ui/animation/css-animation-tests.ts | 10 +- .../android/org.nativescript.widgets.d.ts | 8 + 31 files changed, 709 insertions(+), 192 deletions(-) create mode 100644 e2e/animation/app/3d-rotate/page.ts create mode 100644 e2e/animation/app/3d-rotate/page.xml create mode 100644 e2e/animation/app/css-animations/3d-rotate/page.css create mode 100644 e2e/animation/app/css-animations/3d-rotate/page.ts create mode 100644 e2e/animation/app/css-animations/3d-rotate/page.xml diff --git a/api-reports/NativeScript.api.md b/api-reports/NativeScript.api.md index 3c1d17ad5..f6f2c8e68 100644 --- a/api-reports/NativeScript.api.md +++ b/api-reports/NativeScript.api.md @@ -243,7 +243,8 @@ export interface AnimationDefinition { opacity?: number; - rotate?: number; + // Warning: (ae-forgotten-export) The symbol "Point3D" needs to be exported by the entry point index.d.ts + rotate?: number | Point3D; scale?: Pair; @@ -2086,6 +2087,8 @@ export class Style extends Observable { // (undocumented) public paddingTop: Length; // (undocumented) + public perspective: number; + // (undocumented) public placeholderColor: Color; // Warning: (ae-forgotten-export) The symbol "PropertyBagClass" needs to be exported by the entry point index.d.ts public readonly PropertyBag: PropertyBagClass; @@ -2094,6 +2097,10 @@ export class Style extends Observable { // (undocumented) public rotate: number; // (undocumented) + public rotateX: number; + // (undocumented) + public rotateY: number; + // (undocumented) public scaleX: number; // (undocumented) public scaleY: number; @@ -2702,12 +2709,15 @@ export abstract class View extends ViewBase { opacity: number; originX: number; originY: number; + perspective: number; // (undocumented) _redrawNativeBackground(value: any): void; // (undocumented) _removeAnimation(animation: Animation): boolean; public static resolveSizeAndState(size: number, specSize: number, specMode: number, childMeasuredState: number): number; rotate: number; + rotateX: number; + rotateY: number; scaleX: number; scaleY: number; _setCurrentLayoutBounds(left: number, top: number, right: number, bottom: number): { boundsChanged: boolean, sizeChanged: boolean }; diff --git a/e2e/animation/app/3d-rotate/page.ts b/e2e/animation/app/3d-rotate/page.ts new file mode 100644 index 000000000..e9f473cd8 --- /dev/null +++ b/e2e/animation/app/3d-rotate/page.ts @@ -0,0 +1,40 @@ +import { EventData, Page } from "tns-core-modules/ui/page"; +import { View } from "tns-core-modules/ui/core/view"; +import { Point3D } from "tns-core-modules/ui/animation/animation"; + +let view: View; + +export function pageLoaded(args: EventData) { + const page = args.object; + view = page.getViewById("view"); +} + +export function onAnimateX(args: EventData) { + rotate({ x: 360, y: 0, z: 0 }); +} + +export function onAnimateY(args: EventData) { + rotate({ x: 0, y: 360, z: 0 }); +} + +export function onAnimateZ(args: EventData) { + rotate({ x: 0, y: 0, z: 360 }); +} + +export function onAnimateXYZ(args: EventData) { + rotate({ x: 360, y: 360, z: 360 }); +} + +async function rotate(rotate: Point3D) { + await view.animate({ + rotate, + duration: 1000 + }); + reset(); +} + +function reset() { + view.rotate = 0; + view.rotateX = 0; + view.rotateY = 0; +} diff --git a/e2e/animation/app/3d-rotate/page.xml b/e2e/animation/app/3d-rotate/page.xml new file mode 100644 index 000000000..c56b6a9fa --- /dev/null +++ b/e2e/animation/app/3d-rotate/page.xml @@ -0,0 +1,24 @@ + + + + + + + + +