Add on:ready event or similar?
cliveportman opened this issue · 2 comments
cliveportman commented
I'm using the AOS library here: http://michalsnik.github.io/aos/
It's great and generally works well with Svelte. But mixing it with a carousel is giving me some issues, such as AOS's offset calculations being out. What I'd like to do is only initialise AOS when the carousel has built. I'm trying:
$: if (carousel) AOS.init()
But that doesn't help. Could we have an on:ready event or something like that that I can listen for before initialising AOS? I'm sure it would help others.
antony commented
@cliveportman happy for this to be the case if you can provide a PR :)
kiuKisas commented
To emulate this, I bind my carousel to a variable and wait for it to not be undefined anymore.
<script>
import Carousel from '@beyonk/svelte-carousel';
let carousel = undefined;
</script>
<div class={carousel === undefined ? 'loading' : 'ready'}></div>
<Carousel bind:this={carousel}>
...
</Carousel>