Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/components/Carousel/Carousel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@
data.particlesToScrollInit = particlesToScroll
}

/**
* Size of gap between particles in px (pixels)
*/
export let gapSize = 0
$: {
data.gapSize = gapSize
}

export async function goTo(pageIndex, options) {
const animated = get(options, 'animated', true)
if (typeof pageIndex !== 'number') {
Expand All @@ -163,12 +171,12 @@
const pageWindowElementResizeObserver = createResizeObserver(({
width,
}) => {
pageWindowWidth = width
pageWindowWidth = width + data.gapSize
data.particleWidth = pageWindowWidth / data.particlesToShow

applyParticleSizes({
particlesContainerChildren: particlesContainer.children,
particleWidth: data.particleWidth,
particleWidth: data.particleWidth - data.gapSize,
})
methods.offsetPage({ animated: false })
})
Expand Down Expand Up @@ -286,6 +294,7 @@
on:swipeFailed={handleSwipeFailed}
on:swipeThresholdReached={handleSwipeThresholdReached}
style="
gap: {gapSize}px;
transform: translateX({offset}px);
transition-duration: {durationMs}ms;
transition-timing-function: {timingFunction};
Expand Down