@@ -285,8 +285,35 @@ export class Img extends ImageBase {
285285 this . src = src ;
286286 }
287287
288- public _setNativeImage ( nativeImage : UIImage ) {
289- this . nativeViewProtected . image = nativeImage ;
288+ public _setNativeImage ( nativeImage : UIImage , animated = true ) {
289+
290+ if ( animated ) {
291+ // switch (this.transition) {
292+ // case 'fade':
293+ this . nativeViewProtected . alpha = 0.0 ;
294+ this . nativeViewProtected . image = nativeImage ;
295+ UIView . animateWithDurationAnimations ( this . fadeDuration / 1000 , ( ) => {
296+ this . nativeViewProtected . alpha = this . opacity ;
297+ } ) ;
298+ // break;
299+ // case 'curlUp':
300+ // UIView.transitionWithViewDurationOptionsAnimationsCompletion(
301+ // this.nativeViewProtected,
302+ // 0.3,
303+ // UIViewAnimationOptions.TransitionCrossDissolve,
304+ // () => {
305+ // this._setNativeImage(image);
306+ // },
307+ // null
308+ // );
309+ // break;
310+ // default:
311+ // this._setNativeImage(image);
312+ // }
313+ } else {
314+ this . nativeViewProtected . image = nativeImage ;
315+ }
316+
290317 if ( this . _imageSourceAffectsLayout ) {
291318 this . _imageSourceAffectsLayout = false ;
292319 this . requestLayout ( ) ;
@@ -295,33 +322,9 @@ export class Img extends ImageBase {
295322
296323 private handleImageLoaded = ( image : UIImage , error : NSError , cacheType : number ) => {
297324 this . isLoading = false ;
325+ const animate = ( this . alwaysFade || cacheType !== SDImageCacheType . Memory ) && this . fadeDuration > 0 ;
298326 if ( image ) {
299- if ( ( this . alwaysFade || cacheType !== SDImageCacheType . Memory ) && this . fadeDuration > 0 ) {
300- // switch (this.transition) {
301- // case 'fade':
302- this . nativeViewProtected . alpha = 0.0 ;
303- this . _setNativeImage ( image ) ;
304- UIView . animateWithDurationAnimations ( this . fadeDuration / 1000 , ( ) => {
305- this . nativeViewProtected . alpha = this . opacity ;
306- } ) ;
307- // break;
308- // case 'curlUp':
309- // UIView.transitionWithViewDurationOptionsAnimationsCompletion(
310- // this.nativeViewProtected,
311- // 0.3,
312- // UIViewAnimationOptions.TransitionCrossDissolve,
313- // () => {
314- // this._setNativeImage(image);
315- // },
316- // null
317- // );
318- // break;
319- // default:
320- // this._setNativeImage(image);
321- // }
322- } else {
323- this . _setNativeImage ( image ) ;
324- }
327+ this . _setNativeImage ( image , animate ) ;
325328 }
326329 if ( ! this . autoPlayAnimations ) {
327330 this . nativeViewProtected . stopAnimating ( ) ;
@@ -337,7 +340,7 @@ export class Img extends ImageBase {
337340 this . notify ( args ) ;
338341 if ( this . failureImageUri ) {
339342 image = this . getUIImage ( this . failureImageUri ) ;
340- this . _setNativeImage ( image ) ;
343+ this . _setNativeImage ( image , animate ) ;
341344 }
342345 } else if ( image ) {
343346 const args = {
@@ -388,8 +391,9 @@ export class Img extends ImageBase {
388391 if ( this . nativeViewProtected ) {
389392 const src = this . src ;
390393 if ( src ) {
394+ const animate = this . fadeDuration > 0 ;
391395 if ( src instanceof ImageSource ) {
392- this . _setNativeImage ( src . ios ) ;
396+ this . _setNativeImage ( src . ios , animate ) ;
393397 return ;
394398 } else if ( typeof src === 'string' ) {
395399 if ( isFontIconURI ( src ) ) {
@@ -398,7 +402,7 @@ export class Img extends ImageBase {
398402 // support sync mode only
399403 const font = this . style . fontInternal ;
400404 const color = this . style . color ;
401- this . _setNativeImage ( ImageSource . fromFontIconCodeSync ( fontIconCode , font , color ) . ios ) ;
405+ this . _setNativeImage ( ImageSource . fromFontIconCodeSync ( fontIconCode , font , color ) . ios , animate ) ;
402406 }
403407 return ;
404408 }
0 commit comments