diff --git a/src/molecules/PaginationDots.svelte b/src/molecules/PaginationDots.svelte
new file mode 100644
index 0000000..39f150a
--- /dev/null
+++ b/src/molecules/PaginationDots.svelte
@@ -0,0 +1,21 @@
+
+
+
+ {#each photos as dot, index}
+ - currentIndex + 2}
+ class:hidden={index < currentIndex - 3 || index > currentIndex + 3}
+ on:click={() => dispatch('goToIndex', { index })}
+ >
+
+
+ {/each}
+
diff --git a/src/organisms/Carousel.svelte b/src/organisms/Carousel.svelte
index bf9e982..98ec575 100644
--- a/src/organisms/Carousel.svelte
+++ b/src/organisms/Carousel.svelte
@@ -12,6 +12,7 @@
// Components
import IconArrow from '../atoms/IconArrow'
import Counter from '../atoms/Counter'
+ import PaginationDots from '../molecules/PaginationDots'
// Props
export let photos
@@ -45,7 +46,6 @@
currentIndex = (currentIndex >= photos.length) ? 0 : currentIndex
} else {
currentIndex = direction
- console.log('Go to photo', direction, currentIndex)
}
// Send current photo to event
@@ -203,12 +203,8 @@
-
- {#each photos as page, index}
- - goToPhoto(index)}>
-
-
- {/each}
-
+ currentIndex = event.detail.index}
+ />
{/if}
diff --git a/src/style/organisms/_carousel.scss b/src/style/organisms/_carousel.scss
index a7facca..dfe96ef 100644
--- a/src/style/organisms/_carousel.scss
+++ b/src/style/organisms/_carousel.scss
@@ -252,16 +252,37 @@
margin-top: 32px;
li {
- display: block;
+ display: flex;
+ align-items: center;
padding: 4px;
cursor: pointer;
+ &, button {
+ transition: all 0.6s $ease-quart;
+ will-change: transform, width, height, padding;
+ }
+
+ // Active
&.active button {
background-color: $color-secondary;
transform: scale(1.25);
- will-change: scale, background-color;
}
+ // Small dot
+ &.small button {
+ transform: scale(0.6);
+ opacity: 0.5;
+ }
+ // Hidden
+ &.hidden {
+ padding: 0;
+ transform: scale(0);
+ opacity: 0;
+ width: 0;
+ height: 0;
+ }
+
+ // Hover
&:hover:not(.active) {
button {
background-color: lighten($color-lightpurple, 10);
@@ -277,7 +298,6 @@
background-color: $color-lightpurple;
border-radius: 100%;
text-decoration: none;
- transition: all 600ms $ease-quart;
}
}
}