0

The angular 2 animate documentation is very poor, so I started playing with it and decided to make some nice animation like fading, between 2 images.

My current image has the animation trigger all set up:

<img src="myimage.png" class="img img-responsive"
            [@travelState]="travelState"
            >

animations: [
    trigger('travelState', [
      state('inactive', style({

      })),
      state('active',   style({
//Change image src
      })),
      transition('inactive => active', animate('100ms ease-in')),
      transition('active => inactive', animate('100ms ease-out'))
    ])
  ]

Now, switching between inactive state and active state has to change the image src attribute to another image, with fading transition. How I can change the src image attribute when the image triggers active state?

2 Answers 2

1

Angular 2 animations are built on top of the W3C's CSS3 transitions API. As you can see from their list of animatable properties, you cannot animate the src property.

You can, however, achieve essentially the same effect by layering both images on top of each other (see here if you need help doing that) and animating the opacity of whichever image is on top.

Sign up to request clarification or add additional context in comments.

Comments

0

Sounds like you want to use the onDone callback that will be included in RC.6

https://github.com/angular/angular/issues/10304

2 Comments

Cool, thanks. So until then I can apply only CSS styles such as backgroundImage to an animation state?
I haven't used animation myself yet and have actually no idea what you're talking about :D I just remembered seeing this issue and related PR and got the impression this is related.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.