{"id":360550,"date":"2022-01-25T06:14:11","date_gmt":"2022-01-25T14:14:11","guid":{"rendered":"https:\/\/css-tricks.com\/?p=360550"},"modified":"2022-02-09T06:39:24","modified_gmt":"2022-02-09T14:39:24","slug":"scroll-triggered-animation-vanilla-javascript","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/scroll-triggered-animation-vanilla-javascript\/","title":{"rendered":"How to Make a Scroll-Triggered Animation With Basic JavaScript"},"content":{"rendered":"\n

A little bit of animation on a site can add some flair, impress users, and get their attention. You could have them run, no matter where they are on the page, immediately when the page loads. But what if your website is fairly long so it took some time for the user to scroll down to that element? They might miss it.<\/p>\n\n\n\n

You could have them run all the time, but perhaps the animation is best designed so that you for sure see the beginning of it. The trick is to start the animation when the user scrolls down to that element \u2014 scroll-triggered animation, if you will.<\/p>\n\n\n\n\n\n\n\n