diff --git a/src/organisms/Carousel.svelte b/src/organisms/Carousel.svelte
index 25a244d..c2a915a 100644
--- a/src/organisms/Carousel.svelte
+++ b/src/organisms/Carousel.svelte
@@ -8,6 +8,7 @@
// Dependencies
import SwipeListener from 'swipe-listener'
+ import lazySizes from 'lazysizes'
// Animations
import { animateIn } from 'animations/Carousel'
@@ -29,6 +30,34 @@
$: prevPhoto = photos[currentIndex - 1] || photos[photos.length - 1]
$: nextPhoto = photos[currentIndex + 1] || photos[0]
+ // Default size for the image
+ const defaultWidth = 900
+ const defaultHeight = Math.ceil(defaultWidth / 1.5)
+
+
+ // Get lazyload class
+ const getLazyloadClass = index => {
+ console.log(index, currentIndex)
+ // Preload current photo
+ if (index === currentIndex || index >= currentIndex - 2 && index <= currentIndex + 2) {
+ return true
+ }
+ // Preload the two previous and next photos
+ if (index >= currentIndex - 2 && index <= currentIndex + 2) {
+ return true
+ }
+ // If currentIndex = last photo, preload the two first ones
+ if (currentIndex === photos.length - 1 && (index === 0 || index === 1)) {
+ return true
+ }
+ // return false
+ // If currentIndex = first photo, preload the two last ones
+ // if (index) {
+
+ // }
+ return false
+ }
+
/*
** Navigate to a photo
@@ -112,9 +141,7 @@
*/
onMount(() => {
// Entering transition
- if (photos) {
- animateIn(scope)
- }
+ animateIn(scope)
// Enable gestures
const touch = SwipeListener(scope)
@@ -132,7 +159,6 @@