High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
feat: focus jumped-to item in timeline (#24738)
bo0tzzd7c28470ee8e
diff --git a/web/src/lib/components/timeline/Timeline.svelte b/web/src/lib/components/timeline/Timeline.svelteindex 6e21479acc..cc2c3ef162 100644--- a/web/src/lib/components/timeline/Timeline.svelte+++ b/web/src/lib/components/timeline/Timeline.svelte@@ -13,6 +13,7 @@import Skeleton from '$lib/elements/Skeleton.svelte';import type { DayGroup } from '$lib/managers/timeline-manager/day-group.svelte';import { isIntersecting } from '$lib/managers/timeline-manager/internal/intersection-support.svelte';+ import { focusAsset } from '$lib/components/timeline/actions/focus-actions';import type { MonthGroup } from '$lib/managers/timeline-manager/month-group.svelte';import { TimelineManager } from '$lib/managers/timeline-manager/timeline-manager.svelte';import type { TimelineAsset, TimelineManagerOptions, ViewportTopMonth } from '$lib/managers/timeline-manager/types';@@ -25,7 +26,7 @@import { getTimes, type ScrubberListener } from '$lib/utils/timeline-util';import { type AlbumResponseDto, type PersonResponseDto, type UserResponseDto } from '@immich/sdk';import { DateTime } from 'luxon';- import { onDestroy, onMount, type Snippet } from 'svelte';+ import { onDestroy, onMount, tick, type Snippet } from 'svelte';import type { UpdatePayload } from 'vite';interface Props {@@ -226,6 +227,9 @@if (!scrolled) {// if the asset is not found, scroll to the toptimelineManager.scrollTo(0);+ } else if (scrollTarget) {+ await tick();+ focusAsset(scrollTarget);}invisible = false;};diff --git a/web/src/lib/components/timeline/actions/focus-actions.ts b/web/src/lib/components/timeline/actions/focus-actions.tsindex f0f9e2e50c..49f1eef767 100644--- a/web/src/lib/components/timeline/actions/focus-actions.ts+++ b/web/src/lib/components/timeline/actions/focus-actions.ts@@ -21,11 +21,15 @@ export const focusPreviousAsset = () =>const queryHTMLElement = (query: string) => document.querySelector(query) as HTMLElement;+export const focusAsset = (assetId: string) => {+ const element = queryHTMLElement(`[data-thumbnail-focus-container][data-asset="${assetId}"]`);+ element?.focus();+};+export const setFocusToAsset = (scrollToAsset: (asset: TimelineAsset) => boolean, asset: TimelineAsset) => {const scrolled = scrollToAsset(asset);if (scrolled) {- const element = queryHTMLElement(`[data-thumbnail-focus-container][data-asset="${asset.id}"]`);- element?.focus();+ focusAsset(asset.id);}};@@ -71,8 +75,7 @@ export const setFocusTo = async (if (!invocation.isStillValid()) {return;}- const element = queryHTMLElement(`[data-thumbnail-focus-container][data-asset="${asset.id}"]`);- element?.focus();+ focusAsset(asset.id);}invocation.endInvocation();