Skip to content

Commit 7942bd1

Browse files
committed
fix: add direction tracking to carousel transitions
1 parent e20d40c commit 7942bd1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib/carousel/Carousel.svelte

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import Indicators from './Indicators.svelte';
1919
import Slide from './Slide.svelte';
2020
import { canChangeSlide } from './CarouselSlide';
21-
import type { ParamsType } from '../types'
21+
import type { ParamsType } from '../types';
2222
2323
type TransitionFunc = (node: HTMLElement, params: ParamsType) => TransitionConfig;
2424
const SLIDE_DURATION_RATIO = 0.25; // TODO: Expose one day?
@@ -61,6 +61,7 @@
6161
6262
_state.index = _state.index >= images.length - 1 ? 0 : _state.index + 1;
6363
_state.lastSlideChange = new Date();
64+
_state.forward = true;
6465
return { ..._state };
6566
});
6667
};
@@ -71,6 +72,7 @@
7172
7273
_state.index = _state.index <= 0 ? images.length - 1 : _state.index - 1;
7374
_state.lastSlideChange = new Date();
75+
_state.forward = false;
7476
return { ..._state };
7577
});
7678
};

0 commit comments

Comments
 (0)