@@ -168,59 +168,65 @@ export class Animation extends common.Animation implements definition.Animation
168168 }
169169
170170 trace . write ( "UIView.beginAnimationsContext(" + index + "): " + common . Animation . _getAnimationInfo ( animation ) , trace . categories . Animation ) ;
171- UIView . beginAnimationsContext ( index . toString ( ) , null ) ;
172171
173- if ( animationDelegate ) {
174- UIView . setAnimationDelegate ( animationDelegate ) ;
175- UIView . setAnimationWillStartSelector ( "animationWillStart" ) ;
176- UIView . setAnimationDidStopSelector ( "animationDidStop" ) ;
177- }
172+ UIView . animateKeyframesWithDurationDelayOptionsAnimationsCompletion ( 1 , 0 ,
173+ UIViewKeyframeAnimationOptions . UIViewKeyframeAnimationOptionBeginFromCurrentState ,
174+ ( ) => {
175+ UIView . addKeyframeWithRelativeStartTimeRelativeDurationAnimations ( 0 , 1 , ( ) => {
176+ if ( animationDelegate ) {
177+ UIView . setAnimationDelegate ( animationDelegate ) ;
178+ UIView . setAnimationWillStartSelector ( "animationWillStart" ) ;
179+ UIView . setAnimationDidStopSelector ( "animationDidStop" ) ;
180+ }
178181
179- if ( animation . duration !== undefined ) {
180- UIView . setAnimationDuration ( animation . duration / 1000.0 ) ;
181- }
182- else {
183- UIView . setAnimationDuration ( 0.3 ) ; //Default duration.
184- }
185- if ( animation . delay !== undefined ) {
186- UIView . setAnimationDelay ( animation . delay / 1000.0 ) ;
187- }
188- if ( animation . iterations !== undefined ) {
189- if ( animation . iterations === Number . POSITIVE_INFINITY ) {
190- UIView . setAnimationRepeatCount ( FLT_MAX ) ;
191- }
192- else {
193- UIView . setAnimationRepeatCount ( animation . iterations - 1 ) ;
194- }
195- }
196- if ( animation . curve !== undefined ) {
197- UIView . setAnimationCurve ( animation . curve ) ;
198- }
182+ if ( animation . duration !== undefined ) {
183+ UIView . setAnimationDuration ( animation . duration / 1000.0 ) ;
184+ }
185+ else {
186+ UIView . setAnimationDuration ( 0.3 ) ; //Default duration.
187+ }
188+ if ( animation . delay !== undefined ) {
189+ UIView . setAnimationDelay ( animation . delay / 1000.0 ) ;
190+ }
191+ if ( animation . iterations !== undefined ) {
192+ if ( animation . iterations === Number . POSITIVE_INFINITY ) {
193+ UIView . setAnimationRepeatCount ( FLT_MAX ) ;
194+ }
195+ else {
196+ UIView . setAnimationRepeatCount ( animation . iterations - 1 ) ;
197+ }
198+ }
199+ if ( animation . curve !== undefined ) {
200+ UIView . setAnimationCurve ( animation . curve ) ;
201+ }
199202
200- var originalValue ;
201- switch ( animation . property ) {
202- case common . Properties . opacity :
203- originalValue = animation . target . opacity ;
204- ( < any > animation ) . _propertyResetCallback = ( ) => { animation . target . opacity = originalValue } ;
205- animation . target . opacity = animation . value ;
206- break ;
207- case common . Properties . backgroundColor :
208- originalValue = animation . target . backgroundColor ;
209- ( < any > animation ) . _propertyResetCallback = ( ) => { animation . target . backgroundColor = originalValue } ;
210- animation . target . backgroundColor = animation . value ;
211- break ;
212- case _transform :
213- originalValue = nativeView . transform ;
214- ( < any > animation ) . _propertyResetCallback = ( ) => { nativeView . transform = originalValue } ;
215- nativeView . transform = Animation . _createNativeAffineTransform ( animation ) ;
216- break ;
217- default :
218- throw new Error ( "Cannot animate " + animation . property ) ;
219- break ;
220- }
203+ var originalValue ;
204+ switch ( animation . property ) {
205+ case common . Properties . opacity :
206+ originalValue = animation . target . opacity ;
207+ ( < any > animation ) . _propertyResetCallback = ( ) => { animation . target . opacity = originalValue } ;
208+ animation . target . opacity = animation . value ;
209+ break ;
210+ case common . Properties . backgroundColor :
211+ originalValue = animation . target . backgroundColor ;
212+ ( < any > animation ) . _propertyResetCallback = ( ) => { animation . target . backgroundColor = originalValue } ;
213+ animation . target . backgroundColor = animation . value ;
214+ break ;
215+ case _transform :
216+ originalValue = nativeView . transform ;
217+ ( < any > animation ) . _propertyResetCallback = ( ) => { nativeView . transform = originalValue } ;
218+ nativeView . transform = Animation . _createNativeAffineTransform ( animation ) ;
219+ break ;
220+ default :
221+ throw new Error ( "Cannot animate " + animation . property ) ;
222+ break ;
223+ }
224+ } )
225+ } ,
226+ null
227+ ) ;
221228
222229 trace . write ( "UIView.commitAnimations " + index , trace . categories . Animation ) ;
223- UIView . commitAnimations ( ) ;
224230
225231 if ( ! playSequentially && nextAnimationCallback ) {
226232 nextAnimationCallback ( ) ;
0 commit comments