@mark8t/core
v1.1.0-rc-0.35
Published
<div align="left">
Downloads
17
Readme
Svelte Card Carousel
The ultimate carousel component for Svelte 3.
Demo
Installation
yarn add your-package-name
npm install your-package-name
pnpm install your-package-name
Import Component
<script>
import Carousel from 'your-package-name';
...
</script>
SvelteKit Support
If you're using SvelteKit, follow these additional steps:
- Install as a dev dependency.
pnpm install your-package-name -D
- Extend
kit
insvelte.config.js
to include thevite
property.
const config = {
kit: {
vite: {
optimizeDeps: {
include: ['dependency1', 'dependency2']
}
}
}
}
Props
| Prop | Type | Default | Description |
|-------------------|-----------|---------|-----------------------------------|
| data
| array
| []
| An array of card data objects. |
| autoScroll
| boolean
| false
| Enable/disable auto-scrolling. |
| autoScrollSpeed
| number
| 3000
| Speed of auto-scrolling in ms. |
| dragAcceleration
| number
| 1.5
| Acceleration factor for drag. |
| wrapLeft
| boolean
| true
| Enable/disable wrap to last item. |
| wrapRight
| boolean
| true
| Enable/disable wrap to first item.|
Events
onCardClick
Triggered when a card is clicked.
<Carousel on:cardClick={handleCardClick} />
Methods
goToPage(index)
Navigate to a specific page by index.
carousel.goToPage(2);
Troubleshooting
If you encounter the "document is not defined" error while running Vitest, make sure to include jsdom
to simulate a DOM environment.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
MIT