Skip to content

fix: add direction tracking to carousel component #1574

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lib/carousel/Carousel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import Indicators from './Indicators.svelte';
import Slide from './Slide.svelte';
import { canChangeSlide } from './CarouselSlide';
import type { ParamsType } from '../types'
import type { ParamsType } from '../types';

type TransitionFunc = (node: HTMLElement, params: ParamsType) => TransitionConfig;
const SLIDE_DURATION_RATIO = 0.25; // TODO: Expose one day?
Expand Down Expand Up @@ -61,6 +61,7 @@

_state.index = _state.index >= images.length - 1 ? 0 : _state.index + 1;
_state.lastSlideChange = new Date();
_state.forward = true;
return { ..._state };
});
};
Expand All @@ -71,6 +72,7 @@

_state.index = _state.index <= 0 ? images.length - 1 : _state.index - 1;
_state.lastSlideChange = new Date();
_state.forward = false;
return { ..._state };
});
};
Expand Down