Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

How do I trigger the animation only once

So I have a slideshow built with Bootstrap Carousel, I have a couple items on the first 2 slides, SVGs that animate in. One is a logo drawn, the other fades in. The problem I am running into is the animation starts over when the slide cycles through once. I just want it to trigger on initial load, and then just have the SVGs static. I'm not sure how to do that. I assume JavaScript will be involved to check if the animations have been triggered, but I'm lost on if that's true or otherwise.

1 Answer

Steven Parker
Steven Parker
229,005 Points

I'm guessing these "animations" are actually CSS transitions? If so, one thing you could do is to include a special class in the CSS that will be present when the items are first loaded, but can be removed once they have been shown.

Removing the class can be done with a bit of JavaScript.