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

CSS

Control animations through cookies?

Hey, everyone!

I've just watched the SVG Animation course by Guil H. and added animation to the front-page of my practice website. (http://learnedbytreehouse.com/, for @media > 75rem)

So, the question is: I want to run this animation only when the user comes to my website for the first time. Is it possible to solve this problem? Could we somehow control the CSS through the cookies?

Thx!

1 Answer

You need to use javascript to check for the cookie and then run the animation. Alternatively, you could also use PHP to do that as well, and add a class to the element if the cookie doe not exist.

Something like https://github.com/carhartl/jquery-cookie could help out with all of this.