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.

playSegments runs whole animation

See original GitHub issue

I am implementing ng-lottie in my angular 4 app. I am trying to play a segment when the animation is created. But on creation, it plays the whole animation at first then loop through the segment. Here is my code -

//Lottie configuration in component.
this.lottieConfig = {
    renderer: 'svg',
    loop: true,
    prerender: false,
    autoplay: false,
    autoloadSegments: false,
    path: './assets/content/data_3.json'
};

//HTML code
<lottie-animation-view [options]="lottieConfig" (animCreated)="handleAnimation($event)" (click)="onAnimationClick()"></lottie-animation-view>

//Handle animation function on animation create
handleAnimation(anim: any) {
	this.anim = anim;
	this.anim.playSegments([[0,479]],true);
} 

Although I am able to find a solution by adding timeout in handleAnimation function. But I do not know if this is the correct way to solve this issue.

//Handle animation function code with timeout
handleAnimation(anim: any) {
	this.anim = anim;

	setTimeout(() => {
		this.anim.playSegments([[0,479]],true);
	} , 1);
}

Just think that it has something to do with this issue https://github.com/bodymovin/bodymovin/issues/398

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chenqingspringcommented, May 31, 2017

I just made the config autoloadSegments: false work in v0.2.1

Can you please try it, and give me some feedback? Thanks!

0reactions
1pocketaces1commented, Apr 20, 2018

Also I cannot get the proper syntax for playSegments(). Console is telling me I need ‘:’ instead of a comma?

Read more comments on GitHub >

github_iconTop Results From Across the Web

The `playSegments()` plays the whole animation before ...
The playSegments() plays the whole animation before playing the segment ... it lets the current segment play and then runs the enqueued one?...
Read more >
android: play segment of Lottie animation - Stack Overflow
It sets the minimum frame that the animation will start from when playing or looping. lottie_toggle.setMinFrame(minFrame);. It sets the minimum ...
Read more >
[Lottie Animations] playSegments - OutSystems
There is no solution for my question in that post, thats why I create a new post. Playsegment is used when you want...
Read more >
EASIEST Way To Play Parts Of Lottie Animations - YouTube
Named markers are a great way to easily identify and play different parts of your Lottie animations, saving you from having to find...
Read more >
How To Play Segments Of Lottie Animations - YouTube
Segments of Lottie animations can be played using the playSegments function of Lottie-web. You can play different segments of your animation ...
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