1
1
import { AnimationKeyframe } from '@angular/core/src/animation/animation_keyframe' ;
2
2
import { AnimationPlayer } from '@angular/core/src/animation/animation_player' ;
3
- import { AnimationStyles } from '@angular/core/src/animation/animation_styles' ;
4
- import { AnimationDriver } from '@angular/core/src/animation/animation_driver' ;
5
3
import { KeyframeAnimation , KeyframeAnimationInfo , KeyframeInfo , KeyframeDeclaration } from 'ui/animation/keyframe-animation' ;
6
4
import { View } from "ui/core/view" ;
7
5
import enums = require( "ui/enums" ) ;
@@ -10,14 +8,14 @@ import observable = require('ui/core/dependency-observable');
10
8
import types = require( "utils/types" ) ;
11
9
12
10
export class NativeScriptAnimationPlayer implements AnimationPlayer {
13
-
11
+
14
12
public parentPlayer : AnimationPlayer ;
15
13
16
14
private _subscriptions : Function [ ] = [ ] ;
17
15
private _finished = false ;
18
16
private animation : KeyframeAnimation ;
19
17
private target : View ;
20
-
18
+
21
19
constructor ( element : Node , keyframes : AnimationKeyframe [ ] , duration : number , delay : number , easing : string ) {
22
20
23
21
this . parentPlayer = null ;
@@ -52,14 +50,14 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
52
50
if ( typeof value === "string" && property . valueConverter ) {
53
51
value = property . valueConverter ( < string > value ) ;
54
52
}
55
- keyframeInfo . declarations . push ( { property : property . name , value : value } )
53
+ keyframeInfo . declarations . push ( { property : property . name , value : value } ) ;
56
54
}
57
55
else if ( typeof value === "string" && substyle === "transform" ) {
58
56
NativeScriptAnimationPlayer . parseTransform ( < string > value , keyframeInfo ) ;
59
57
}
60
58
}
61
59
}
62
- keyframeAnimationInfo . keyframes . push ( keyframeInfo )
60
+ keyframeAnimationInfo . keyframes . push ( keyframeInfo ) ;
63
61
}
64
62
65
63
this . animation = KeyframeAnimation . keyframeAnimationFromInfo ( keyframeAnimationInfo , observable . ValueSource . VisualState ) ;
@@ -79,7 +77,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
79
77
if ( this . animation ) {
80
78
this . animation . play ( this . target )
81
79
. then ( ( ) => { this . _onFinish ( ) ; } )
82
- . catch ( ( e ) => { } ) ;
80
+ . catch ( ( e ) => { } ) ;
83
81
}
84
82
}
85
83
@@ -110,11 +108,11 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
110
108
setPosition ( p : any ) : void {
111
109
throw new Error ( "AnimationPlayer.setPosition method is not supported!" ) ;
112
110
}
113
-
111
+
114
112
getPosition ( ) : number {
115
113
return 0 ;
116
114
}
117
-
115
+
118
116
static animationTimingFunctionConverter ( value ) : any {
119
117
switch ( value ) {
120
118
case "ease" :
@@ -136,9 +134,9 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
136
134
throw new Error ( "Invalid value for animation: " + value ) ;
137
135
}
138
136
return enums . AnimationCurve . cubicBezier (
139
- NativeScriptAnimationPlayer . bezieArgumentConverter ( bezierArr [ 0 ] ) ,
140
- NativeScriptAnimationPlayer . bezieArgumentConverter ( bezierArr [ 1 ] ) ,
141
- NativeScriptAnimationPlayer . bezieArgumentConverter ( bezierArr [ 2 ] ) ,
137
+ NativeScriptAnimationPlayer . bezieArgumentConverter ( bezierArr [ 0 ] ) ,
138
+ NativeScriptAnimationPlayer . bezieArgumentConverter ( bezierArr [ 1 ] ) ,
139
+ NativeScriptAnimationPlayer . bezieArgumentConverter ( bezierArr [ 2 ] ) ,
142
140
NativeScriptAnimationPlayer . bezieArgumentConverter ( bezierArr [ 3 ] ) ) ;
143
141
}
144
142
else {
@@ -154,7 +152,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
154
152
return result ;
155
153
}
156
154
157
- static transformConverter ( value : any ) : Object {
155
+ static transformConverter ( value : any ) : Object {
158
156
if ( value === "none" ) {
159
157
let operations = { } ;
160
158
operations [ value ] = value ;
@@ -166,20 +164,20 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
166
164
let pos = 0 ;
167
165
while ( pos < value . length ) {
168
166
if ( value [ pos ] === " " || value [ pos ] === "," ) {
169
- pos ++ ;
167
+ pos ++ ;
170
168
}
171
169
else if ( value [ pos ] === "(" ) {
172
170
let start = pos + 1 ;
173
171
while ( pos < value . length && value [ pos ] !== ")" ) {
174
- pos ++ ;
172
+ pos ++ ;
175
173
}
176
174
let operand = value . substring ( start , pos ) ;
177
175
operations [ operator ] = operand . trim ( ) ;
178
176
operator = "" ;
179
- pos ++ ;
177
+ pos ++ ;
180
178
}
181
179
else {
182
- operator += value [ pos ++ ] ;
180
+ operator += value [ pos ++ ] ;
183
181
}
184
182
}
185
183
return operations ;
@@ -196,29 +194,29 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
196
194
for ( let transform in newTransform ) {
197
195
switch ( transform ) {
198
196
case "scaleX" :
199
- animationInfo . declarations . push ( { property : "scale" , value : { x : parseFloat ( newTransform [ transform ] ) , y : 1 } } ) ;
197
+ animationInfo . declarations . push ( { property : "scale" , value : { x : parseFloat ( newTransform [ transform ] ) , y : 1 } } ) ;
200
198
break ;
201
199
case "scaleY" :
202
- animationInfo . declarations . push ( { property : "scale" , value : { x : 1 , y : parseFloat ( newTransform [ transform ] ) } } ) ;
200
+ animationInfo . declarations . push ( { property : "scale" , value : { x : 1 , y : parseFloat ( newTransform [ transform ] ) } } ) ;
203
201
break ;
204
202
case "scale" :
205
203
case "scale3d" :
206
204
values = newTransform [ transform ] . split ( "," ) ;
207
205
if ( values . length === 2 || values . length === 3 ) {
208
- animationInfo . declarations . push ( { property : "scale" , value : { x : parseFloat ( values [ 0 ] ) , y : parseFloat ( values [ 1 ] ) } } ) ;
206
+ animationInfo . declarations . push ( { property : "scale" , value : { x : parseFloat ( values [ 0 ] ) , y : parseFloat ( values [ 1 ] ) } } ) ;
209
207
}
210
208
break ;
211
209
case "translateX" :
212
- animationInfo . declarations . push ( { property : "translate" , value : { x : parseFloat ( newTransform [ transform ] ) , y : 0 } } ) ;
210
+ animationInfo . declarations . push ( { property : "translate" , value : { x : parseFloat ( newTransform [ transform ] ) , y : 0 } } ) ;
213
211
break ;
214
212
case "translateY" :
215
- animationInfo . declarations . push ( { property : "translate" , value : { x : 0 , y : parseFloat ( newTransform [ transform ] ) } } ) ;
213
+ animationInfo . declarations . push ( { property : "translate" , value : { x : 0 , y : parseFloat ( newTransform [ transform ] ) } } ) ;
216
214
break ;
217
215
case "translate" :
218
216
case "translate3d" :
219
217
values = newTransform [ transform ] . split ( "," ) ;
220
218
if ( values . length === 2 || values . length === 3 ) {
221
- animationInfo . declarations . push ( { property : "translate" , value : { x : parseFloat ( values [ 0 ] ) , y : parseFloat ( values [ 1 ] ) } } ) ;
219
+ animationInfo . declarations . push ( { property : "translate" , value : { x : parseFloat ( values [ 0 ] ) , y : parseFloat ( values [ 1 ] ) } } ) ;
222
220
}
223
221
break ;
224
222
case "rotate" :
@@ -227,11 +225,11 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
227
225
if ( text . slice ( - 3 ) === "rad" ) {
228
226
val = val * ( 180.0 / Math . PI ) ;
229
227
}
230
- animationInfo . declarations . push ( { property : "rotate" , value : val } ) ;
228
+ animationInfo . declarations . push ( { property : "rotate" , value : val } ) ;
231
229
case "none" :
232
- animationInfo . declarations . push ( { property : "scale" , value : { x : 1 , y : 1 } } ) ;
233
- animationInfo . declarations . push ( { property : "translate" , value : { x : 0 , y : 0 } } ) ;
234
- animationInfo . declarations . push ( { property : "rotate" , value : 0 } ) ;
230
+ animationInfo . declarations . push ( { property : "scale" , value : { x : 1 , y : 1 } } ) ;
231
+ animationInfo . declarations . push ( { property : "translate" , value : { x : 0 , y : 0 } } ) ;
232
+ animationInfo . declarations . push ( { property : "rotate" , value : 0 } ) ;
235
233
break ;
236
234
}
237
235
}
0 commit comments