Skip to content
Merged
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
17 changes: 12 additions & 5 deletions src/lib/IONOS/components/explore/Scroller.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import type ScrollerItem from './scrollerItem.d.ts';

const dispatcher = createEventDispatcher();

// Pixels per second
const speed = 25;
const speed: number = 25;

export let direction = 'left';
export let items;
export let items: ScrollerItem[] = [];

let el: HTMLElement|null = null;

Expand All @@ -17,9 +18,15 @@
}
}

$: scrollWidth = el?.scrollWidth ?? 0;
$: fullWidth = scrollWidth / 2;
$: duration = fullWidth / speed;
let scrollWidth: number;
let fullWidth: number;
let duration: number;

$: {
scrollWidth = items.length > 0 ? el?.scrollWidth ?? 0 : 0;
fullWidth = scrollWidth / 2;
duration = fullWidth / speed;
}
</script>

<div
Expand Down