question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do you loop a single segment and not all segments?

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
bodymovincommented, Jul 27, 2018

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?

2reactions
bodymovincommented, Aug 22, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found