1.0.3 • Published 8 months ago

svelte-card-carousel v1.0.3

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

Svelte Card Carousel

npm npm GitHub repo GitHub followers

The ultimate card carousel component for Svelte 4.

Demo

Installation

yarn add svelte-card-carousel
npm i svelte-card-carousel
pnpm i svelte-card-carousel

Import Component

<script>
  import Carousel from 'svelte-card-carousel';
  ...
</script>

Usage

<Carousel
  data={data}
  autoScroll={true}
  autoScrollSpeed={3000}
  dragAcceleration={1.5}
  wrapLeft={true}
  wrapRight={true}
/>

Data

{
	"cards": [
		{
			"imageSrc": "https://source.unsplash.com/featured/?landscape",
			"videoSrc": "https://www.shutterstock.com/shutterstock/videos/1052743418/preview/stock-footage--aerial-drone-distant-sunset-view-of-tour-eiffel-tower-and-seine-river-bridge-traffic-cars-driving.webm",
			"title": "Stunning Random, Landscape",
			"label": "Nature",
			"paragraph": "This is a beautiful landscape. The rolling hills stretch out as far as the eye can see. The sky above is a brilliant blue, dotted with fluffy clouds.",
			"buttonText": "Learn More",
			"buttonLink": "https://google.ca/"
		}
  ]
}

SvelteKit Support

If you're using SvelteKit, follow these additional steps: 1. Install as a dev dependency.

pnpm i svelte-card-carousel -D
  1. Extend kit in svelte.config.js to include the vite property.
const config = {
  kit: {
    vite: {
      optimizeDeps: {
        include: ['svelte-card-carousel']
      }
    }
  }
}

Props

PropTypeDefaultDescription
dataarray[]An array of card data objects.
autoScrollbooleanfalseEnable/disable auto-scrolling.
autoScrollSpeednumber3000Speed of auto-scrolling in ms.
dragAccelerationnumber1.5Acceleration factor for drag.
wrapLeftbooleantrueEnable/disable wrap to last item.
wrapRightbooleantrueEnable/disable wrap to first item.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago