lmgonzalves / segment

A JavaScript library to draw and animate SVG path strokes
http://lmgonzalves.github.io/segment
MIT License
1.74k stars 98 forks source link

How can i add more paths? #8

Closed saadkkhan closed 8 years ago

saadkkhan commented 8 years ago

I have more than one path which i want to animate with TimelineLite plugin. How can i add more paths in the following: var s = document.getElementById("s"), // shield = document.getElementById('shield'), segment = new Segment(s);

lmgonzalves commented 8 years ago

Segment only accept a single path element, so you need to create a Segment instance for each of them. A simple example:

// Getting the elements
var s = document.getElementById("s");
var shield = document.getElementById("shield");

// Creating Segment instances
var segmentS = new Segment(s);
var segmentShield = new Segment(shield);

If you have more elements, consider handle them with loops and a proper data structure, like Arrays.