Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
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 up-
Sadaf Partovi
Front End Web Development Techdegree Graduate 14,594 Points1 Answer
-
gene c
13,630 PointsShouldn't the last step of animating line drawings be animating stroke-dashOFFSET to 0 instead of stroke-dasharray?
Posted by gene cgene c
13,630 Points3 Answers
-
armand Rodriguez
7,830 Points1 Answer
-
Ross Wilkinson
5,430 Points1 Answer
-
Daniel Garcia
12,877 Points0 Answers
-
Megan Weber
32,795 PointsTrying to Use Javascript to Initialize Array & Offset. Why is it Not Working?
Posted by Megan WeberMegan Weber
32,795 Points1 Answer
-
Edgar Gil
13,322 PointsSomething II Notice stroke-dasharray finding the perfect length.
Posted by Edgar GilEdgar Gil
13,322 Points0 Answers
-
Stetson Nash
17,603 Points0 Answers
-
Alex Oates
7,171 Points0 Answers
-
Pier-Luc Cossette
4,588 Points1 Answer
-
Amanda Williamson
1,295 Points1 Answer
View all discussions for this video
Related 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