Skip to content

Commit 7c210f1

Browse files
committed
Fix compiler warnings in carousel
1 parent a873d86 commit 7c210f1

1 file changed

Lines changed: 28 additions & 18 deletions

File tree

src/lib/components/ui/carousel/carousel.svelte

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,42 @@
99
1010
let {
1111
ref = $bindable(null),
12-
opts = {},
13-
plugins = [],
12+
opts: _opts = {},
13+
plugins: _plugins = [],
1414
setApi = () => {},
15-
orientation = "horizontal",
15+
orientation: _orientation = "horizontal",
1616
class: className,
1717
children,
1818
...restProps
1919
}: WithElementRef<CarouselProps> = $props();
2020
21+
const opts = $derived(_opts);
22+
const plugins = $derived(_plugins);
23+
const orientation = $derived(_orientation);
24+
2125
let carouselState = $state<EmblaContext>({
22-
api: undefined,
23-
scrollPrev,
24-
scrollNext,
25-
orientation,
26-
canScrollNext: false,
27-
canScrollPrev: false,
28-
handleKeyDown,
29-
options: opts,
30-
plugins,
31-
onInit,
32-
scrollSnaps: [],
33-
selectedIndex: 0,
34-
scrollTo,
35-
});
26+
api: undefined,
27+
scrollPrev,
28+
scrollNext,
29+
orientation: "horizontal",
30+
canScrollNext: false,
31+
canScrollPrev: false,
32+
handleKeyDown,
33+
options: {},
34+
plugins: [],
35+
onInit,
36+
scrollSnaps: [],
37+
selectedIndex: 0,
38+
scrollTo,
39+
});
40+
41+
setEmblaContext(carouselState);
3642
37-
setEmblaContext(carouselState);
43+
$effect(() => {
44+
carouselState.orientation = orientation;
45+
carouselState.options = opts;
46+
carouselState.plugins = plugins;
47+
});
3848
3949
function scrollPrev() {
4050
carouselState.api?.scrollPrev();

0 commit comments

Comments
 (0)