"npm Basics (retiring)" was retired on April 9, 2022. You are now viewing the recommended replacement.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Animating SVG with CSS!
You have completed Animating SVG with CSS!
In this video, you will learn how to use the stroke-dasharray and stroke-dashoffset properties to create line animations.
CORRECTION: Creating an Animated Line Drawing
- Add a stroke to the path
- Set
stroke-dasharray
equal to the path's total length - Set
stroke-dashoffset
the same asstroke-dasharray
- Animate
stroke-dashoffset
back to0
Getting a path's total length using JavaScript
For example:
const path = document.querySelector('.logo');
const length = path.getTotalLength();
Quick Reference
Animated Line Drawing Examples
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up