Screwed around with the layout a bit

This commit is contained in:
Eclypsed
2024-01-13 02:36:53 -05:00
parent 8acf9b3c46
commit 951575c284
13 changed files with 79 additions and 155 deletions
@@ -3,44 +3,15 @@
export let cardDataList
import Card from '$lib/components/media/mediaCard.svelte'
import { onMount } from 'svelte'
let scrollableWrapper,
scrollableWrapperWidth,
scrollable,
scrollableWidth,
isHovered,
scrollpos = 0
onMount(() => {
scrollableWrapperWidth = scrollableWrapper.clientWidth - 96 // Account for x padding
scrollableWidth = Math.abs(scrollableWrapperWidth - scrollable.scrollWidth)
})
</script>
<section>
<section class="overflow-visible">
{#if header}
<h1 class="px-12 text-4xl"><strong>{header}</strong></h1>
<h1 class="text-4xl"><strong>{header}</strong></h1>
{/if}
<div
bind:this={scrollableWrapper}
role="menu"
tabindex="-1"
class="overflow-hidden px-12 py-4"
on:focus={() => (isHovered = true)}
on:blur={() => (isHovered = false)}
on:wheel={(event) => {
if (isHovered) {
scrollpos += event.deltaY / 2 // Change divisor to adjust speed
scrollpos = Math.min(Math.max(0, scrollpos), scrollableWidth)
scrollable.style.transform = `translateX(-${scrollpos}px)`
}
}}
>
<div id="scrollable" bind:this={scrollable} class="no-scrollbar flex gap-6 transition-transform duration-200 ease-out">
{#each cardDataList as cardData}
<Card mediaData={cardData} />
{/each}
</div>
<div class="no-scrollbar flex gap-6 overflow-y-hidden overflow-x-scroll py-4">
{#each cardDataList as cardData}
<Card mediaData={cardData} />
{/each}
</div>
</section>