2023-03-27 05:53:35 +02:00
|
|
|
<script lang="ts">
|
2024-02-14 08:09:49 -05:00
|
|
|
import Icon from '$lib/components/elements/icon.svelte';
|
|
|
|
|
import { ProjectionType } from '$lib/constants';
|
2025-04-02 10:30:41 -05:00
|
|
|
import { locale, playVideoThumbnailOnHover } from '$lib/stores/preferences.store';
|
2025-04-28 14:48:33 -04:00
|
|
|
import { getAssetPlaybackUrl, getAssetThumbnailUrl } from '$lib/utils';
|
2024-02-24 21:23:30 +01:00
|
|
|
import { timeToSeconds } from '$lib/utils/date-time';
|
2025-04-02 10:30:41 -05:00
|
|
|
import { getAltText } from '$lib/utils/thumbnail-util';
|
2025-05-17 22:57:08 -04:00
|
|
|
import { AssetMediaSize, Visibility } from '@immich/sdk';
|
2023-10-25 09:48:25 -04:00
|
|
|
import {
|
|
|
|
|
mdiArchiveArrowDownOutline,
|
2023-10-27 15:34:01 -05:00
|
|
|
mdiCameraBurst,
|
2023-10-25 09:48:25 -04:00
|
|
|
mdiCheckCircle,
|
|
|
|
|
mdiHeart,
|
|
|
|
|
mdiMotionPauseOutline,
|
|
|
|
|
mdiMotionPlayOutline,
|
|
|
|
|
mdiRotate360,
|
|
|
|
|
} from '@mdi/js';
|
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-02 10:30:41 -05:00
|
|
|
import { thumbhash } from '$lib/actions/thumbhash';
|
2025-04-28 14:48:33 -04:00
|
|
|
import { authManager } from '$lib/managers/auth-manager.svelte';
|
2025-05-17 22:57:08 -04:00
|
|
|
import type { TimelineAsset } from '$lib/stores/assets-store.svelte';
|
2025-04-02 10:30:41 -05:00
|
|
|
import { mobileDevice } from '$lib/stores/mobile-device.svelte';
|
2025-04-30 00:19:38 -04:00
|
|
|
import { focusNext } from '$lib/utils/focus-util';
|
2025-04-02 10:30:41 -05:00
|
|
|
import { currentUrlReplaceAssetId } from '$lib/utils/navigation';
|
|
|
|
|
import { TUNABLES } from '$lib/utils/tunables';
|
2025-04-28 14:48:33 -04:00
|
|
|
import { onMount } from 'svelte';
|
2025-04-02 10:30:41 -05:00
|
|
|
import type { ClassValue } from 'svelte/elements';
|
2024-02-14 08:09:49 -05:00
|
|
|
import { fade } from 'svelte/transition';
|
|
|
|
|
import ImageThumbnail from './image-thumbnail.svelte';
|
|
|
|
|
import VideoThumbnail from './video-thumbnail.svelte';
|
2023-07-01 00:50:47 -04:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
2025-05-17 22:57:08 -04:00
|
|
|
asset: TimelineAsset;
|
2024-11-14 08:43:25 -06:00
|
|
|
groupIndex?: number;
|
2025-05-17 22:57:08 -04:00
|
|
|
thumbnailSize?: number;
|
|
|
|
|
thumbnailWidth?: number;
|
|
|
|
|
thumbnailHeight?: number;
|
2024-11-14 08:43:25 -06:00
|
|
|
selected?: boolean;
|
|
|
|
|
selectionCandidate?: boolean;
|
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
|
|
|
disabled?: boolean;
|
2025-04-02 10:30:41 -05:00
|
|
|
disableLinkMouseOver?: boolean;
|
2024-11-14 08:43:25 -06:00
|
|
|
readonly?: boolean;
|
|
|
|
|
showArchiveIcon?: boolean;
|
|
|
|
|
showStackedIcon?: boolean;
|
2025-04-02 10:30:41 -05:00
|
|
|
imageClass?: ClassValue;
|
2025-04-11 18:01:51 -04:00
|
|
|
brokenAssetClass?: ClassValue;
|
2025-04-02 10:30:41 -05:00
|
|
|
dimmed?: boolean;
|
2025-05-17 22:57:08 -04:00
|
|
|
onClick?: (asset: TimelineAsset) => void;
|
|
|
|
|
onSelect?: (asset: TimelineAsset) => void;
|
|
|
|
|
onMouseEvent?: (event: { isMouseOver: boolean; selectedGroupIndex: number }) => void;
|
|
|
|
|
handleFocus?: () => void;
|
2024-11-14 08:43:25 -06:00
|
|
|
}
|
2023-10-27 15:34:01 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let {
|
2025-03-18 10:14:46 -04:00
|
|
|
asset = $bindable(),
|
2024-11-14 08:43:25 -06:00
|
|
|
groupIndex = 0,
|
|
|
|
|
thumbnailSize = undefined,
|
|
|
|
|
thumbnailWidth = undefined,
|
|
|
|
|
thumbnailHeight = undefined,
|
|
|
|
|
selected = false,
|
|
|
|
|
selectionCandidate = false,
|
|
|
|
|
disabled = false,
|
2025-04-02 10:30:41 -05:00
|
|
|
disableLinkMouseOver = false,
|
2024-11-14 08:43:25 -06:00
|
|
|
readonly = false,
|
|
|
|
|
showArchiveIcon = false,
|
|
|
|
|
showStackedIcon = true,
|
|
|
|
|
onClick = undefined,
|
|
|
|
|
onSelect = undefined,
|
|
|
|
|
onMouseEvent = undefined,
|
2025-03-12 02:18:14 +11:00
|
|
|
handleFocus = undefined,
|
2025-04-02 10:30:41 -05:00
|
|
|
imageClass = '',
|
2025-04-11 18:01:51 -04:00
|
|
|
brokenAssetClass = '',
|
2025-04-02 10:30:41 -05:00
|
|
|
dimmed = false,
|
2024-11-14 08:43:25 -06:00
|
|
|
}: Props = $props();
|
2023-07-01 00:50:47 -04: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
|
|
|
let {
|
|
|
|
|
IMAGE_THUMBNAIL: { THUMBHASH_FADE_DURATION },
|
|
|
|
|
} = TUNABLES;
|
2023-07-01 00:50:47 -04:00
|
|
|
|
2025-03-27 10:43:56 -05:00
|
|
|
let usingMobileDevice = $derived(mobileDevice.pointerCoarse);
|
2025-04-30 00:19:38 -04:00
|
|
|
let element: HTMLElement | undefined = $state();
|
2024-11-14 08:43:25 -06:00
|
|
|
let mouseOver = $state(false);
|
|
|
|
|
let loaded = $state(false);
|
2025-04-11 18:01:51 -04:00
|
|
|
let thumbError = $state(false);
|
2024-11-14 08:43:25 -06:00
|
|
|
|
|
|
|
|
let width = $derived(thumbnailSize || thumbnailWidth || 235);
|
|
|
|
|
let height = $derived(thumbnailSize || thumbnailHeight || 235);
|
2023-07-01 00:50:47 -04: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 onIconClickedHandler = (e?: MouseEvent) => {
|
|
|
|
|
e?.stopPropagation();
|
|
|
|
|
e?.preventDefault();
|
2023-07-01 00:50:47 -04:00
|
|
|
if (!disabled) {
|
2025-03-18 10:14:46 -04:00
|
|
|
onSelect?.($state.snapshot(asset));
|
2023-07-01 00:50:47 -04:00
|
|
|
}
|
|
|
|
|
};
|
2023-10-27 15:34:01 -05: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 callClickHandlers = () => {
|
|
|
|
|
if (selected) {
|
|
|
|
|
onIconClickedHandler();
|
2024-06-11 17:27:18 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2025-03-18 10:14:46 -04:00
|
|
|
onClick?.($state.snapshot(asset));
|
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-27 09:51:52 -04: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 handleClick = (e: MouseEvent) => {
|
|
|
|
|
if (e.ctrlKey || e.metaKey) {
|
2024-06-11 17:27:18 +02:00
|
|
|
return;
|
2024-06-08 16:33:23 -04: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
|
|
|
e.stopPropagation();
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
callClickHandlers();
|
|
|
|
|
};
|
2024-06-11 17:27:18 +02:00
|
|
|
|
2025-03-18 10:14:46 -04:00
|
|
|
const onMouseEnter = () => {
|
2025-03-27 10:43:56 -05:00
|
|
|
if (usingMobileDevice) {
|
2025-03-24 17:36:36 -04:00
|
|
|
return;
|
|
|
|
|
}
|
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
|
|
|
mouseOver = true;
|
|
|
|
|
onMouseEvent?.({ isMouseOver: true, selectedGroupIndex: groupIndex });
|
2024-06-08 16:33:23 -04:00
|
|
|
};
|
|
|
|
|
|
2023-10-27 15:34:01 -05:00
|
|
|
const onMouseLeave = () => {
|
2025-03-18 10:14:46 -04:00
|
|
|
mouseOver = false;
|
2023-10-27 15:34:01 -05:00
|
|
|
};
|
2025-03-27 09:51:52 -04:00
|
|
|
|
2025-04-11 18:28:36 -04:00
|
|
|
let timer: ReturnType<typeof setTimeout>;
|
2025-04-16 19:24:26 -04:00
|
|
|
|
|
|
|
|
const preventContextMenu = (evt: Event) => evt.preventDefault();
|
|
|
|
|
let disposeables: (() => void)[] = [];
|
|
|
|
|
|
|
|
|
|
const clearLongPressTimer = () => {
|
|
|
|
|
clearTimeout(timer);
|
|
|
|
|
for (const dispose of disposeables) {
|
|
|
|
|
dispose();
|
|
|
|
|
}
|
|
|
|
|
disposeables = [];
|
|
|
|
|
};
|
2025-04-11 18:28:36 -04:00
|
|
|
|
|
|
|
|
let startX: number = 0;
|
|
|
|
|
let startY: number = 0;
|
2025-03-27 09:51:52 -04:00
|
|
|
function longPress(element: HTMLElement, { onLongPress }: { onLongPress: () => void }) {
|
2025-04-11 18:28:36 -04:00
|
|
|
let didPress = false;
|
2025-04-16 19:24:26 -04:00
|
|
|
const start = (evt: PointerEvent) => {
|
|
|
|
|
startX = evt.clientX;
|
|
|
|
|
startY = evt.clientY;
|
2025-04-11 18:28:36 -04:00
|
|
|
didPress = false;
|
2025-03-27 09:51:52 -04:00
|
|
|
timer = setTimeout(() => {
|
|
|
|
|
onLongPress();
|
2025-04-16 19:24:26 -04:00
|
|
|
element.addEventListener('contextmenu', preventContextMenu, { once: true });
|
|
|
|
|
disposeables.push(() => element.removeEventListener('contextmenu', preventContextMenu));
|
2025-04-11 18:28:36 -04:00
|
|
|
didPress = true;
|
2025-03-27 09:51:52 -04:00
|
|
|
}, 350);
|
|
|
|
|
};
|
2025-04-11 18:28:36 -04:00
|
|
|
const click = (e: MouseEvent) => {
|
|
|
|
|
if (!didPress) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
};
|
|
|
|
|
element.addEventListener('click', click);
|
2025-04-16 19:24:26 -04:00
|
|
|
element.addEventListener('pointerdown', start, true);
|
|
|
|
|
element.addEventListener('pointerup', clearLongPressTimer, true);
|
2025-03-27 09:51:52 -04:00
|
|
|
return {
|
|
|
|
|
destroy: () => {
|
2025-04-11 18:28:36 -04:00
|
|
|
element.removeEventListener('click', click);
|
2025-04-16 19:24:26 -04:00
|
|
|
element.removeEventListener('pointerdown', start, true);
|
|
|
|
|
element.removeEventListener('pointerup', clearLongPressTimer, true);
|
2025-03-27 09:51:52 -04:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2025-04-11 18:28:36 -04:00
|
|
|
function moveHandler(e: PointerEvent) {
|
|
|
|
|
var diffX = Math.abs(startX - e.clientX);
|
|
|
|
|
var diffY = Math.abs(startY - e.clientY);
|
|
|
|
|
if (diffX >= 10 || diffY >= 10) {
|
|
|
|
|
clearLongPressTimer();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onMount(() => {
|
|
|
|
|
document.addEventListener('scroll', clearLongPressTimer, true);
|
|
|
|
|
document.addEventListener('wheel', clearLongPressTimer, true);
|
|
|
|
|
document.addEventListener('contextmenu', clearLongPressTimer, true);
|
|
|
|
|
document.addEventListener('pointermove', moveHandler, true);
|
|
|
|
|
return () => {
|
|
|
|
|
document.removeEventListener('scroll', clearLongPressTimer, true);
|
|
|
|
|
document.removeEventListener('wheel', clearLongPressTimer, true);
|
|
|
|
|
document.removeEventListener('contextmenu', clearLongPressTimer, true);
|
|
|
|
|
document.removeEventListener('pointermove', moveHandler, true);
|
|
|
|
|
};
|
|
|
|
|
});
|
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
|
|
|
<div
|
|
|
|
|
data-asset={asset.id}
|
2025-04-02 10:30:41 -05:00
|
|
|
class={[
|
|
|
|
|
'focus-visible:outline-none flex overflow-hidden',
|
|
|
|
|
disabled ? 'bg-gray-300' : 'bg-immich-primary/20 dark:bg-immich-dark-primary/20',
|
|
|
|
|
]}
|
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="{width}px"
|
|
|
|
|
style:height="{height}px"
|
|
|
|
|
>
|
2025-04-11 18:01:51 -04:00
|
|
|
{#if (!loaded || thumbError) && asset.thumbhash}
|
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
|
|
|
<canvas
|
|
|
|
|
use:thumbhash={{ base64ThumbHash: asset.thumbhash }}
|
2025-04-11 18:01:51 -04:00
|
|
|
class="absolute object-cover"
|
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="{width}px"
|
|
|
|
|
style:height="{height}px"
|
|
|
|
|
out:fade={{ duration: THUMBHASH_FADE_DURATION }}
|
|
|
|
|
></canvas>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2025-03-24 17:36:36 -04:00
|
|
|
<!-- as of iOS17, there is a preference for long press speed, which is not available for mobile web.
|
|
|
|
|
The defaults are as follows:
|
|
|
|
|
fast: 200ms
|
|
|
|
|
default: 500ms
|
|
|
|
|
slow: ??ms
|
|
|
|
|
-->
|
2025-03-18 10:14:46 -04:00
|
|
|
<div
|
2025-05-13 16:10:05 +02:00
|
|
|
class={['group absolute top-[0px] bottom-[0px]', { 'cursor-not-allowed': disabled, 'cursor-pointer': !disabled }]}
|
2025-04-02 10:30:41 -05:00
|
|
|
style:width="inherit"
|
|
|
|
|
style:height="inherit"
|
2025-03-18 10:14:46 -04:00
|
|
|
onmouseenter={onMouseEnter}
|
|
|
|
|
onmouseleave={onMouseLeave}
|
2025-03-27 09:51:52 -04:00
|
|
|
use:longPress={{ onLongPress: () => onSelect?.($state.snapshot(asset)) }}
|
2025-03-18 10:14:46 -04:00
|
|
|
onkeydown={(evt) => {
|
|
|
|
|
if (evt.key === 'Enter') {
|
|
|
|
|
callClickHandlers();
|
|
|
|
|
}
|
|
|
|
|
if (evt.key === 'x') {
|
|
|
|
|
onSelect?.(asset);
|
|
|
|
|
}
|
2025-04-30 00:19:38 -04:00
|
|
|
if (document.activeElement === element && evt.key === 'Escape') {
|
|
|
|
|
focusNext((element) => element.dataset.thumbnailFocusContainer === undefined, true);
|
2025-04-14 12:56:40 -04:00
|
|
|
}
|
2025-03-18 10:14:46 -04:00
|
|
|
}}
|
|
|
|
|
onclick={handleClick}
|
2025-04-30 00:19:38 -04:00
|
|
|
bind:this={element}
|
2025-03-18 10:14:46 -04:00
|
|
|
onfocus={handleFocus}
|
2025-04-14 12:56:40 -04:00
|
|
|
data-thumbnail-focus-container
|
2025-04-02 10:30:41 -05:00
|
|
|
tabindex={0}
|
|
|
|
|
role="link"
|
2025-03-18 10:14:46 -04:00
|
|
|
>
|
|
|
|
|
<div
|
2025-04-02 10:30:41 -05:00
|
|
|
class={[
|
|
|
|
|
'absolute h-full w-full select-none bg-transparent transition-transform',
|
|
|
|
|
{ 'scale-[0.85]': selected },
|
|
|
|
|
{ 'rounded-xl': selected },
|
|
|
|
|
]}
|
2025-03-18 10:14:46 -04:00
|
|
|
>
|
2025-04-02 10:30:41 -05:00
|
|
|
<!-- icon overlay -->
|
|
|
|
|
<div>
|
2025-05-13 16:10:05 +02:00
|
|
|
{#if !usingMobileDevice && mouseOver && !disableLinkMouseOver}
|
|
|
|
|
<!-- lazy show the url on mouse over-->
|
|
|
|
|
<a
|
|
|
|
|
class="absolute w-full top-0 bottom-0"
|
|
|
|
|
style:cursor="unset"
|
|
|
|
|
href={currentUrlReplaceAssetId(asset.id)}
|
|
|
|
|
onclick={(evt) => evt.preventDefault()}
|
|
|
|
|
tabindex={-1}
|
|
|
|
|
aria-label="Thumbnail URL"
|
|
|
|
|
>
|
|
|
|
|
</a>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2025-04-02 10:30:41 -05:00
|
|
|
<!-- Gradient overlay on hover -->
|
|
|
|
|
{#if !usingMobileDevice && !disabled}
|
|
|
|
|
<div
|
|
|
|
|
class={[
|
|
|
|
|
'absolute h-full w-full bg-gradient-to-b from-black/25 via-[transparent_25%] opacity-0 transition-opacity group-hover:opacity-100',
|
|
|
|
|
{ 'rounded-xl': selected },
|
|
|
|
|
]}
|
|
|
|
|
></div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2025-05-13 16:10:05 +02:00
|
|
|
<!-- Dimmed support -->
|
2025-04-02 10:30:41 -05:00
|
|
|
{#if dimmed && !mouseOver}
|
2025-05-13 16:10:05 +02:00
|
|
|
<div id="a" class={['absolute h-full w-full bg-gray-700/40', { 'rounded-xl': selected }]}></div>
|
2025-04-02 10:30:41 -05:00
|
|
|
{/if}
|
|
|
|
|
<!-- Outline on focus -->
|
2025-03-24 17:36:36 -04:00
|
|
|
<div
|
2025-04-02 10:30:41 -05:00
|
|
|
class={[
|
|
|
|
|
'absolute size-full group-focus-visible:outline outline-4 -outline-offset-4 outline-immich-primary',
|
|
|
|
|
{ 'rounded-xl': selected },
|
|
|
|
|
]}
|
2025-03-24 17:36:36 -04:00
|
|
|
></div>
|
2023-07-01 00:50:47 -04:00
|
|
|
|
2025-04-02 10:30:41 -05:00
|
|
|
<!-- Favorite asset star -->
|
2025-04-28 14:48:33 -04:00
|
|
|
{#if !authManager.key && asset.isFavorite}
|
2025-05-13 16:10:05 +02:00
|
|
|
<div class="absolute bottom-2 start-2">
|
2025-04-02 10:30:41 -05:00
|
|
|
<Icon path={mdiHeart} size="24" class="text-white" />
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2023-07-28 06:29:09 +02:00
|
|
|
|
2025-05-17 22:57:08 -04:00
|
|
|
{#if !authManager.key && showArchiveIcon && asset.visibility === Visibility.Archive}
|
2025-05-13 16:10:05 +02:00
|
|
|
<div class={['absolute start-2', asset.isFavorite ? 'bottom-10' : 'bottom-2']}>
|
2025-04-02 10:30:41 -05:00
|
|
|
<Icon path={mdiArchiveArrowDownOutline} size="24" class="text-white" />
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2023-10-27 15:34:01 -05:00
|
|
|
|
2025-05-17 22:57:08 -04:00
|
|
|
{#if asset.isImage && asset.projectionType === ProjectionType.EQUIRECTANGULAR}
|
2025-05-13 16:10:05 +02:00
|
|
|
<div class="absolute end-0 top-0 flex place-items-center gap-1 text-xs font-medium text-white">
|
2025-04-28 09:53:53 -04:00
|
|
|
<span class="pe-2 pt-2">
|
2025-04-02 10:30:41 -05:00
|
|
|
<Icon path={mdiRotate360} size="24" />
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2023-10-27 15:34:01 -05:00
|
|
|
|
2025-04-02 10:30:41 -05:00
|
|
|
<!-- Stacked asset -->
|
|
|
|
|
{#if asset.stack && showStackedIcon}
|
|
|
|
|
<div
|
|
|
|
|
class={[
|
2025-05-13 16:10:05 +02:00
|
|
|
'absolute flex place-items-center gap-1 text-xs font-medium text-white',
|
2025-05-17 22:57:08 -04:00
|
|
|
asset.isImage && !asset.livePhotoVideoId ? 'top-0 end-0' : 'top-7 end-1',
|
2025-04-02 10:30:41 -05:00
|
|
|
]}
|
|
|
|
|
>
|
2025-04-28 09:53:53 -04:00
|
|
|
<span class="pe-2 pt-2 flex place-items-center gap-1">
|
2025-04-02 10:30:41 -05:00
|
|
|
<p>{asset.stack.assetCount.toLocaleString($locale)}</p>
|
|
|
|
|
<Icon path={mdiCameraBurst} size="24" />
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
2025-03-18 10:14:46 -04:00
|
|
|
<ImageThumbnail
|
2025-04-02 10:30:41 -05:00
|
|
|
class={imageClass}
|
2025-04-11 18:01:51 -04:00
|
|
|
{brokenAssetClass}
|
2025-03-18 10:14:46 -04:00
|
|
|
url={getAssetThumbnailUrl({ id: asset.id, size: AssetMediaSize.Thumbnail, cacheKey: asset.thumbhash })}
|
|
|
|
|
altText={$getAltText(asset)}
|
|
|
|
|
widthStyle="{width}px"
|
|
|
|
|
heightStyle="{height}px"
|
|
|
|
|
curve={selected}
|
2025-04-11 18:01:51 -04:00
|
|
|
onComplete={(errored) => ((loaded = true), (thumbError = errored))}
|
2025-03-18 10:14:46 -04:00
|
|
|
/>
|
2025-05-17 22:57:08 -04:00
|
|
|
{#if asset.isVideo}
|
2025-03-18 10:14:46 -04:00
|
|
|
<div class="absolute top-0 h-full w-full">
|
|
|
|
|
<VideoThumbnail
|
|
|
|
|
url={getAssetPlaybackUrl({ id: asset.id, cacheKey: asset.thumbhash })}
|
|
|
|
|
enablePlayback={mouseOver && $playVideoThumbnailOnHover}
|
|
|
|
|
curve={selected}
|
2025-05-17 22:57:08 -04:00
|
|
|
durationInSeconds={timeToSeconds(asset.duration!)}
|
2025-03-18 10:14:46 -04:00
|
|
|
playbackOnIconHover={!$playVideoThumbnailOnHover}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2025-05-17 22:57:08 -04:00
|
|
|
{:else if asset.isImage && asset.livePhotoVideoId}
|
2025-03-18 10:14:46 -04:00
|
|
|
<div class="absolute top-0 h-full w-full">
|
|
|
|
|
<VideoThumbnail
|
|
|
|
|
url={getAssetPlaybackUrl({ id: asset.livePhotoVideoId, cacheKey: asset.thumbhash })}
|
|
|
|
|
pauseIcon={mdiMotionPauseOutline}
|
|
|
|
|
playIcon={mdiMotionPlayOutline}
|
|
|
|
|
showTime={false}
|
|
|
|
|
curve={selected}
|
|
|
|
|
playbackOnIconHover
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2023-07-03 10:56:58 +01:00
|
|
|
{/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>
|
2025-03-18 10:14:46 -04:00
|
|
|
{#if selectionCandidate}
|
|
|
|
|
<div
|
|
|
|
|
class="absolute top-0 h-full w-full bg-immich-primary opacity-40"
|
|
|
|
|
in:fade={{ duration: 100 }}
|
|
|
|
|
out:fade={{ duration: 100 }}
|
|
|
|
|
></div>
|
|
|
|
|
{/if}
|
2025-05-13 16:10:05 +02:00
|
|
|
|
|
|
|
|
<!-- Select asset button -->
|
|
|
|
|
{#if !readonly && (mouseOver || selected || selectionCandidate)}
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onclick={onIconClickedHandler}
|
|
|
|
|
class={['absolute p-2 focus:outline-none', { 'cursor-not-allowed': disabled }]}
|
|
|
|
|
role="checkbox"
|
|
|
|
|
tabindex={-1}
|
|
|
|
|
onfocus={handleFocus}
|
|
|
|
|
aria-checked={selected}
|
|
|
|
|
{disabled}
|
|
|
|
|
>
|
|
|
|
|
{#if disabled}
|
|
|
|
|
<Icon path={mdiCheckCircle} size="24" class="text-zinc-800" />
|
|
|
|
|
{:else if selected}
|
|
|
|
|
<div class="rounded-full bg-[#D9DCEF] dark:bg-[#232932]">
|
|
|
|
|
<Icon path={mdiCheckCircle} size="24" class="text-immich-primary" />
|
|
|
|
|
</div>
|
|
|
|
|
{:else}
|
|
|
|
|
<Icon path={mdiCheckCircle} size="24" class="text-white/80 hover:text-white" />
|
|
|
|
|
{/if}
|
|
|
|
|
</button>
|
|
|
|
|
{/if}
|
2025-03-18 10:14:46 -04:00
|
|
|
</div>
|
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>
|