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';
|
2023-07-01 00:50:47 -04:00
|
|
|
import { memoryStore } from '$lib/stores/memory.store';
|
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';
|
2024-05-31 13:44:04 -04:00
|
|
|
import { getMemoryLane } from '@immich/sdk';
|
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';
|
|
|
|
|
import { fade } from 'svelte/transition';
|
2024-07-17 13:37:39 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2023-06-14 20:47:18 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
$: shouldRender = $memoryStore?.length > 0;
|
2023-06-14 20:47:18 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
onMount(async () => {
|
2023-10-04 18:11:11 -04:00
|
|
|
const localTime = new Date();
|
2024-02-14 08:09:49 -05:00
|
|
|
$memoryStore = await getMemoryLane({ month: localTime.getMonth() + 1, day: localTime.getDate() });
|
2023-07-01 00:50:47 -04:00
|
|
|
});
|
2023-06-14 20:47:18 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
let memoryLaneElement: HTMLElement;
|
|
|
|
|
let offsetWidth = 0;
|
|
|
|
|
let innerWidth = 0;
|
2023-06-14 20:47:18 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
let scrollLeftPosition = 0;
|
2023-06-14 20:47:18 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const onScroll = () => (scrollLeftPosition = memoryLaneElement?.scrollLeft);
|
2023-06-16 17:06:38 +01:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
$: canScrollLeft = scrollLeftPosition > 0;
|
|
|
|
|
$: canScrollRight = Math.ceil(scrollLeftPosition) < innerWidth - offsetWidth;
|
2023-06-16 17:06:38 +01:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const scrollBy = 400;
|
|
|
|
|
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}
|
2023-07-18 13:19:39 -05:00
|
|
|
class="relative mt-5 overflow-x-hidden whitespace-nowrap transition-all"
|
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)}
|
2023-07-01 00:50:47 -04:00
|
|
|
on:scroll={onScroll}
|
|
|
|
|
>
|
|
|
|
|
{#if canScrollLeft || canScrollRight}
|
|
|
|
|
<div class="sticky left-0 z-20">
|
|
|
|
|
{#if canScrollLeft}
|
|
|
|
|
<div class="absolute left-4 top-[6rem] z-20" transition:fade={{ duration: 200 }}>
|
|
|
|
|
<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"
|
2023-07-01 00:50:47 -04:00
|
|
|
on:click={scrollLeft}
|
|
|
|
|
>
|
2023-10-25 09:48:25 -04:00
|
|
|
<Icon path={mdiChevronLeft} size="36" /></button
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
{#if canScrollRight}
|
|
|
|
|
<div class="absolute right-4 top-[6rem] z-20" transition:fade={{ duration: 200 }}>
|
|
|
|
|
<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"
|
2023-07-01 00:50:47 -04:00
|
|
|
on:click={scrollRight}
|
|
|
|
|
>
|
2023-10-25 09:48:25 -04:00
|
|
|
<Icon path={mdiChevronRight} size="36" /></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)}>
|
2024-09-13 12:27:10 -04:00
|
|
|
{#each $memoryStore as memory (memory.yearsAgo)}
|
2024-05-02 04:17:40 +08:00
|
|
|
{#if memory.assets.length > 0}
|
2024-05-27 09:06:15 +02:00
|
|
|
<a
|
2024-05-02 04:17:40 +08:00
|
|
|
class="memory-card relative mr-8 inline-block aspect-video h-[215px] rounded-xl"
|
2024-09-13 12:27:10 -04:00
|
|
|
href="{AppRoute.MEMORY}?{QueryParameter.ID}={memory.assets[0].id}"
|
2024-05-02 04:17:40 +08:00
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
class="h-full w-full rounded-xl object-cover"
|
2024-05-31 13:44:04 -04:00
|
|
|
src={getAssetThumbnailUrl(memory.assets[0].id)}
|
2024-07-17 13:37:39 +02:00
|
|
|
alt={$t('memory_lane_title', { values: { title: $getAltText(memory.assets[0]) } })}
|
2024-05-02 04:17:40 +08:00
|
|
|
draggable="false"
|
|
|
|
|
/>
|
|
|
|
|
<p class="absolute bottom-2 left-4 z-10 text-lg text-white">
|
2024-07-05 15:06:35 +02:00
|
|
|
{$memoryLaneTitle(memory.yearsAgo)}
|
2024-05-02 04:17:40 +08:00
|
|
|
</p>
|
|
|
|
|
<div
|
|
|
|
|
class="absolute left-0 top-0 z-0 h-full w-full rounded-xl bg-gradient-to-t from-black/40 via-transparent to-transparent transition-all hover:bg-black/20"
|
2024-11-02 16:49:07 +01:00
|
|
|
></div>
|
2024-05-27 09:06:15 +02:00
|
|
|
</a>
|
2024-05-02 04:17:40 +08:00
|
|
|
{/if}
|
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>
|