vadimkorr / svelte-carousel

The awesome carousel component for Svelte 3 :arrow_left: :art: :arrow_right:
https://vadimkorr.github.io/svelte-carousel
Apache License 2.0
291 stars 64 forks source link

Dots current index not updated on mount #123

Open abynim opened 2 years ago

abynim commented 2 years ago

If the initialPageIndex prop is set to anything over 0, while the Carousel's content renders the correct page, the Dots always show the first Dot as selected.

Looks like the currentPageIndex in the Carousel is not set on mount. https://github.com/vadimkorr/svelte-carousel/blob/main/src/components/Carousel/Carousel.svelte#L204

Setting the currentPageIndex to match initialPageIndex on mount seems to fix it, but I don't know if that is the appropriate solution!

// Carousel.svelte Line 204

methods.showPage(initialPageIndex, { animated: false })
currentPageIndex = initialPageIndex; // Added this line