Repository navigation
Expand file tree
/
Copy pathSlide.svelte
More file actions
55 lines (47 loc) · 1.42 KB
/
Copy pathSlide.svelte
File metadata and controls
55 lines (47 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<script lang="ts">
import type { SlideProps } from "$lib";
import { getTheme } from "$lib/theme/themeUtils";
import clsx from "clsx";
import { getCarouselContext } from "$lib/context";
import { fly } from "svelte/transition";
import { slide } from "./theme";
const _state = getCarouselContext();
let { image, transition, fit, class: className, ...restProps }: SlideProps = $props();
const theme = $derived(getTheme("slide"));
let transitionSlideIn = $derived({
x: _state?.forward ? "100%" : "-100%",
opacity: 1,
width: "100%",
height: "100%",
duration: _state?.slideDuration ?? 1000
});
let transitionSlideOut = $derived({
x: _state?.forward ? "-100%" : "100%",
opacity: 0.9,
width: "100%",
height: "100%",
duration: _state?.slideDuration ?? 1000
});
let imgClass = $derived(slide({ fit, class: clsx(theme, className) }));
</script>
{#if transition}
{#key image}
<img alt="..." {...image} transition:transition={{}} {...restProps} class={imgClass} />
{/key}
{:else}
{#key image}
<img alt="..." {...image} {...restProps} out:fly={transitionSlideOut} in:fly={transitionSlideIn} class={imgClass} />
{/key}
{/if}
<!--
@component
[Go to docs](https://flowbite-svelte.com/)
## Type
[SlideProps](https://github.com/themesberg/flowbite-svelte/blob/main/src/lib/types.ts#L515)
## Props
@prop image
@prop transition
@prop fit
@prop class: className
@prop ...restProps
-->