How do you loop a single segment and not all segments?
See original GitHub issueI have several icons that have an intro animation [0,20] where they get drawn in and a loop animation [21, 100] for when you hover over the icons. Setting loop to true will make all my segments loop which is not what I want, I only need one of the segments to loop. Anyway do this?
Here’s an example of how I have my code setup:
var data = {
container: el,
renderer: 'svg',
loop: false,
autoplay: false,
path: 'data.json'
};
var anim = bodymovin.loadAnimation(data);
anim.addEventListener('DOMLoaded', function(e) {
anim.playSegments([0,20], true); // run intro animation
});
el.addEventListener('mouseover', function(e) {
anim.playSegments([21,100], true); // run loop animation
});
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
javascript - Efficiently ordering line segments into a loop
Set one end of each segment as First, and another end as second (randomly). Sort your segments by their first x and put...
Read more >Segment Matching Issues
In the analysis tool, select the missing segment and copy the link in the address bar of the webpage. Paste the link into...
Read more >Output is not as expected when a segment in a nested loop ...
Inbound processing and the mapper looping output is not as expected when one segment ends an inner and outer loop in the Header...
Read more >EDI Loops
Rule #1: Each Loop has Loop ID and may contain one or more Segments · Rule #2: Each Loop has only one segment...
Read more >Adding or deleting segments, loops, and elements from an ...
Select the number of segments or loops to add and then click OK. After adding a segment, you can: Add one or more...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

To set a new segment you need to wait for the animation to be loaded, that’s why the first invocation isn’t working. you can use
this.playButtonAnimator.addEventListener('DOMLoaded',()=>{})For the rest of the issue, can you post a working implementation?You can do anim.playSegments([[0,20],[21,100]],true) and it will loop only the final segment. You can also set directly the “loop” property to false/true on the animation instance.