2023-06-14 20:47:18 -05:00
|
|
|
<script lang="ts">
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
import { resizeObserver } from '$lib/actions/resize-observer';
|
2023-10-25 09:48:25 -04:00
|
|
|
import Icon from '$lib/components/elements/icon.svelte';
|
2024-02-14 08:09:49 -05:00
|
|
|
import { AppRoute, QueryParameter } from '$lib/constants';
|
2025-03-19 03:34:09 +11:00
|
|
|
import { memoryStore } from '$lib/stores/memory.store.svelte';
|
2024-03-27 16:14:29 -04:00
|
|
|
import { getAssetThumbnailUrl, memoryLaneTitle } from '$lib/utils';
|
2024-03-03 16:42:17 -05:00
|
|
|
import { getAltText } from '$lib/utils/thumbnail-util';
|
2025-05-17 22:57:08 -04:00
|
|
|
import { toTimelineAsset } from '$lib/utils/timeline-util';
|
2023-10-25 09:48:25 -04:00
|
|
|
import { mdiChevronLeft, mdiChevronRight } from '@mdi/js';
|
2024-02-14 08:09:49 -05:00
|
|
|
import { onMount } from 'svelte';
|
2024-07-17 13:37:39 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2025-02-21 13:31:37 -05:00
|
|
|
import { fade } from 'svelte/transition';
|
2023-06-14 20:47:18 -05:00
|
|
|
|
2025-03-19 03:34:09 +11:00
|
|
|
let shouldRender = $derived(memoryStore.memories?.length > 0);
|
2023-06-14 20:47:18 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
onMount(async () => {
|
2025-03-19 03:34:09 +11:00
|
|
|
await memoryStore.initialize();
|
2023-07-01 00:50:47 -04:00
|
|
|
});
|
2023-06-14 20:47:18 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let memoryLaneElement: HTMLElement | undefined = $state();
|
|
|
|
|
let offsetWidth = $state(0);
|
|
|
|
|
let innerWidth = $state(0);
|
2023-06-14 20:47:18 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let scrollLeftPosition = $state(0);
|
2023-06-14 20:47:18 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
const onScroll = () => {
|
|
|
|
|
scrollLeftPosition = memoryLaneElement?.scrollLeft ?? 0;
|
|
|
|
|
};
|
2023-06-16 17:06:38 +01:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let canScrollLeft = $derived(scrollLeftPosition > 0);
|
2025-03-07 03:50:56 +01:00
|
|
|
let canScrollRight = $derived(Math.ceil(scrollLeftPosition) < Math.floor(innerWidth - offsetWidth));
|
2023-06-16 17:06:38 +01:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const scrollBy = 400;
|
2024-11-14 08:43:25 -06:00
|
|
|
const scrollLeft = () => memoryLaneElement?.scrollBy({ left: -scrollBy, behavior: 'smooth' });
|
|
|
|
|
const scrollRight = () => memoryLaneElement?.scrollBy({ left: scrollBy, behavior: 'smooth' });
|
2023-06-14 20:47:18 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{#if shouldRender}
|
2023-07-01 00:50:47 -04:00
|
|
|
<section
|
|
|
|
|
id="memory-lane"
|
|
|
|
|
bind:this={memoryLaneElement}
|
2025-04-01 22:12:04 -04:00
|
|
|
class="relative mt-5 mx-2 overflow-x-scroll overflow-y-hidden whitespace-nowrap transition-all"
|
2025-03-06 15:37:11 +01:00
|
|
|
style="scrollbar-width:none"
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
use:resizeObserver={({ width }) => (offsetWidth = width)}
|
2024-11-14 08:43:25 -06:00
|
|
|
onscroll={onScroll}
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
|
|
|
|
{#if canScrollLeft || canScrollRight}
|
2025-05-13 16:10:05 +02:00
|
|
|
<div class="sticky start-0">
|
2023-07-01 00:50:47 -04:00
|
|
|
{#if canScrollLeft}
|
2025-05-18 15:51:33 +02:00
|
|
|
<div class="absolute start-4 top-24" transition:fade={{ duration: 200 }}>
|
2023-07-01 00:50:47 -04:00
|
|
|
<button
|
2024-05-27 09:06:15 +02:00
|
|
|
type="button"
|
2023-07-18 13:19:39 -05:00
|
|
|
class="rounded-full border border-gray-500 bg-gray-100 p-2 text-gray-500 opacity-50 hover:opacity-100"
|
2025-03-10 03:31:55 +01:00
|
|
|
title={$t('previous')}
|
|
|
|
|
aria-label={$t('previous')}
|
2024-11-14 08:43:25 -06:00
|
|
|
onclick={scrollLeft}
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
2025-03-10 03:31:55 +01:00
|
|
|
<Icon path={mdiChevronLeft} size="36" ariaLabel={$t('previous')} /></button
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
{#if canScrollRight}
|
2025-05-18 15:51:33 +02:00
|
|
|
<div class="absolute end-4 top-24" transition:fade={{ duration: 200 }}>
|
2023-07-01 00:50:47 -04:00
|
|
|
<button
|
2024-05-27 09:06:15 +02:00
|
|
|
type="button"
|
2023-07-18 13:19:39 -05:00
|
|
|
class="rounded-full border border-gray-500 bg-gray-100 p-2 text-gray-500 opacity-50 hover:opacity-100"
|
2025-03-10 03:31:55 +01:00
|
|
|
title={$t('next')}
|
|
|
|
|
aria-label={$t('next')}
|
2024-11-14 08:43:25 -06:00
|
|
|
onclick={scrollRight}
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
2025-03-10 03:31:55 +01:00
|
|
|
<Icon path={mdiChevronRight} size="36" ariaLabel={$t('next')} /></button
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
<div class="inline-block" use:resizeObserver={({ width }) => (innerWidth = width)}>
|
2025-03-19 03:34:09 +11:00
|
|
|
{#each memoryStore.memories as memory (memory.id)}
|
|
|
|
|
<a
|
2025-05-18 15:51:33 +02:00
|
|
|
class="memory-card relative me-2 md:me-4 last:me-0 inline-block aspect-3/4 md:aspect-4/3 max-md:h-[150px] xl:aspect-video h-[215px] rounded-xl"
|
2025-03-19 03:34:09 +11:00
|
|
|
href="{AppRoute.MEMORY}?{QueryParameter.ID}={memory.assets[0].id}"
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
class="h-full w-full rounded-xl object-cover"
|
|
|
|
|
src={getAssetThumbnailUrl(memory.assets[0].id)}
|
2025-05-17 22:57:08 -04:00
|
|
|
alt={$t('memory_lane_title', { values: { title: $getAltText(toTimelineAsset(memory.assets[0])) } })}
|
2025-03-19 03:34:09 +11:00
|
|
|
draggable="false"
|
|
|
|
|
/>
|
|
|
|
|
<div
|
2025-05-18 15:51:33 +02:00
|
|
|
class="absolute start-0 top-0 h-full w-full rounded-xl bg-linear-to-t from-black/40 via-transparent to-transparent transition-all hover:bg-black/20"
|
2025-03-19 03:34:09 +11:00
|
|
|
></div>
|
2025-05-13 23:52:56 +02:00
|
|
|
<p class="absolute bottom-2 start-4 text-lg text-white max-md:text-sm">
|
|
|
|
|
{$memoryLaneTitle(memory)}
|
|
|
|
|
</p>
|
2025-03-19 03:34:09 +11:00
|
|
|
</a>
|
2023-07-01 00:50:47 -04:00
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
2023-06-14 20:47:18 -05:00
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
<style>
|
2023-07-01 00:50:47 -04:00
|
|
|
.memory-card {
|
2023-11-27 11:42:04 -05:00
|
|
|
box-shadow:
|
|
|
|
|
rgba(60, 64, 67, 0.3) 0px 1px 2px 0px,
|
|
|
|
|
rgba(60, 64, 67, 0.15) 0px 1px 3px 1px;
|
2023-07-01 00:50:47 -04:00
|
|
|
}
|
2023-06-14 20:47:18 -05:00
|
|
|
</style>
|