{"_id":"@coryparsnipson/svelte-carousel","name":"@coryparsnipson/svelte-carousel","dist-tags":{"latest":"1.0.19"},"versions":{"1.0.19":{"name":"@coryparsnipson/svelte-carousel","version":"1.0.19","description":"Svelte carousel","main":"src/main.js","author":{"name":"vadimkorr"},"repository":{"type":"git","url":"git+https://github.com/vadimkorr/svelte-carousel.git"},"bugs":{"url":"https://github.com/vadimkorr/svelte-carousel/issues"},"homepage":"https://github.com/vadimkorr/svelte-carousel#readme","keywords":["svelte","carousel","slider","svelte carousel","image carousel"],"license":"Apache-2.0","scripts":{"start":"sirv docs","storybook":"start-storybook -p 6006","build:docs":"rollup -c","dev:docs":"rollup -c -w","test":"jest"},"devDependencies":{"@babel/core":"^7.12.10","@babel/plugin-transform-runtime":"^7.14.5","@babel/preset-env":"^7.12.11","@rollup/plugin-commonjs":"^17.0.0","@rollup/plugin-image":"^2.1.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.0.0","@storybook/addon-actions":"^6.1.14","@storybook/addon-essentials":"^6.1.14","@storybook/addon-links":"^6.1.14","@storybook/svelte":"^6.1.14","babel-loader":"^8.2.2","jest":"^26.6.3","lodash":"^4.17.20","mdsvex":"^0.8.9","rollup":"^2.3.4","rollup-plugin-babel":"^4.4.0","rollup-plugin-import-css":"^2.0.1","rollup-plugin-livereload":"^2.0.0","rollup-plugin-svelte":"^7.0.0","rollup-plugin-terser":"^7.0.0","sirv-cli":"^1.0.11","svelte":"^3.31.2","svelte-loader":"^2.13.6"},"dependencies":{"simply-reactive":"github:vadimkorr/simply-reactive#1.0.2"},"directories":{"doc":"docs"},"gitHead":"9d039db8d25425a169f4b286cedddb4f331837ab","_id":"@coryparsnipson/svelte-carousel@1.0.19","_nodeVersion":"18.3.0","_npmVersion":"8.11.0","dist":{"integrity":"sha512-jJq0kjenmncNFOWUHxDdqDKAgyHsbbLJ2/3Rdg/5061iWmCm4u1PO3nfjP1fHnhveGECwDq9iduV9SixBx02Xw==","shasum":"4a4af9452fc5a0062210577041d796026f978f80","tarball":"https://registry.npmjs.org/@coryparsnipson/svelte-carousel/-/svelte-carousel-1.0.19.tgz","fileCount":32,"unpackedSize":64132,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFd3HrdSs5f2ok1j3/px44mJoPedInYTHCNsyeRSw7XYAiAp7nVI64NrGWLorMQwLiy3Sran2yN90CrQ7+qmEnh3AA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJitTGkACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpJOw/7BFzv8DAH36aph8Lrm7rLX8jOeANs52Eww73593isbTs9L8if\r\njySoF+GaEzBNJXUflr87BdZPmuq4WploWkB6jJ/p+kNVcmx4wQS3rbUddf8Z\r\nwsgK2yYOIurVKQoATkHtIFxX6ZLpEfMLYIUBflQfbsFGFTeO1Nr1yJ+DXcbu\r\nunh4/E9XRM3w7+lOsbOigvREYJOANvOM7t4l4vKgcIow/W/JjtnUprYG3YG4\r\nJ7G+37iU9OvS4JgDdUsz+If9unNQaBqhtrAmehR+261buxArsD48iYidKmFC\r\nbqZVtKwAbzJLlmcS0VzUJnCGfR3dN+QUzzhfhjaQhYPkxOpH41tQOa2DP1hE\r\n37DP0nFg0Z0MLbMryLVHJOEoHPP6b3+62XlV4n+l8/6OtMGDEIrWtorExBM3\r\n5nGHiaHET1mqNrIoH8aSWghbr0sA2FDEkVRNbO1ls3/FYVEPJMyE4ZyK5pOM\r\nGt2yM+dGCIxY1IdT/UeF8bG3Bqi4wKAMGl5zMPU8D8fXxDEruly5V+RYhAJb\r\nWxo4tkYjznWBfqBbKD/+2PvDDJFYxsLbCse0yIwTvWSwlfWFpksMTOiC5s9D\r\nKhoZnLb42q9+kpsjPWoJh4ZqqDeC5SvH2GuJJGsjUgo/2XxFLvQ8MfyfFldK\r\nuqfQnnwd8OSzUzhKC5bszXskKlJJtTPIrhU=\r\n=Gj+S\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"coryparsnipson","email":"cparsnipson@gmail.com"},"maintainers":[{"name":"coryparsnipson","email":"cparsnipson@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-carousel_1.0.19_1656041892202_0.6640203753354463"},"_hasShrinkwrap":false}},"time":{"created":"2022-06-24T03:38:12.121Z","1.0.19":"2022-06-24T03:38:12.370Z","modified":"2022-06-24T03:38:12.531Z"},"maintainers":[{"name":"coryparsnipson","email":"cparsnipson@gmail.com"}],"description":"Svelte carousel","homepage":"https://github.com/vadimkorr/svelte-carousel#readme","keywords":["svelte","carousel","slider","svelte carousel","image carousel"],"repository":{"type":"git","url":"git+https://github.com/vadimkorr/svelte-carousel.git"},"author":{"name":"vadimkorr"},"bugs":{"url":"https://github.com/vadimkorr/svelte-carousel/issues"},"license":"Apache-2.0","readme":"![svelte-carousel](./docs/svelte-carousel-logo-md.png)\n\n\n# svelte-carousel\n\n<div align=\"left\">\n\n[![npm](https://img.shields.io/npm/v/svelte-carousel.svg)](https://www.npmjs.com/package/svelte-carousel) [![npm](https://img.shields.io/npm/dm/svelte-carousel.svg)](https://www.npmjs.com/package/svelte-carousel)\n<br />\n[![GitHub repo](https://img.shields.io/badge/github-repo-green.svg?style=flat)](https://github.com/vadimkorr/svelte-carousel) [![GitHub followers](https://img.shields.io/github/followers/vadimkorr.svg?style=social&label=Follow)](https://github.com/vadimkorr)\n\n</div>\n\nThe awesome carousel component for Svelte 3\n\n## Demo\n* [vadimkorr.github.io/svelte-carousel](https://vadimkorr.github.io/svelte-carousel)\n* [REPL](https://svelte.dev/repl/f503a458832f4a358d9ec00f88945ff5)\n\n## Installation\n```bash\nyarn add svelte-carousel\n```\n```bash\nnpm install svelte-carousel\n```\n\nImport component\n```jsx\n<script>\n  import Carousel from 'svelte-carousel'\n  // ...\n</script>\n```\n\n## SvelteKit support\nThere are several things to keep in mind when `svelte-carousel` is used with SvelteKit. This is because `svelte-carousel` is a client-side library and depends on `document` and `window`. [See more in SvelteKit FAQ](https://kit.svelte.dev/faq).\n\n1. Install `svelte-carousel` as a dev dependency. [Why as a dev dependency?](https://github.com/sveltejs/sapper-template#using-external-components)\n\n```bash\nyarn add svelte-carousel -D\n```\n```bash\nnpm install svelte-carousel -D\n```\n\n2. Extend `kit` in `svelte.config.js` to include the `vite` property\n\n```js\nconst config = {\n  // existing props\n  kit: {\n    // existing props\n    vite: { optimizeDeps: { include: ['lodash.get', 'lodash.isequal', 'lodash.clonedeep'] } }\n  }\n}\n```\n\n3. Import and use it:\n\n```jsx\n\n<script>\n  import { onMount } from 'svelte';\n\n  let Carousel; // for saving Carousel component class\n  let carousel; // for calling methods of the carousel instance\n  onMount(async () => {\n    const module = await import('svelte-carousel');\n    Carousel = module.default;\n  });\n\n  const handleNextClick = () => {\n    carousel.goToNext()\n  }\n</script>\n\n<svelte:component\n  this={Carousel}\n  bind:this={carousel}\n>\n  <div>1</div>\n  <div>2</div>\n  <div>3</div>\n</svelte:component>\n\n<button on:click={handleNextClick}>Next</button>\n```\n\n## Vite support\n1. Extend `optimizeDeps.include` in `vite.config.js`\n\n```js\nexport default defineConfig({\n  optimizeDeps: {\n    include: ['lodash.get', 'lodash.isequal', 'lodash.clonedeep']\n  }\n})\n\n```\n\n2. Import and use it:\n\n```jsx\n\n<script>\n  import Carousel from 'svelte-carousel'\n\n  let carousel; // for calling methods of the carousel instance\n  const handleNextClick = () => {\n    carousel.goToNext()\n  }\n</script>\n\n<Carousel\n  bind:this={carousel}\n>\n  <div>1</div>\n  <div>2</div>\n  <div>3</div>\n</Carousel>\n\n<button on:click={handleNextClick}>Next</button>\n```\n\n## Props\n| Prop                      | Type       | Default         | Description                                   | \n|---------------------------|------------|-----------------|-----------------------------------------------|\n| `arrows`                  | `boolean`  | `true`          | Enables next/prev arrows                      |\n| `infinite`                | `boolean`  | `true`          | Infinite looping                              |\n| `initialPageIndex`        | `number`   | `0`             | Page to start on                              |\n| `duration`                | `number`   | `500`           | Transition duration (ms)                      |\n| `autoplay`                | `boolean`  | `false`         | Enables autoplay of pages                     |\n| `autoplayDuration`        | `number`   | `3000`          | Autoplay change interval (ms)                 |\n| `autoplayDirection`       | `string`   | `'next'`        | Autoplay change direction (`next` or `prev`)  |\n| `pauseOnFocus`            | `boolean`  | `false`         | Pauses autoplay on focus (for touchable devices - tap the carousel to toggle the autoplay, for non-touchable devices - hover over the carousel to pause the autoplay) |\n| `autoplayProgressVisible` | `boolean`  | `false`         | Shows autoplay duration progress indicator    |\n| `dots`                    | `boolean`  | `true`          | Current page indicator dots                   |\n| `timingFunction`          | `string`   | `'ease-in-out'` | CSS animation timing function                 |\n| `swiping`                 | `boolean`  | `true`          | Enables swiping                               |\n| `particlesToShow`         | `number`   | `1`             | Number of elements to show                    |\n| `particlesToScroll`       | `number`   | `1`             | Number of elements to scroll                  |\n\n## Events\n\n### `pageChange`\nIt is dispatched on page change\n\n| Payload field      | Type        | Description                           | \n|--------------------|-------------|---------------------------------------|\n| `event.detail`     | `number`    | Current page index                    |\n\n```jsx\n<Carousel\n  on:pageChange={\n    event => console.log(`Current page index: ${event.detail}`)\n  }\n>\n  <!-- -->\n</Carousel>\n```\n\n## Slots\n\n### `prev` and `next`\nThey are used for customizing prev and next buttons.\n\nSlot props:\n\n| Prop               | Type        | Description                           | \n|--------------------|-------------|---------------------------------------|\n| `showPrevPage`     | `function`  | Call it to switch to the previos page |\n| `showNextPage`     | `function`  | Call it to switch to the next page    |\n\n```jsx\n<Carousel\n  let:showPrevPage\n  let:showNextPage\n>\n  <div slot=\"prev\">\n    <!-- -->\n  </div>\n  <div slot=\"next\">\n    <!-- -->\n  </div>\n  <!-- -->\n</Carousel>\n```\n\n### `dots`\nThis slot is used for customizing how dots look like.\n\nSlot props:\n\n| Prop                | Type         | Description                                  | \n|---------------------|--------------|----------------------------------------------|\n| `currentPageIndex`  | `number`     | Represents current page index (start from 0) |\n| `pagesCount`        | `number`     | Total pages amount                           |\n| `showPage`          | `function`   | Takes index as page to be shown              |\n\n```jsx\n<Carousel\n  let:currentPageIndex\n  let:pagesCount\n  let:showPage\n>\n  <div slot=\"dots\">\n    <!-- -->\n  </div>\n  <!-- -->\n</Carousel>\n```\n\n### Default slot\nThis slot takes content for the carousel.\n\nSlot props:\n\n| Prop              | Type       | Description                                                          | \n|-------------------|------------|----------------------------------------------------------------------|\n| `loaded`          | `number[]` | Contains indexes of pages to be loaded. Can be used for lazy loading |\n\n```jsx\n<Carousel\n  let:loaded\n>\n  <div>\n    <!-- -->\n  </div>\n  <!-- -->\n</Carousel>\n```\n\n## Methods\n\n### `goTo`\nNavigates to a page by index. `(pageIndex, options) => Promise<void>`.\n\nArguments:\n\n| Argument           | Type        | Default | Description                           | \n|--------------------|-------------|---------|---------------------------------------|\n| `pageIndex`        | `number`    |         | Page number                           |\n| `options.animated` | `boolean`   | `true`  | Should it be animated or not          |\n\n```jsx\n<script>\n  // ...\n  let carousel;\n  function goToStartPage() {\n    carousel.goTo(0, { animated: false })\n  }\n</script>\n\n<Carousel\n  bind:this={carousel}\n>\n  <!--  -->\n</Carousel>\n<button class=\"button\" on:click={goToStartPage}>Go</button>\n```\n\n### `goToPrev`\nNavigates to the previous page. `(options) => Promise<void>`.\n\nArguments:\n\n| Argument           | Type        | Default | Description                   | \n|--------------------|-------------|---------|-------------------------------|\n| `options.animated` | `boolean`   | `true`  | Should it be animated or not  |\n\n```jsx\n<script>\n  // ...\n  let carousel;\n  function goToPrevPage() {\n    carousel.goToPrev({ animated: false })\n  }\n</script>\n\n<Carousel\n  bind:this={carousel}\n>\n  <!--  -->\n</Carousel>\n<button class=\"button\" on:click={goToPrevPage}>Go</button>\n```\n\n### `goToNext`\nNavigates to the next page. `(options) => Promise<void>`.\n\nArguments:\n\n| Argument           | Type        | Default | Description                  | \n|--------------------|-------------|---------|------------------------------|\n| `options.animated` | `boolean`   | `true`  | Should it be animated or not |\n\n```jsx\n<script>\n  // ...\n  let carousel;\n  function goToNextPage() {\n    carousel.goToNext({ animated: false })\n  }\n</script>\n\n<Carousel\n  bind:this={carousel}\n>\n  <!--  -->\n</Carousel>\n<button class=\"button\" on:click={goToNextPage}>Go</button>\n```\n","readmeFilename":"README.md"}