11import { AnimationPlayer } from "@angular/core" ;
22import { AnimationKeyframe } from "./private_import_core" ;
3- import { KeyframeAnimation , KeyframeAnimationInfo , KeyframeInfo , KeyframeDeclaration } from 'ui/animation/keyframe-animation' ;
3+ import {
4+ KeyframeAnimation ,
5+ KeyframeAnimationInfo ,
6+ KeyframeInfo ,
7+ KeyframeDeclaration
8+ } from "ui/animation/keyframe-animation" ;
49import { View } from "ui/core/view" ;
510import { AnimationCurve } from "ui/enums" ;
6- import { ValueSource } from ' ui/core/dependency-observable' ;
11+ import { ValueSource } from " ui/core/dependency-observable" ;
712import { isString } from "utils/types" ;
8- import * as styleProperty from ' ui/styling/style-property' ;
13+ import * as styleProperty from " ui/styling/style-property" ;
914
1015export class NativeScriptAnimationPlayer implements AnimationPlayer {
1116
@@ -18,7 +23,13 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
1823 private animation : KeyframeAnimation ;
1924 private target : View ;
2025
21- constructor ( element : Node , keyframes : AnimationKeyframe [ ] , duration : number , delay : number , easing : string ) {
26+ constructor (
27+ element : Node ,
28+ keyframes : AnimationKeyframe [ ] ,
29+ duration : number ,
30+ delay : number ,
31+ easing : string
32+ ) {
2233
2334 this . parentPlayer = null ;
2435
@@ -36,7 +47,9 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
3647 keyframeAnimationInfo . duration = duration ;
3748 keyframeAnimationInfo . delay = delay ;
3849 keyframeAnimationInfo . iterations = 1 ;
39- keyframeAnimationInfo . curve = easing ? NativeScriptAnimationPlayer . animationTimingFunctionConverter ( easing ) : AnimationCurve . ease ;
50+ keyframeAnimationInfo . curve = easing ?
51+ NativeScriptAnimationPlayer . animationTimingFunctionConverter ( easing ) :
52+ AnimationCurve . ease ;
4053 keyframeAnimationInfo . keyframes = new Array < KeyframeInfo > ( ) ;
4154 keyframeAnimationInfo . isForwards = true ;
4255
@@ -53,16 +66,16 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
5366 value = property . valueConverter ( < string > value ) ;
5467 }
5568 keyframeInfo . declarations . push ( { property : property . name , value : value } ) ;
56- }
57- else if ( typeof value === "string" && substyle === "transform" ) {
69+ } else if ( typeof value === "string" && substyle === "transform" ) {
5870 NativeScriptAnimationPlayer . parseTransform ( < string > value , keyframeInfo ) ;
5971 }
6072 }
6173 }
6274 keyframeAnimationInfo . keyframes . push ( keyframeInfo ) ;
6375 }
6476
65- this . animation = KeyframeAnimation . keyframeAnimationFromInfo ( keyframeAnimationInfo , ValueSource . VisualState ) ;
77+ this . animation = KeyframeAnimation . keyframeAnimationFromInfo (
78+ keyframeAnimationInfo , ValueSource . VisualState ) ;
6679 }
6780
6881 init ( ) : void {
@@ -159,8 +172,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
159172 NativeScriptAnimationPlayer . bezieArgumentConverter ( bezierArr [ 1 ] ) ,
160173 NativeScriptAnimationPlayer . bezieArgumentConverter ( bezierArr [ 2 ] ) ,
161174 NativeScriptAnimationPlayer . bezieArgumentConverter ( bezierArr [ 3 ] ) ) ;
162- }
163- else {
175+ } else {
164176 throw new Error ( "Invalid value for animation: " + value ) ;
165177 }
166178 }
@@ -178,16 +190,14 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
178190 let operations = { } ;
179191 operations [ value ] = value ;
180192 return operations ;
181- }
182- else if ( isString ( value ) ) {
193+ } else if ( isString ( value ) ) {
183194 let operations = { } ;
184195 let operator = "" ;
185196 let pos = 0 ;
186197 while ( pos < value . length ) {
187198 if ( value [ pos ] === " " || value [ pos ] === "," ) {
188199 pos ++ ;
189- }
190- else if ( value [ pos ] === "(" ) {
200+ } else if ( value [ pos ] === "(" ) {
191201 let start = pos + 1 ;
192202 while ( pos < value . length && value [ pos ] !== ")" ) {
193203 pos ++ ;
@@ -196,14 +206,12 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
196206 operations [ operator ] = operand . trim ( ) ;
197207 operator = "" ;
198208 pos ++ ;
199- }
200- else {
209+ } else {
201210 operator += value [ pos ++ ] ;
202211 }
203212 }
204213 return operations ;
205- }
206- else {
214+ } else {
207215 return undefined ;
208216 }
209217 }
@@ -215,29 +223,50 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
215223 for ( let transform in newTransform ) {
216224 switch ( transform ) {
217225 case "scaleX" :
218- animationInfo . declarations . push ( { property : "scale" , value : { x : parseFloat ( newTransform [ transform ] ) , y : 1 } } ) ;
226+ animationInfo . declarations . push ( {
227+ property : "scale" ,
228+ value : { x : parseFloat ( newTransform [ transform ] ) , y : 1 }
229+ } ) ;
219230 break ;
220231 case "scaleY" :
221- animationInfo . declarations . push ( { property : "scale" , value : { x : 1 , y : parseFloat ( newTransform [ transform ] ) } } ) ;
232+ animationInfo . declarations . push ( {
233+ property : "scale" ,
234+ value : { x : 1 , y : parseFloat ( newTransform [ transform ] ) }
235+ } ) ;
222236 break ;
223237 case "scale" :
224238 case "scale3d" :
225239 values = newTransform [ transform ] . split ( "," ) ;
226240 if ( values . length === 2 || values . length === 3 ) {
227- animationInfo . declarations . push ( { property : "scale" , value : { x : parseFloat ( values [ 0 ] ) , y : parseFloat ( values [ 1 ] ) } } ) ;
241+ animationInfo . declarations . push ( {
242+ property : "scale" ,
243+ value : { x : parseFloat ( values [ 0 ] ) , y : parseFloat ( values [ 1 ] ) }
244+ } ) ;
228245 }
229246 break ;
230247 case "translateX" :
231- animationInfo . declarations . push ( { property : "translate" , value : { x : parseFloat ( newTransform [ transform ] ) , y : 0 } } ) ;
248+ animationInfo . declarations . push ( {
249+ property : "translate" ,
250+ value : { x : parseFloat ( newTransform [ transform ] ) , y : 0 }
251+ } ) ;
232252 break ;
233253 case "translateY" :
234- animationInfo . declarations . push ( { property : "translate" , value : { x : 0 , y : parseFloat ( newTransform [ transform ] ) } } ) ;
254+ animationInfo . declarations . push ( {
255+ property : "translate" ,
256+ value : { x : 0 , y : parseFloat ( newTransform [ transform ] ) }
257+ } ) ;
235258 break ;
236259 case "translate" :
237260 case "translate3d" :
238261 values = newTransform [ transform ] . split ( "," ) ;
239262 if ( values . length === 2 || values . length === 3 ) {
240- animationInfo . declarations . push ( { property : "translate" , value : { x : parseFloat ( values [ 0 ] ) , y : parseFloat ( values [ 1 ] ) } } ) ;
263+ animationInfo . declarations . push ( {
264+ property : "translate" ,
265+ value : {
266+ x : parseFloat ( values [ 0 ] ) ,
267+ y : parseFloat ( values [ 1 ] )
268+ }
269+ } ) ;
241270 }
242271 break ;
243272 case "rotate" :
@@ -250,9 +279,12 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
250279 break ;
251280 case "none" :
252281 animationInfo . declarations . push ( { property : "scale" , value : { x : 1 , y : 1 } } ) ;
253- animationInfo . declarations . push ( { property : "translate" , value : { x : 0 , y : 0 } } ) ;
282+ animationInfo . declarations . push (
283+ { property : "translate" , value : { x : 0 , y : 0 } } ) ;
254284 animationInfo . declarations . push ( { property : "rotate" , value : 0 } ) ;
255285 break ;
286+ default :
287+ throw new Error ( "Unsupported transform: " + transform ) ;
256288 }
257289 }
258290 return array ;
0 commit comments