Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #37 from johnyvelho/fix/dots
Browse files Browse the repository at this point in the history
Generating and activating Dots properly
  • Loading branch information
antony authored Jun 24, 2020
2 parents 2076437 + 26eb4c0 commit 7c67f2e
Show file tree
Hide file tree
Showing 3 changed files with 595 additions and 40 deletions.
316 changes: 295 additions & 21 deletions dist/index.js

Large diffs are not rendered by default.

309 changes: 292 additions & 17 deletions dist/index.mjs

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions src/Carousel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</div>
{#if dots}
<ul>
{#each pips as pip, i}
<li on:click={() => go(i)} class={currentIndex === i ? "active" : ""}></li>
{#each {length: totalDots} as _, i}
<li on:click={() => go(i*perPage)} class={isDotActive(currentIndex, i) ? "active" : ""}></li>
{/each}
</ul>
{/if}
Expand Down Expand Up @@ -100,6 +100,7 @@
const dispatch = createEventDispatcher()
$: pips = controller ? controller.innerElements : []
$: totalDots = controller ? Math.ceil(controller.innerElements.length / perPage) : []
onMount(() => {
controller = new Siema({
Expand All @@ -125,6 +126,11 @@
controller.destroy()
}
})
export function isDotActive (currentIndex, dotIndex) {
if (currentIndex < 0) currentIndex = pips.length + currentIndex;
return currentIndex >= dotIndex*perPage && currentIndex < (dotIndex*perPage)+perPage
}
export function left () {
controller.prev()
Expand Down

0 comments on commit 7c67f2e

Please sign in to comment.