@beyonk/svelte-carousel
Advanced tools
Comparing version 2.5.0 to 2.6.0
@@ -616,6 +616,8 @@ (function (global, factory) { | ||
autoplay && setInterval(right, autoplay); | ||
if(autoplay) { | ||
timer = setInterval(right, autoplay); | ||
} | ||
return () => { | ||
autoplay && clearTimeout(timer); | ||
autoplay && clearInterval(timer); | ||
controller.destroy(); | ||
@@ -636,3 +638,13 @@ } | ||
} | ||
function pause() { | ||
clearInterval(timer); | ||
} | ||
function resume() { | ||
if (autoplay) { | ||
timer = setInterval(right, autoplay); | ||
} | ||
} | ||
function handleChange (event) { | ||
@@ -696,2 +708,4 @@ $$invalidate('currentIndex', currentIndex = controller.currentSlide); | ||
go, | ||
pause, | ||
resume, | ||
pips, | ||
@@ -709,4 +723,24 @@ div0_binding, | ||
if (!document.getElementById("svelte-1ppqxio-style")) add_css(); | ||
init(this, options, instance, create_fragment, safe_not_equal, ["perPage", "loop", "autoplay", "duration", "easing", "startIndex", "draggable", "multipleDrag", "dots", "threshold", "rtl"]); | ||
init(this, options, instance, create_fragment, safe_not_equal, ["perPage", "loop", "autoplay", "duration", "easing", "startIndex", "draggable", "multipleDrag", "dots", "threshold", "rtl", "left", "right", "go", "pause", "resume"]); | ||
} | ||
get left() { | ||
return this.$$.ctx.left; | ||
} | ||
get right() { | ||
return this.$$.ctx.right; | ||
} | ||
get go() { | ||
return this.$$.ctx.go; | ||
} | ||
get pause() { | ||
return this.$$.ctx.pause; | ||
} | ||
get resume() { | ||
return this.$$.ctx.resume; | ||
} | ||
} | ||
@@ -713,0 +747,0 @@ |
@@ -6,3 +6,3 @@ { | ||
"main": "dist/index.js", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"scripts": { | ||
@@ -9,0 +9,0 @@ "build": "rollup -c", |
@@ -121,1 +121,29 @@ <p align="center"> | ||
| `change` | `{ currentSlide, slideCount }` | `currentSlide`: The current slide index. Can be a positive or negative integer. `slideCount`: The number of slides. | | ||
### Actions | ||
You can call left, right, go(slideNumber), pause and resume functions on the slider. For example, for pausing the autoslide while the mouse is hover the carousel | ||
```jsx | ||
<Carousel bind:this={carousel} on:mouseenter={enter} on:mouseleave={leave}> | ||
<div class="slide-content">Slide 1</div> | ||
... | ||
<div class="slide-content">Slide n</div> | ||
</Carousel> | ||
<script> | ||
import Carousel from './Carousel.svelte' | ||
let carousel; | ||
function enter() { | ||
carousel.pause(); | ||
} | ||
function leave() { | ||
carousel.resume(); | ||
} | ||
</script> | ||
``` | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
79734
1394
148