2023-03-27 05:53:35 +02:00
|
|
|
<script lang="ts">
|
2024-08-22 23:24:49 -04:00
|
|
|
import BrokenAsset from '$lib/components/assets/broken-asset.svelte';
|
2025-04-28 10:23:05 -04:00
|
|
|
import { cancelImageUrl } from '$lib/utils/sw-messaging';
|
2025-09-16 21:40:43 +02:00
|
|
|
import { Icon } from '@immich/ui';
|
2024-08-22 23:24:49 -04:00
|
|
|
import { mdiEyeOffOutline } from '@mdi/js';
|
2025-04-28 10:23:05 -04:00
|
|
|
import type { ActionReturn } from 'svelte/action';
|
2025-05-13 16:10:05 +02:00
|
|
|
import type { ClassValue } from 'svelte/elements';
|
2023-05-17 13:07:17 -04:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
url: string;
|
|
|
|
|
altText: string | undefined;
|
|
|
|
|
title?: string | null;
|
|
|
|
|
heightStyle?: string | undefined;
|
|
|
|
|
widthStyle: string;
|
|
|
|
|
curve?: boolean;
|
|
|
|
|
shadow?: boolean;
|
|
|
|
|
circle?: boolean;
|
|
|
|
|
hidden?: boolean;
|
|
|
|
|
border?: boolean;
|
|
|
|
|
hiddenIconClass?: string;
|
2025-04-02 10:30:41 -05:00
|
|
|
class?: ClassValue;
|
2025-04-11 18:01:51 -04:00
|
|
|
brokenAssetClass?: ClassValue;
|
2025-11-07 21:22:02 +01:00
|
|
|
preload?: boolean;
|
2025-04-11 18:01:51 -04:00
|
|
|
onComplete?: ((errored: boolean) => void) | undefined;
|
2024-11-14 08:43:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let {
|
|
|
|
|
url,
|
|
|
|
|
altText,
|
|
|
|
|
title = null,
|
|
|
|
|
heightStyle = undefined,
|
|
|
|
|
widthStyle,
|
|
|
|
|
curve = false,
|
|
|
|
|
shadow = false,
|
|
|
|
|
circle = false,
|
|
|
|
|
hidden = false,
|
|
|
|
|
border = false,
|
|
|
|
|
hiddenIconClass = 'text-white',
|
|
|
|
|
onComplete = undefined,
|
2025-04-02 10:30:41 -05:00
|
|
|
class: imageClass = '',
|
2025-04-11 18:01:51 -04:00
|
|
|
brokenAssetClass = '',
|
2025-11-07 21:22:02 +01:00
|
|
|
preload = true,
|
2024-11-14 08:43:25 -06:00
|
|
|
}: Props = $props();
|
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
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let loaded = $state(false);
|
|
|
|
|
let errored = $state(false);
|
2023-11-29 15:09:22 +00:00
|
|
|
|
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
|
|
|
const setLoaded = () => {
|
|
|
|
|
loaded = true;
|
2025-04-11 18:01:51 -04:00
|
|
|
onComplete?.(false);
|
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
|
|
|
};
|
|
|
|
|
const setErrored = () => {
|
|
|
|
|
errored = true;
|
2025-04-11 18:01:51 -04:00
|
|
|
onComplete?.(true);
|
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
|
|
|
};
|
2025-03-18 10:14:46 -04:00
|
|
|
|
2025-04-28 10:23:05 -04:00
|
|
|
function mount(elem: HTMLImageElement): ActionReturn {
|
2025-03-18 10:14:46 -04:00
|
|
|
if (elem.complete) {
|
|
|
|
|
loaded = true;
|
2025-04-11 18:01:51 -04:00
|
|
|
onComplete?.(false);
|
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
|
|
|
}
|
2025-04-28 10:23:05 -04:00
|
|
|
return {
|
|
|
|
|
destroy: () => cancelImageUrl(url),
|
|
|
|
|
};
|
2025-03-18 10:14:46 -04:00
|
|
|
}
|
2024-09-06 15:16:18 +02:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let optionalClasses = $derived(
|
|
|
|
|
[
|
|
|
|
|
curve && 'rounded-xl',
|
|
|
|
|
circle && 'rounded-full',
|
|
|
|
|
shadow && 'shadow-lg',
|
|
|
|
|
(circle || !heightStyle) && 'aspect-square',
|
2025-10-31 16:38:17 +01:00
|
|
|
border && 'border-3 border-immich-dark-primary/80 hover:border-immich-primary',
|
2025-04-11 18:01:51 -04:00
|
|
|
brokenAssetClass,
|
2024-11-14 08:43:25 -06:00
|
|
|
]
|
|
|
|
|
.filter(Boolean)
|
|
|
|
|
.join(' '),
|
|
|
|
|
);
|
2023-03-27 05:53:35 +02:00
|
|
|
</script>
|
|
|
|
|
|
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
|
|
|
{#if errored}
|
2024-09-06 15:16:18 +02:00
|
|
|
<BrokenAsset class={optionalClasses} width={widthStyle} height={heightStyle} />
|
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
|
|
|
{:else}
|
|
|
|
|
<img
|
2025-03-18 10:14:46 -04:00
|
|
|
use:mount
|
2024-11-14 08:43:25 -06:00
|
|
|
onload={setLoaded}
|
|
|
|
|
onerror={setErrored}
|
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
|
|
|
style:width={widthStyle}
|
|
|
|
|
style:height={heightStyle}
|
|
|
|
|
style:filter={hidden ? 'grayscale(50%)' : 'none'}
|
|
|
|
|
style:opacity={hidden ? '0.5' : '1'}
|
|
|
|
|
src={url}
|
|
|
|
|
alt={loaded || errored ? altText : ''}
|
|
|
|
|
{title}
|
2025-04-02 10:30:41 -05:00
|
|
|
class={['object-cover', optionalClasses, imageClass]}
|
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
|
|
|
draggable="false"
|
2025-11-07 21:22:02 +01:00
|
|
|
loading={preload ? 'eager' : 'lazy'}
|
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
|
|
|
/>
|
|
|
|
|
{/if}
|
2023-07-23 05:00:43 +02:00
|
|
|
|
2023-07-18 20:09:43 +02:00
|
|
|
{#if hidden}
|
2025-04-28 09:53:53 -04:00
|
|
|
<div class="absolute start-1/2 top-1/2 translate-x-[-50%] translate-y-[-50%] transform">
|
2025-09-16 21:40:43 +02:00
|
|
|
<!-- TODO fix `title` type -->
|
|
|
|
|
<Icon title={title ?? undefined} icon={mdiEyeOffOutline} size="2em" class={hiddenIconClass} />
|
2023-07-18 20:09:43 +02:00
|
|
|
</div>
|
|
|
|
|
{/if}
|