Closed braebo closed 3 years ago
Hi @FractalHQ,
Glad you're finding the project useful! I think you want to be binding the play function on the child component like so:
<script>
import { LottiePlayer } from '@lottiefiles/svelte-lottie-player';
let playLottie;
</script>
<button on:click={playLottie}>
Click to play!
</button>
<LottiePlayer
src = 'https://assets2.lottiefiles.com/packages/lf20_wxUJzo.json'
width = 400,
bind:play={playLottie}
/>
Working demo here
Awesome! This is even better than what I had
First off- thanks for this amazing package! I spent way too long trying to get lottie to play nicely with Svelte. Meanwhile this just works 🎉
Second- I've been struggling with manually triggering the play() event.
After importing with
import { LottiePlayer, play } from '@lottiefiles/svelte-lottie-player';
When I run
play()
, I'm told it's not a function.Sorry for the confusion!