mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
feat(web): view transitions from timeline to viewer
Change-Id: I0a37b417ee4c247dcc93d442c976eede6a6a6964
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
|||||||
generateTimelineData,
|
generateTimelineData,
|
||||||
TimelineAssetConfig,
|
TimelineAssetConfig,
|
||||||
TimelineData,
|
TimelineData,
|
||||||
|
toAssetResponseDto,
|
||||||
} from 'src/ui/generators/timeline';
|
} from 'src/ui/generators/timeline';
|
||||||
import { setupBaseMockApiRoutes } from 'src/ui/mock-network/base-network';
|
import { setupBaseMockApiRoutes } from 'src/ui/mock-network/base-network';
|
||||||
import { setupTimelineMockApiRoutes, TimelineTestContext } from 'src/ui/mock-network/timeline-network';
|
import { setupTimelineMockApiRoutes, TimelineTestContext } from 'src/ui/mock-network/timeline-network';
|
||||||
@@ -30,6 +31,10 @@ test.describe('search gallery-viewer', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test.beforeAll(async () => {
|
test.beforeAll(async () => {
|
||||||
|
test.fail(
|
||||||
|
process.env.PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS !== '1',
|
||||||
|
'This test requires env var: PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1',
|
||||||
|
);
|
||||||
adminUserId = faker.string.uuid();
|
adminUserId = faker.string.uuid();
|
||||||
testContext.adminId = adminUserId;
|
testContext.adminId = adminUserId;
|
||||||
timelineRestData = generateTimelineData({ ...createDefaultTimelineConfig(), ownerId: adminUserId });
|
timelineRestData = generateTimelineData({ ...createDefaultTimelineConfig(), ownerId: adminUserId });
|
||||||
@@ -44,7 +49,10 @@ test.describe('search gallery-viewer', () => {
|
|||||||
|
|
||||||
await context.route('**/api/search/metadata', async (route, request) => {
|
await context.route('**/api/search/metadata', async (route, request) => {
|
||||||
if (request.method() === 'POST') {
|
if (request.method() === 'POST') {
|
||||||
const searchAssets = assets.slice(0, 5).filter((asset) => !changes.assetDeletions.includes(asset.id));
|
const searchAssets = assets
|
||||||
|
.slice(0, 5)
|
||||||
|
.filter((asset) => !changes.assetDeletions.includes(asset.id))
|
||||||
|
.map((asset) => toAssetResponseDto(asset));
|
||||||
return route.fulfill({
|
return route.fulfill({
|
||||||
status: 200,
|
status: 200,
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ export const timelineUtils = {
|
|||||||
return page.locator('#asset-grid');
|
return page.locator('#asset-grid');
|
||||||
},
|
},
|
||||||
async waitForTimelineLoad(page: Page) {
|
async waitForTimelineLoad(page: Page) {
|
||||||
await expect(timelineUtils.locator(page)).toBeInViewport();
|
await page.locator('#asset-grid[data-initialized]').waitFor();
|
||||||
await expect.poll(() => thumbnailUtils.locator(page).count()).toBeGreaterThan(0);
|
await expect.poll(() => thumbnailUtils.locator(page).count()).toBeGreaterThan(0);
|
||||||
},
|
},
|
||||||
async getScrollTop(page: Page) {
|
async getScrollTop(page: Page) {
|
||||||
@@ -163,14 +163,17 @@ export const assetViewerUtils = {
|
|||||||
return page.locator('#immich-asset-viewer');
|
return page.locator('#immich-asset-viewer');
|
||||||
},
|
},
|
||||||
async waitForViewerLoad(page: Page, asset: TimelineAssetConfig) {
|
async waitForViewerLoad(page: Page, asset: TimelineAssetConfig) {
|
||||||
await page
|
const imgLocator = page.locator(`[data-viewer-content] img[data-testid="preview"][src*="${asset.id}"]`);
|
||||||
.locator(
|
const videoLocator = page.locator(`[data-viewer-content] video[poster*="${asset.id}"]`);
|
||||||
`img[draggable="false"][src="/api/assets/${asset.id}/thumbnail?size=preview&c=${asset.thumbhash}&edited=true"]`,
|
await imgLocator.or(videoLocator).waitFor();
|
||||||
)
|
|
||||||
.or(
|
if ((await videoLocator.count()) === 0) {
|
||||||
page.locator(`video[poster="/api/assets/${asset.id}/thumbnail?size=preview&c=${asset.thumbhash}&edited=true"]`),
|
await expect
|
||||||
)
|
.poll(() => imgLocator.evaluate((img: HTMLImageElement) => img.complete && img.naturalWidth > 0))
|
||||||
.waitFor();
|
.toBe(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
await expect(page.locator('#immich-asset-viewer')).not.toHaveAttribute('data-navigating');
|
||||||
},
|
},
|
||||||
async expectActiveAssetToBe(page: Page, assetId: string) {
|
async expectActiveAssetToBe(page: Page, assetId: string) {
|
||||||
const activeElement = () =>
|
const activeElement = () =>
|
||||||
|
|||||||
@@ -0,0 +1,273 @@
|
|||||||
|
import { faker } from '@faker-js/faker';
|
||||||
|
import { expect, test } from '@playwright/test';
|
||||||
|
import {
|
||||||
|
Changes,
|
||||||
|
createDefaultTimelineConfig,
|
||||||
|
generateTimelineData,
|
||||||
|
SeededRandom,
|
||||||
|
selectRandom,
|
||||||
|
TimelineAssetConfig,
|
||||||
|
TimelineData,
|
||||||
|
} from 'src/ui/generators/timeline';
|
||||||
|
import { setupBaseMockApiRoutes } from 'src/ui/mock-network/base-network';
|
||||||
|
import { setupTimelineMockApiRoutes, TimelineTestContext } from 'src/ui/mock-network/timeline-network';
|
||||||
|
import { assetViewerUtils } from 'src/ui/specs/timeline/utils';
|
||||||
|
import { utils } from 'src/utils';
|
||||||
|
|
||||||
|
test.describe.configure({ mode: 'parallel' });
|
||||||
|
test.describe('asset-viewer', () => {
|
||||||
|
const rng = new SeededRandom(529);
|
||||||
|
let adminUserId: string;
|
||||||
|
let timelineRestData: TimelineData;
|
||||||
|
const assets: TimelineAssetConfig[] = [];
|
||||||
|
const yearMonths: string[] = [];
|
||||||
|
const testContext = new TimelineTestContext();
|
||||||
|
const changes: Changes = {
|
||||||
|
albumAdditions: [],
|
||||||
|
assetDeletions: [],
|
||||||
|
assetArchivals: [],
|
||||||
|
assetFavorites: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
test.beforeAll(async () => {
|
||||||
|
utils.initSdk();
|
||||||
|
adminUserId = faker.string.uuid();
|
||||||
|
testContext.adminId = adminUserId;
|
||||||
|
timelineRestData = generateTimelineData({ ...createDefaultTimelineConfig(), ownerId: adminUserId });
|
||||||
|
for (const timeBucket of timelineRestData.buckets.values()) {
|
||||||
|
assets.push(...timeBucket);
|
||||||
|
}
|
||||||
|
for (const yearMonth of timelineRestData.buckets.keys()) {
|
||||||
|
const [year, month] = yearMonth.split('-');
|
||||||
|
yearMonths.push(`${year}-${Number(month)}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test.beforeEach(async ({ context }) => {
|
||||||
|
await setupBaseMockApiRoutes(context, adminUserId);
|
||||||
|
await setupTimelineMockApiRoutes(context, timelineRestData, changes, testContext);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.afterEach(() => {
|
||||||
|
testContext.slowBucket = false;
|
||||||
|
changes.albumAdditions = [];
|
||||||
|
changes.assetDeletions = [];
|
||||||
|
changes.assetArchivals = [];
|
||||||
|
changes.assetFavorites = [];
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe('/photos/:id', () => {
|
||||||
|
test('Navigate to next asset via button', async ({ page }) => {
|
||||||
|
const asset = selectRandom(assets, rng);
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
await page.goto(`/photos/${asset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, asset);
|
||||||
|
await expect.poll(() => new URL(page.url()).pathname).toBe(`/photos/${asset.id}`);
|
||||||
|
|
||||||
|
await page.getByLabel('View next asset').click();
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + 1]);
|
||||||
|
await expect.poll(() => new URL(page.url()).pathname).toBe(`/photos/${assets[index + 1].id}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Navigate to previous asset via button', async ({ page }) => {
|
||||||
|
const asset = selectRandom(assets, rng);
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
await page.goto(`/photos/${asset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, asset);
|
||||||
|
await expect.poll(() => new URL(page.url()).pathname).toBe(`/photos/${asset.id}`);
|
||||||
|
|
||||||
|
await page.getByLabel('View previous asset').click();
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index - 1]);
|
||||||
|
await expect.poll(() => new URL(page.url()).pathname).toBe(`/photos/${assets[index - 1].id}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Navigate to next asset via keyboard (ArrowRight)', async ({ page }) => {
|
||||||
|
const asset = selectRandom(assets, rng);
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
await page.goto(`/photos/${asset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, asset);
|
||||||
|
await expect.poll(() => new URL(page.url()).pathname).toBe(`/photos/${asset.id}`);
|
||||||
|
|
||||||
|
await page.getByTestId('next-asset').waitFor();
|
||||||
|
await page.keyboard.press('ArrowRight');
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + 1]);
|
||||||
|
await expect.poll(() => new URL(page.url()).pathname).toBe(`/photos/${assets[index + 1].id}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Navigate to previous asset via keyboard (ArrowLeft)', async ({ page }) => {
|
||||||
|
const asset = selectRandom(assets, rng);
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
await page.goto(`/photos/${asset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, asset);
|
||||||
|
await expect.poll(() => new URL(page.url()).pathname).toBe(`/photos/${asset.id}`);
|
||||||
|
|
||||||
|
await page.getByTestId('previous-asset').waitFor();
|
||||||
|
await page.keyboard.press('ArrowLeft');
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index - 1]);
|
||||||
|
await expect.poll(() => new URL(page.url()).pathname).toBe(`/photos/${assets[index - 1].id}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Navigate forward 5 times via button', async ({ page }) => {
|
||||||
|
const asset = selectRandom(assets, rng);
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
await page.goto(`/photos/${asset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, asset);
|
||||||
|
|
||||||
|
for (let i = 1; i <= 5; i++) {
|
||||||
|
await page.getByLabel('View next asset').click();
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + i]);
|
||||||
|
await expect.poll(() => new URL(page.url()).pathname).toBe(`/photos/${assets[index + i].id}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Navigate backward 5 times via button', async ({ page }) => {
|
||||||
|
const asset = selectRandom(assets, rng);
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
await page.goto(`/photos/${asset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, asset);
|
||||||
|
|
||||||
|
for (let i = 1; i <= 5; i++) {
|
||||||
|
await page.getByLabel('View previous asset').click();
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index - i]);
|
||||||
|
await expect.poll(() => new URL(page.url()).pathname).toBe(`/photos/${assets[index - i].id}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Navigate forward then backward via keyboard', async ({ page }) => {
|
||||||
|
const asset = selectRandom(assets, rng);
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
await page.goto(`/photos/${asset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, asset);
|
||||||
|
|
||||||
|
// Navigate forward 3 times
|
||||||
|
for (let i = 1; i <= 3; i++) {
|
||||||
|
await page.getByTestId('next-asset').waitFor();
|
||||||
|
await page.keyboard.press('ArrowRight');
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Navigate backward 3 times to return to original
|
||||||
|
for (let i = 2; i >= 0; i--) {
|
||||||
|
await page.getByTestId('previous-asset').waitFor();
|
||||||
|
await page.keyboard.press('ArrowLeft');
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify we're back at the original asset
|
||||||
|
await expect.poll(() => new URL(page.url()).pathname).toBe(`/photos/${asset.id}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Verify no next button on last asset', async ({ page }) => {
|
||||||
|
const lastAsset = assets.at(-1)!;
|
||||||
|
await page.goto(`/photos/${lastAsset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, lastAsset);
|
||||||
|
|
||||||
|
// Verify next button doesn't exist
|
||||||
|
await expect(page.getByLabel('View next asset')).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Verify no previous button on first asset', async ({ page }) => {
|
||||||
|
const firstAsset = assets[0];
|
||||||
|
await page.goto(`/photos/${firstAsset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, firstAsset);
|
||||||
|
|
||||||
|
// Verify previous button doesn't exist
|
||||||
|
await expect(page.getByLabel('View previous asset')).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Delete photo advances to next', async ({ page }) => {
|
||||||
|
const asset = selectRandom(assets, rng);
|
||||||
|
await page.goto(`/photos/${asset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, asset);
|
||||||
|
await page.getByLabel('Delete').click();
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + 1]);
|
||||||
|
});
|
||||||
|
test('Delete photo advances to next (2x)', async ({ page }) => {
|
||||||
|
const asset = selectRandom(assets, rng);
|
||||||
|
await page.goto(`/photos/${asset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, asset);
|
||||||
|
await page.getByLabel('Delete').click();
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + 1]);
|
||||||
|
await page.getByLabel('Delete').click();
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + 2]);
|
||||||
|
});
|
||||||
|
test('Delete last photo advances to prev', async ({ page }) => {
|
||||||
|
const asset = assets.at(-1)!;
|
||||||
|
await page.goto(`/photos/${asset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, asset);
|
||||||
|
await page.getByLabel('Delete').click();
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index - 1]);
|
||||||
|
});
|
||||||
|
test('Delete last photo advances to prev (2x)', async ({ page }) => {
|
||||||
|
const asset = assets.at(-1)!;
|
||||||
|
await page.goto(`/photos/${asset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, asset);
|
||||||
|
await page.getByLabel('Delete').click();
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index - 1]);
|
||||||
|
await page.getByLabel('Delete').click();
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index - 2]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test.describe('/trash/photos/:id', () => {
|
||||||
|
test('Delete trashed photo advances to next', async ({ page }) => {
|
||||||
|
const asset = selectRandom(assets, rng);
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
const deletedAssets = assets.slice(index - 10, index + 10).map((asset) => asset.id);
|
||||||
|
changes.assetDeletions.push(...deletedAssets);
|
||||||
|
await page.goto(`/trash/photos/${asset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, asset);
|
||||||
|
await page.getByLabel('Delete').click();
|
||||||
|
// confirm dialog
|
||||||
|
await page.getByRole('button').getByText('Delete').click();
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + 1]);
|
||||||
|
});
|
||||||
|
test('Delete trashed photo advances to next 2x', async ({ page }) => {
|
||||||
|
const asset = selectRandom(assets, rng);
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
const deletedAssets = assets.slice(index - 10, index + 10).map((asset) => asset.id);
|
||||||
|
changes.assetDeletions.push(...deletedAssets);
|
||||||
|
await page.goto(`/trash/photos/${asset.id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, asset);
|
||||||
|
await page.getByLabel('Delete').click();
|
||||||
|
// confirm dialog
|
||||||
|
await page.getByRole('button').getByText('Delete').click();
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + 1]);
|
||||||
|
await page.getByLabel('Delete').click();
|
||||||
|
// confirm dialog
|
||||||
|
await page.getByRole('button').getByText('Delete').click();
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + 2]);
|
||||||
|
});
|
||||||
|
test('Delete trashed photo advances to prev', async ({ page }) => {
|
||||||
|
const asset = selectRandom(assets, rng);
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
const deletedAssets = assets.slice(index - 10, index + 10).map((asset) => asset.id);
|
||||||
|
changes.assetDeletions.push(...deletedAssets);
|
||||||
|
await page.goto(`/trash/photos/${assets[index + 9].id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + 9]);
|
||||||
|
await page.getByLabel('Delete').click();
|
||||||
|
// confirm dialog
|
||||||
|
await page.getByRole('button').getByText('Delete').click();
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + 8]);
|
||||||
|
});
|
||||||
|
test('Delete trashed photo advances to prev 2x', async ({ page }) => {
|
||||||
|
const asset = selectRandom(assets, rng);
|
||||||
|
const index = assets.indexOf(asset);
|
||||||
|
const deletedAssets = assets.slice(index - 10, index + 10).map((asset) => asset.id);
|
||||||
|
changes.assetDeletions.push(...deletedAssets);
|
||||||
|
await page.goto(`/trash/photos/${assets[index + 9].id}`);
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + 9]);
|
||||||
|
await page.getByLabel('Delete').click();
|
||||||
|
// confirm dialog
|
||||||
|
await page.getByRole('button').getByText('Delete').click();
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + 8]);
|
||||||
|
await page.getByLabel('Delete').click();
|
||||||
|
// confirm dialog
|
||||||
|
await page.getByRole('button').getByText('Delete').click();
|
||||||
|
await assetViewerUtils.waitForViewerLoad(page, assets[index + 7]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
+396
@@ -75,6 +75,35 @@
|
|||||||
--immich-dark-bg: 10 10 10;
|
--immich-dark-bg: 10 10 10;
|
||||||
--immich-dark-fg: 229 231 235;
|
--immich-dark-fg: 229 231 235;
|
||||||
--immich-dark-gray: 33 33 33;
|
--immich-dark-gray: 33 33 33;
|
||||||
|
|
||||||
|
/* transitions */
|
||||||
|
--immich-split-viewer-nav: enabled;
|
||||||
|
|
||||||
|
/* view transition variables */
|
||||||
|
/* Base animation duration for standard transitions (page fades, info panel) */
|
||||||
|
--vt-duration-default: 250ms;
|
||||||
|
/* Duration for hero transitions (thumbnail to full viewer) */
|
||||||
|
--vt-duration-hero: 280ms;
|
||||||
|
/* Duration for next/previous photo navigation */
|
||||||
|
--vt-duration-viewer-navigation: 270ms;
|
||||||
|
/* Duration for slideshow mode transitions */
|
||||||
|
--vt-duration-slideshow: 1s;
|
||||||
|
/* Easing function for slide animations (ease-out) */
|
||||||
|
--vt-viewer-slide-easing: cubic-bezier(0.2, 0, 0, 1);
|
||||||
|
/* How far images slide in/out during navigation (% of viewport) */
|
||||||
|
--vt-viewer-slide-distance: 15%;
|
||||||
|
/* Starting opacity for fly transitions (slide+fade effect) */
|
||||||
|
--vt-viewer-opacity-start: 0.1;
|
||||||
|
/* Maximum blur during fly transitions (currently disabled) */
|
||||||
|
--vt-viewer-blur-max: 0px;
|
||||||
|
|
||||||
|
--vt-viewer-next-in: flyInRight;
|
||||||
|
--vt-viewer-next-out: flyOutLeft;
|
||||||
|
--vt-viewer-prev-in: flyInLeft;
|
||||||
|
--vt-viewer-prev-out: flyOutRight;
|
||||||
|
--vt-viewer-old-opacity: 1;
|
||||||
|
/* Easing function for memory and hero morph transitions */
|
||||||
|
--vt-memory-easing: cubic-bezier(0.2, 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
button:not(:disabled),
|
button:not(:disabled),
|
||||||
@@ -176,3 +205,370 @@
|
|||||||
@apply bg-subtle rounded-lg;
|
@apply bg-subtle rounded-lg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@layer base {
|
||||||
|
::view-transition {
|
||||||
|
background: var(--color-black);
|
||||||
|
animation-duration: var(--vt-duration-default);
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-old(*),
|
||||||
|
::view-transition-new(*) {
|
||||||
|
mix-blend-mode: normal;
|
||||||
|
animation-duration: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-old(*) {
|
||||||
|
animation-name: fadeOut;
|
||||||
|
animation-fill-mode: forwards;
|
||||||
|
}
|
||||||
|
::view-transition-new(*) {
|
||||||
|
animation-name: fadeIn;
|
||||||
|
animation-fill-mode: forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-old(root) {
|
||||||
|
animation: var(--vt-duration-default) 0s fadeOut forwards;
|
||||||
|
}
|
||||||
|
::view-transition-new(root) {
|
||||||
|
animation: var(--vt-duration-default) 0s fadeIn forwards;
|
||||||
|
}
|
||||||
|
html:active-view-transition-type(slideshow) {
|
||||||
|
&::view-transition-old(*) {
|
||||||
|
animation: var(--vt-duration-slideshow) linear crossfadeOut forwards;
|
||||||
|
}
|
||||||
|
&::view-transition-new(*) {
|
||||||
|
animation: var(--vt-duration-slideshow) linear crossfadeIn forwards;
|
||||||
|
}
|
||||||
|
&::view-transition-image-pair(*) {
|
||||||
|
isolation: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html:active-view-transition-type(viewer-nav) {
|
||||||
|
&::view-transition-old(root) {
|
||||||
|
animation: var(--vt-duration-hero) 0s fadeOut forwards;
|
||||||
|
}
|
||||||
|
&::view-transition-new(root) {
|
||||||
|
animation: var(--vt-duration-hero) 0s fadeIn forwards;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
::view-transition-image-pair(info) {
|
||||||
|
isolation: auto;
|
||||||
|
}
|
||||||
|
::view-transition-old(info) {
|
||||||
|
animation: var(--vt-duration-default) 0s panelSlideOutRight forwards;
|
||||||
|
}
|
||||||
|
::view-transition-new(info) {
|
||||||
|
animation: var(--vt-duration-default) 0s panelSlideInRight forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-group(detail-panel) {
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
::view-transition-old(detail-panel),
|
||||||
|
::view-transition-new(detail-panel) {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
::view-transition-group(letterbox-left),
|
||||||
|
::view-transition-group(letterbox-right),
|
||||||
|
::view-transition-group(letterbox-top),
|
||||||
|
::view-transition-group(letterbox-bottom) {
|
||||||
|
animation-duration: var(--vt-duration-viewer-navigation);
|
||||||
|
animation-timing-function: var(--vt-viewer-slide-easing);
|
||||||
|
z-index: 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-image-pair(letterbox-left),
|
||||||
|
::view-transition-image-pair(letterbox-right),
|
||||||
|
::view-transition-image-pair(letterbox-top),
|
||||||
|
::view-transition-image-pair(letterbox-bottom) {
|
||||||
|
isolation: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-old(letterbox-left),
|
||||||
|
::view-transition-old(letterbox-right),
|
||||||
|
::view-transition-old(letterbox-top),
|
||||||
|
::view-transition-old(letterbox-bottom),
|
||||||
|
::view-transition-new(letterbox-left),
|
||||||
|
::view-transition-new(letterbox-right),
|
||||||
|
::view-transition-new(letterbox-top),
|
||||||
|
::view-transition-new(letterbox-bottom) {
|
||||||
|
animation: none;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: fill;
|
||||||
|
background-color: var(--color-black);
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-group(exclude-leftbutton),
|
||||||
|
::view-transition-group(exclude-rightbutton),
|
||||||
|
::view-transition-group(exclude) {
|
||||||
|
animation: none;
|
||||||
|
z-index: 5;
|
||||||
|
}
|
||||||
|
::view-transition-old(exclude-leftbutton),
|
||||||
|
::view-transition-old(exclude-rightbutton),
|
||||||
|
::view-transition-old(exclude) {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
::view-transition-new(exclude-leftbutton),
|
||||||
|
::view-transition-new(exclude-rightbutton),
|
||||||
|
::view-transition-new(exclude) {
|
||||||
|
animation: none;
|
||||||
|
z-index: 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-group(hero) {
|
||||||
|
animation-duration: var(--vt-duration-hero);
|
||||||
|
animation-timing-function: var(--vt-memory-easing);
|
||||||
|
}
|
||||||
|
::view-transition-old(hero) {
|
||||||
|
animation: none;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
::view-transition-new(hero) {
|
||||||
|
animation: none;
|
||||||
|
align-content: center;
|
||||||
|
}
|
||||||
|
::view-transition-old(next),
|
||||||
|
::view-transition-old(next-old),
|
||||||
|
::view-transition-new(next),
|
||||||
|
::view-transition-new(next-new),
|
||||||
|
::view-transition-old(previous),
|
||||||
|
::view-transition-old(previous-old),
|
||||||
|
::view-transition-new(previous),
|
||||||
|
::view-transition-new(previous-new) {
|
||||||
|
animation-duration: var(--vt-duration-viewer-navigation);
|
||||||
|
animation-timing-function: var(--vt-viewer-slide-easing);
|
||||||
|
animation-fill-mode: forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-old(next),
|
||||||
|
::view-transition-old(next-old),
|
||||||
|
::view-transition-old(previous),
|
||||||
|
::view-transition-old(previous-old) {
|
||||||
|
opacity: var(--vt-viewer-old-opacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-old(next),
|
||||||
|
::view-transition-old(next-old) {
|
||||||
|
animation-name: var(--vt-viewer-next-out);
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-new(next),
|
||||||
|
::view-transition-new(next-new) {
|
||||||
|
animation-name: var(--vt-viewer-next-in);
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-old(previous),
|
||||||
|
::view-transition-old(previous-old) {
|
||||||
|
animation-name: var(--vt-viewer-prev-out);
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-new(previous),
|
||||||
|
::view-transition-new(previous-new) {
|
||||||
|
animation-name: var(--vt-viewer-prev-in);
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-old(next-old),
|
||||||
|
::view-transition-new(next-new),
|
||||||
|
::view-transition-old(previous-old),
|
||||||
|
::view-transition-new(previous-new) {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-old(previous-old) {
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes flyInLeft {
|
||||||
|
from {
|
||||||
|
transform: translateX(calc(-1 * var(--vt-viewer-slide-distance)));
|
||||||
|
opacity: var(--vt-viewer-opacity-start);
|
||||||
|
filter: blur(var(--vt-viewer-blur-max));
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
filter: blur(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes flyOutLeft {
|
||||||
|
from {
|
||||||
|
opacity: 1;
|
||||||
|
filter: blur(0);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translateX(calc(-1 * var(--vt-viewer-slide-distance)));
|
||||||
|
opacity: var(--vt-viewer-opacity-start);
|
||||||
|
filter: blur(var(--vt-viewer-blur-max));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes flyInRight {
|
||||||
|
from {
|
||||||
|
transform: translateX(var(--vt-viewer-slide-distance));
|
||||||
|
opacity: var(--vt-viewer-opacity-start);
|
||||||
|
filter: blur(var(--vt-viewer-blur-max));
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
filter: blur(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes flyOutRight {
|
||||||
|
from {
|
||||||
|
opacity: 1;
|
||||||
|
filter: blur(0);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translateX(var(--vt-viewer-slide-distance));
|
||||||
|
opacity: var(--vt-viewer-opacity-start);
|
||||||
|
filter: blur(var(--vt-viewer-blur-max));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes panelSlideInRight {
|
||||||
|
from {
|
||||||
|
transform: translateX(100%);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes panelSlideOutRight {
|
||||||
|
from {
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translateX(100%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* cubic fade curves so combined opacity stays close to 1.0 during crossfade */
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes fadeOut {
|
||||||
|
from {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes crossfadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes crossfadeOut {
|
||||||
|
from {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
::view-transition-group(hero) {
|
||||||
|
animation-name: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-old(hero) {
|
||||||
|
animation: none;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-new(hero) {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
html:active-view-transition-type(viewer) {
|
||||||
|
&::view-transition-old(hero) {
|
||||||
|
animation: none;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
&::view-transition-new(hero) {
|
||||||
|
animation: var(--vt-duration-default) 0s fadeIn forwards;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
html:active-view-transition-type(timeline) {
|
||||||
|
&::view-transition-old(hero) {
|
||||||
|
animation: var(--vt-duration-default) 0s fadeOut forwards;
|
||||||
|
}
|
||||||
|
&::view-transition-new(hero) {
|
||||||
|
animation: var(--vt-duration-default) 0s fadeIn forwards;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-group(letterbox-left),
|
||||||
|
::view-transition-group(letterbox-right),
|
||||||
|
::view-transition-group(letterbox-top),
|
||||||
|
::view-transition-group(letterbox-bottom) {
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-old(letterbox-left),
|
||||||
|
::view-transition-old(letterbox-right),
|
||||||
|
::view-transition-old(letterbox-top),
|
||||||
|
::view-transition-old(letterbox-bottom),
|
||||||
|
::view-transition-new(letterbox-left),
|
||||||
|
::view-transition-new(letterbox-right),
|
||||||
|
::view-transition-new(letterbox-top),
|
||||||
|
::view-transition-new(letterbox-bottom) {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-group(previous),
|
||||||
|
::view-transition-group(previous-old),
|
||||||
|
::view-transition-group(next),
|
||||||
|
::view-transition-group(next-old) {
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
transform: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-old(previous),
|
||||||
|
::view-transition-old(previous-old),
|
||||||
|
::view-transition-old(next),
|
||||||
|
::view-transition-old(next-old) {
|
||||||
|
animation: var(--vt-duration-viewer-navigation) fadeOut forwards;
|
||||||
|
transform-origin: center;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
object-fit: contain;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
::view-transition-new(previous),
|
||||||
|
::view-transition-new(previous-new),
|
||||||
|
::view-transition-new(next),
|
||||||
|
::view-transition-new(next-new) {
|
||||||
|
animation: var(--vt-duration-viewer-navigation) fadeIn forwards;
|
||||||
|
transform-origin: center;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { thumbhash } from '$lib/actions/thumbhash';
|
import { thumbhash } from '$lib/actions/thumbhash';
|
||||||
import AlphaBackground from '$lib/components/AlphaBackground.svelte';
|
import AlphaBackground from '$lib/components/AlphaBackground.svelte';
|
||||||
|
import Letterboxes from '$lib/components/asset-viewer/letterboxes.svelte';
|
||||||
import BrokenAsset from '$lib/components/assets/broken-asset.svelte';
|
import BrokenAsset from '$lib/components/assets/broken-asset.svelte';
|
||||||
import DelayedLoadingSpinner from '$lib/components/DelayedLoadingSpinner.svelte';
|
import DelayedLoadingSpinner from '$lib/components/DelayedLoadingSpinner.svelte';
|
||||||
import ImageLayer from '$lib/components/ImageLayer.svelte';
|
import ImageLayer from '$lib/components/ImageLayer.svelte';
|
||||||
@@ -18,6 +19,10 @@
|
|||||||
sharedLink?: SharedLinkResponseDto;
|
sharedLink?: SharedLinkResponseDto;
|
||||||
objectFit?: 'contain' | 'cover';
|
objectFit?: 'contain' | 'cover';
|
||||||
container: Size;
|
container: Size;
|
||||||
|
showLetterboxes?: boolean;
|
||||||
|
transitionName?: string | null | undefined;
|
||||||
|
letterboxTransitionName?: string | undefined;
|
||||||
|
imageClass?: string;
|
||||||
onUrlChange?: (url: string) => void;
|
onUrlChange?: (url: string) => void;
|
||||||
onImageReady?: () => void;
|
onImageReady?: () => void;
|
||||||
onError?: () => void;
|
onError?: () => void;
|
||||||
@@ -41,6 +46,10 @@
|
|||||||
sharedLink,
|
sharedLink,
|
||||||
objectFit = 'contain',
|
objectFit = 'contain',
|
||||||
container,
|
container,
|
||||||
|
showLetterboxes = true,
|
||||||
|
transitionName,
|
||||||
|
letterboxTransitionName,
|
||||||
|
imageClass,
|
||||||
onUrlChange,
|
onUrlChange,
|
||||||
onImageReady,
|
onImageReady,
|
||||||
onError,
|
onError,
|
||||||
@@ -166,10 +175,20 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="relative h-full w-full overflow-hidden will-change-transform" bind:this={ref}>
|
<div class="relative h-full w-full overflow-hidden" bind:this={ref}>
|
||||||
{@render backdrop?.()}
|
{@render backdrop?.()}
|
||||||
|
|
||||||
<div class="absolute inset-0 pointer-events-none" style:left style:top style:width style:height>
|
<Letterboxes {letterboxTransitionName} show={showLetterboxes} {scaledDimensions} {container} />
|
||||||
|
|
||||||
|
<div
|
||||||
|
class={['absolute inset-0 pointer-events-none', imageClass]}
|
||||||
|
style:left
|
||||||
|
style:top
|
||||||
|
style:width
|
||||||
|
style:height
|
||||||
|
style:view-transition-name={transitionName}
|
||||||
|
data-transition-name={transitionName}
|
||||||
|
>
|
||||||
{#if show.alphaBackground}
|
{#if show.alphaBackground}
|
||||||
<AlphaBackground />
|
<AlphaBackground />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
<script module lang="ts">
|
||||||
|
const useSplitNavTransitions =
|
||||||
|
typeof document !== 'undefined' &&
|
||||||
|
getComputedStyle(document.documentElement).getPropertyValue('--immich-split-viewer-nav').trim() === 'enabled';
|
||||||
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
import { focusTrap } from '$lib/actions/focus-trap';
|
import { focusTrap } from '$lib/actions/focus-trap';
|
||||||
@@ -13,6 +19,7 @@
|
|||||||
import { authManager } from '$lib/managers/auth-manager.svelte';
|
import { authManager } from '$lib/managers/auth-manager.svelte';
|
||||||
import { editManager, EditToolType } from '$lib/managers/edit/edit-manager.svelte';
|
import { editManager, EditToolType } from '$lib/managers/edit/edit-manager.svelte';
|
||||||
import { eventManager } from '$lib/managers/event-manager.svelte';
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||||
|
import { viewTransitionManager } from '$lib/managers/ViewTransitionManager.svelte';
|
||||||
import { getAssetActions } from '$lib/services/asset.service';
|
import { getAssetActions } from '$lib/services/asset.service';
|
||||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||||
import { isFaceEditMode } from '$lib/stores/face-edit.svelte';
|
import { isFaceEditMode } from '$lib/stores/face-edit.svelte';
|
||||||
@@ -27,6 +34,7 @@
|
|||||||
import { InvocationTracker } from '$lib/utils/invocationTracker';
|
import { InvocationTracker } from '$lib/utils/invocationTracker';
|
||||||
import { SlideshowHistory } from '$lib/utils/slideshow-history';
|
import { SlideshowHistory } from '$lib/utils/slideshow-history';
|
||||||
import { toTimelineAsset } from '$lib/utils/timeline-util';
|
import { toTimelineAsset } from '$lib/utils/timeline-util';
|
||||||
|
import { crossfadeViewerContent, removeCrossfadeOverlay } from '$lib/utils/transition-utils';
|
||||||
import {
|
import {
|
||||||
AssetTypeEnum,
|
AssetTypeEnum,
|
||||||
getAssetInfo,
|
getAssetInfo,
|
||||||
@@ -40,7 +48,7 @@
|
|||||||
import { onDestroy, onMount, untrack } from 'svelte';
|
import { onDestroy, onMount, untrack } from 'svelte';
|
||||||
import type { SwipeCustomEvent } from 'svelte-gestures';
|
import type { SwipeCustomEvent } from 'svelte-gestures';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
import { fly } from 'svelte/transition';
|
import { fly, slide } from 'svelte/transition';
|
||||||
import Thumbnail from '../assets/thumbnail/thumbnail.svelte';
|
import Thumbnail from '../assets/thumbnail/thumbnail.svelte';
|
||||||
import ActivityStatus from './activity-status.svelte';
|
import ActivityStatus from './activity-status.svelte';
|
||||||
import ActivityViewer from './activity-viewer.svelte';
|
import ActivityViewer from './activity-viewer.svelte';
|
||||||
@@ -89,13 +97,14 @@
|
|||||||
onRandom,
|
onRandom,
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
const { setAssetId } = assetViewingStore;
|
const { setAssetId, invisible } = assetViewingStore;
|
||||||
const {
|
const {
|
||||||
restartProgress: restartSlideshowProgress,
|
restartProgress: restartSlideshowProgress,
|
||||||
stopProgress: stopSlideshowProgress,
|
stopProgress: stopSlideshowProgress,
|
||||||
slideshowNavigation,
|
slideshowNavigation,
|
||||||
slideshowState,
|
slideshowState,
|
||||||
slideshowRepeat,
|
slideshowRepeat,
|
||||||
|
slideshowTransition,
|
||||||
} = slideshowStore;
|
} = slideshowStore;
|
||||||
const stackThumbnailSize = 60;
|
const stackThumbnailSize = 60;
|
||||||
const stackSelectedThumbnailSize = 65;
|
const stackSelectedThumbnailSize = 65;
|
||||||
@@ -109,6 +118,10 @@
|
|||||||
let sharedLink = getSharedLink();
|
let sharedLink = getSharedLink();
|
||||||
let fullscreenElement = $state<Element>();
|
let fullscreenElement = $state<Element>();
|
||||||
|
|
||||||
|
let slideShowPlaying = $derived($slideshowState === SlideshowState.PlaySlideshow);
|
||||||
|
let slideShowAscending = $derived($slideshowNavigation === SlideshowNavigation.AscendingOrder);
|
||||||
|
let slideShowShuffle = $derived($slideshowNavigation === SlideshowNavigation.Shuffle);
|
||||||
|
|
||||||
let playOriginalVideo = $state($alwaysLoadOriginalVideo);
|
let playOriginalVideo = $state($alwaysLoadOriginalVideo);
|
||||||
let slideshowStartAssetId = $state<string>();
|
let slideshowStartAssetId = $state<string>();
|
||||||
|
|
||||||
@@ -142,35 +155,40 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onAssetUpdate = (updatedAsset: AssetResponseDto) => {
|
let transitionName = $state<string | undefined>('hero');
|
||||||
if (asset.id === updatedAsset.id) {
|
let letterboxTransitionName = $state<string | undefined>(undefined);
|
||||||
cursor = { ...cursor, current: updatedAsset };
|
let detailPanelTransitionName = $state<string | undefined>(undefined);
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
let unsubscribes: (() => void)[] = [];
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
syncAssetViewerOpenClass(true);
|
syncAssetViewerOpenClass(true);
|
||||||
const slideshowStateUnsubscribe = slideshowState.subscribe((value) => {
|
|
||||||
if (value === SlideshowState.PlaySlideshow) {
|
|
||||||
slideshowHistory.reset();
|
|
||||||
slideshowHistory.queue(toTimelineAsset(asset));
|
|
||||||
handlePromiseError(handlePlaySlideshow());
|
|
||||||
} else if (value === SlideshowState.StopSlideshow) {
|
|
||||||
handlePromiseError(handleStopSlideshow());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const slideshowNavigationUnsubscribe = slideshowNavigation.subscribe((value) => {
|
const addInfoTransition = () => {
|
||||||
if (value === SlideshowNavigation.Shuffle) {
|
detailPanelTransitionName = 'info';
|
||||||
slideshowHistory.reset();
|
transitionName = 'hero';
|
||||||
slideshowHistory.queue(toTimelineAsset(asset));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
slideshowStateUnsubscribe();
|
|
||||||
slideshowNavigationUnsubscribe();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
unsubscribes.push(
|
||||||
|
eventManager.on({
|
||||||
|
ViewerOpenTransition: addInfoTransition,
|
||||||
|
ViewerCloseTransition: addInfoTransition,
|
||||||
|
}),
|
||||||
|
slideshowState.subscribe((value) => {
|
||||||
|
if (value === SlideshowState.PlaySlideshow) {
|
||||||
|
slideshowHistory.reset();
|
||||||
|
slideshowHistory.queue(toTimelineAsset(asset));
|
||||||
|
handlePromiseError(handlePlaySlideshow());
|
||||||
|
} else if (value === SlideshowState.StopSlideshow) {
|
||||||
|
handlePromiseError(handleStopSlideshow());
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
slideshowNavigation.subscribe((value) => {
|
||||||
|
if (value === SlideshowNavigation.Shuffle) {
|
||||||
|
slideshowHistory.reset();
|
||||||
|
slideshowHistory.queue(toTimelineAsset(asset));
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
@@ -179,10 +197,16 @@
|
|||||||
isFaceEditMode.value = false;
|
isFaceEditMode.value = false;
|
||||||
syncAssetViewerOpenClass(false);
|
syncAssetViewerOpenClass(false);
|
||||||
preloadManager.destroy();
|
preloadManager.destroy();
|
||||||
|
|
||||||
|
for (const unsubscribe of unsubscribes) {
|
||||||
|
unsubscribe();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const closeViewer = () => {
|
const closeViewer = () => {
|
||||||
onClose?.(asset);
|
transitionName = 'hero';
|
||||||
|
const id = stack?.primaryAssetId ?? asset.id;
|
||||||
|
onClose?.({ ...asset, id });
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeEditor = async () => {
|
const closeEditor = async () => {
|
||||||
@@ -194,65 +218,132 @@
|
|||||||
assetViewerManager.closeEditor();
|
assetViewerManager.closeEditor();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getTransitionName = (kind: 'old' | 'new', direction: string | null | undefined) => {
|
||||||
|
if (direction === 'previous' || direction === 'next') {
|
||||||
|
return useSplitNavTransitions ? `${direction}-${kind}` : direction;
|
||||||
|
}
|
||||||
|
return direction ?? undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearTransitionNames = () => {
|
||||||
|
detailPanelTransitionName = undefined;
|
||||||
|
transitionName = undefined;
|
||||||
|
letterboxTransitionName = undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
const startTransition = async (
|
||||||
|
types: string[],
|
||||||
|
targetTransition: string | null,
|
||||||
|
navigateFn: () => Promise<boolean>,
|
||||||
|
) => {
|
||||||
|
const oldName = getTransitionName('old', targetTransition);
|
||||||
|
const newName = getTransitionName('new', targetTransition);
|
||||||
|
|
||||||
|
let result = false;
|
||||||
|
|
||||||
|
await viewTransitionManager.startTransition({
|
||||||
|
types,
|
||||||
|
prepareOldSnapshot: () => {
|
||||||
|
transitionName = oldName;
|
||||||
|
letterboxTransitionName = targetTransition ? `${targetTransition}-old` : undefined;
|
||||||
|
detailPanelTransitionName = 'detail-panel';
|
||||||
|
},
|
||||||
|
performUpdate: async (signal) => {
|
||||||
|
const ready = eventManager.untilNext('ViewerOpenTransitionReady', { signal });
|
||||||
|
result = await navigateFn();
|
||||||
|
await ready;
|
||||||
|
},
|
||||||
|
prepareNewSnapshot: () => {
|
||||||
|
transitionName = newName;
|
||||||
|
letterboxTransitionName = targetTransition ? `${targetTransition}-new` : undefined;
|
||||||
|
},
|
||||||
|
onFinished: clearTransitionNames,
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
const completeNavigation = async (order: 'previous' | 'next', skipTransition: boolean) => {
|
||||||
|
preloadManager.cancelBeforeNavigation(order);
|
||||||
|
const skipped = viewTransitionManager.skipTransitions();
|
||||||
|
const canTransition = viewTransitionManager.isSupported() && !skipped && !skipTransition;
|
||||||
|
|
||||||
|
let navigate: () => Promise<boolean>;
|
||||||
|
let types: string[];
|
||||||
|
let targetTransition: string | null;
|
||||||
|
|
||||||
|
if (slideShowPlaying && slideShowShuffle) {
|
||||||
|
navigate = async () => {
|
||||||
|
let next = order === 'previous' ? slideshowHistory.previous() : slideshowHistory.next();
|
||||||
|
if (!next) {
|
||||||
|
const asset = await onRandom?.();
|
||||||
|
if (asset) {
|
||||||
|
slideshowHistory.queue(asset);
|
||||||
|
next = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
};
|
||||||
|
types = ['slideshow'];
|
||||||
|
targetTransition = null;
|
||||||
|
} else {
|
||||||
|
navigate = async () => {
|
||||||
|
const target = order === 'previous' ? previousAsset : nextAsset;
|
||||||
|
return navigateToAsset(target);
|
||||||
|
};
|
||||||
|
types = slideShowPlaying ? ['slideshow'] : ['viewer-nav'];
|
||||||
|
targetTransition = slideShowPlaying ? null : order;
|
||||||
|
}
|
||||||
|
|
||||||
|
const targetAsset = order === 'previous' ? previousAsset : nextAsset;
|
||||||
|
const slideshowAllowsTransition = !slideShowPlaying || $slideshowTransition;
|
||||||
|
const useTransition = canTransition && slideshowAllowsTransition && (slideShowShuffle || !!targetAsset);
|
||||||
|
const hasNext = useTransition ? await startTransition(types, targetTransition, navigate) : await navigate();
|
||||||
|
|
||||||
|
if (!slideShowPlaying) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasNext) {
|
||||||
|
$restartSlideshowProgress = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($slideshowRepeat && slideshowStartAssetId) {
|
||||||
|
await setAssetId(slideshowStartAssetId);
|
||||||
|
$restartSlideshowProgress = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await handleStopSlideshow();
|
||||||
|
};
|
||||||
|
|
||||||
const tracker = new InvocationTracker();
|
const tracker = new InvocationTracker();
|
||||||
const navigateAsset = (order?: 'previous' | 'next') => {
|
let navigating = $state(false);
|
||||||
|
const navigateAsset = (order?: 'previous' | 'next', skipTransition: boolean = false) => {
|
||||||
if (!order) {
|
if (!order) {
|
||||||
if ($slideshowState === SlideshowState.PlaySlideshow) {
|
if (slideShowPlaying) {
|
||||||
order = $slideshowNavigation === SlideshowNavigation.AscendingOrder ? 'previous' : 'next';
|
order = slideShowAscending ? 'previous' : 'next';
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preloadManager.cancelBeforeNavigation(order);
|
|
||||||
|
|
||||||
if (tracker.isActive()) {
|
if (tracker.isActive()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tracker.invoke(async () => {
|
navigating = true;
|
||||||
const isShuffle =
|
void tracker.invoke(
|
||||||
$slideshowState === SlideshowState.PlaySlideshow && $slideshowNavigation === SlideshowNavigation.Shuffle;
|
() => completeNavigation(order, skipTransition),
|
||||||
|
(error: unknown) => handleError(error, $t('error_while_navigating')),
|
||||||
let hasNext: boolean;
|
() => {
|
||||||
|
navigating = false;
|
||||||
if (isShuffle) {
|
eventManager.emit('ViewerAfterNavigate');
|
||||||
hasNext = order === 'previous' ? slideshowHistory.previous() : slideshowHistory.next();
|
},
|
||||||
if (!hasNext) {
|
);
|
||||||
const asset = await onRandom?.();
|
|
||||||
if (asset) {
|
|
||||||
slideshowHistory.queue(asset);
|
|
||||||
hasNext = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
hasNext =
|
|
||||||
order === 'previous' ? await navigateToAsset(cursor.previousAsset) : await navigateToAsset(cursor.nextAsset);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($slideshowState !== SlideshowState.PlaySlideshow) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasNext) {
|
|
||||||
$restartSlideshowProgress = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($slideshowRepeat && slideshowStartAssetId) {
|
|
||||||
await setAssetId(slideshowStartAssetId);
|
|
||||||
$restartSlideshowProgress = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await handleStopSlideshow();
|
|
||||||
}, $t('error_while_navigating'));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Slide show mode
|
|
||||||
*/
|
|
||||||
|
|
||||||
let assetViewerHtmlElement = $state<HTMLElement>();
|
let assetViewerHtmlElement = $state<HTMLElement>();
|
||||||
|
|
||||||
const slideshowHistory = new SlideshowHistory((asset) => {
|
const slideshowHistory = new SlideshowHistory((asset) => {
|
||||||
@@ -277,10 +368,11 @@
|
|||||||
|
|
||||||
const handleStopSlideshow = async () => {
|
const handleStopSlideshow = async () => {
|
||||||
try {
|
try {
|
||||||
if (document.fullscreenElement) {
|
if (!document.fullscreenElement) {
|
||||||
document.body.style.cursor = '';
|
return;
|
||||||
await document.exitFullscreen();
|
|
||||||
}
|
}
|
||||||
|
document.body.style.cursor = '';
|
||||||
|
await document.exitFullscreen();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, $t('errors.unable_to_exit_fullscreen'));
|
handleError(error, $t('errors.unable_to_exit_fullscreen'));
|
||||||
} finally {
|
} finally {
|
||||||
@@ -289,11 +381,24 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleStackedAssetMouseEvent = (isMouseOver: boolean, stackedAsset: AssetResponseDto) => {
|
const handleStackedAssetMouseEnter = (stackedAsset: AssetResponseDto) => {
|
||||||
previewStackedAsset = isMouseOver ? stackedAsset : undefined;
|
if ((previewStackedAsset ?? cursor.current).id === stackedAsset.id) {
|
||||||
if (isMouseOver) {
|
return;
|
||||||
isFaceEditMode.value = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isFaceEditMode.value = false;
|
||||||
|
void crossfadeViewerContent(() => {
|
||||||
|
previewStackedAsset = stackedAsset;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleStackSlideshowMouseLeave = () => {
|
||||||
|
if (!previewStackedAsset) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeCrossfadeOverlay();
|
||||||
|
previewStackedAsset = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePreAction = (action: Action) => {
|
const handlePreAction = (action: Action) => {
|
||||||
@@ -394,15 +499,24 @@
|
|||||||
if (cursor.current.id === lastCursor?.current.id) {
|
if (cursor.current.id === lastCursor?.current.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastCursor) {
|
if (lastCursor) {
|
||||||
|
previewStackedAsset = undefined;
|
||||||
|
ocrManager.showOverlay = false;
|
||||||
preloadManager.updateAfterNavigation(lastCursor, cursor, sharedLink);
|
preloadManager.updateAfterNavigation(lastCursor, cursor, sharedLink);
|
||||||
|
lastCursor = cursor;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (!lastCursor) {
|
preloadManager.initializePreloads(cursor, sharedLink);
|
||||||
preloadManager.initializePreloads(cursor, sharedLink);
|
|
||||||
}
|
|
||||||
lastCursor = cursor;
|
lastCursor = cursor;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const onAssetUpdate = (update: AssetResponseDto) => {
|
||||||
|
if (asset.id === update.id) {
|
||||||
|
cursor = { ...cursor, current: update };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const viewerKind = $derived.by(() => {
|
const viewerKind = $derived.by(() => {
|
||||||
if (previewStackedAsset) {
|
if (previewStackedAsset) {
|
||||||
return previewStackedAsset.type === AssetTypeEnum.Image ? 'PhotoViewer' : 'StackVideoViewer';
|
return previewStackedAsset.type === AssetTypeEnum.Image ? 'PhotoViewer' : 'StackVideoViewer';
|
||||||
@@ -473,13 +587,17 @@
|
|||||||
|
|
||||||
<section
|
<section
|
||||||
id="immich-asset-viewer"
|
id="immich-asset-viewer"
|
||||||
class="fixed start-0 top-0 grid size-full grid-cols-4 grid-rows-[64px_1fr] overflow-hidden bg-black touch-none"
|
class="fixed inset-s-0 top-0 z-10 grid size-full grid-cols-4 grid-rows-[64px_1fr] overflow-hidden bg-black touch-none"
|
||||||
|
class:invisible={$invisible}
|
||||||
|
data-navigating={navigating || undefined}
|
||||||
use:focusTrap
|
use:focusTrap
|
||||||
bind:this={assetViewerHtmlElement}
|
bind:this={assetViewerHtmlElement}
|
||||||
>
|
>
|
||||||
<!-- Top navigation bar -->
|
|
||||||
{#if $slideshowState === SlideshowState.None && !assetViewerManager.isShowEditor}
|
{#if $slideshowState === SlideshowState.None && !assetViewerManager.isShowEditor}
|
||||||
<div class="col-span-4 col-start-1 row-span-1 row-start-1 transition-transform">
|
<div
|
||||||
|
class="col-span-4 col-start-1 row-span-1 row-start-1 transition-transform"
|
||||||
|
style:view-transition-name="exclude"
|
||||||
|
>
|
||||||
<AssetViewerNavBar
|
<AssetViewerNavBar
|
||||||
{asset}
|
{asset}
|
||||||
{album}
|
{album}
|
||||||
@@ -490,7 +608,7 @@
|
|||||||
onAction={handleAction}
|
onAction={handleAction}
|
||||||
{onUndoDelete}
|
{onUndoDelete}
|
||||||
onPlaySlideshow={() => ($slideshowState = SlideshowState.PlaySlideshow)}
|
onPlaySlideshow={() => ($slideshowState = SlideshowState.PlaySlideshow)}
|
||||||
onClose={onClose ? () => onClose(asset) : undefined}
|
onClose={onClose ? closeViewer : undefined}
|
||||||
{playOriginalVideo}
|
{playOriginalVideo}
|
||||||
{setPlayOriginalVideo}
|
{setPlayOriginalVideo}
|
||||||
/>
|
/>
|
||||||
@@ -511,16 +629,21 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if $slideshowState === SlideshowState.None && showNavigation && !assetViewerManager.isShowEditor && !isFaceEditMode.value && previousAsset}
|
{#if $slideshowState === SlideshowState.None && showNavigation && !assetViewerManager.isShowEditor && !isFaceEditMode.value && previousAsset}
|
||||||
<div class="my-auto col-span-1 col-start-1 row-span-full row-start-1 justify-self-start">
|
<div
|
||||||
|
data-test-id="previous-asset"
|
||||||
|
class="my-auto col-span-1 col-start-1 row-span-full row-start-1 justify-self-start"
|
||||||
|
style:view-transition-name="exclude-leftbutton"
|
||||||
|
>
|
||||||
<PreviousAssetAction onPreviousAsset={() => navigateAsset('previous')} />
|
<PreviousAssetAction onPreviousAsset={() => navigateAsset('previous')} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<!-- Asset Viewer -->
|
|
||||||
<div data-viewer-content class="z-[-1] relative col-start-1 col-span-4 row-start-1 row-span-full">
|
<div data-viewer-content class="z-[-1] relative col-start-1 col-span-4 row-start-1 row-span-full">
|
||||||
{#if viewerKind === 'StackVideoViewer'}
|
{#if viewerKind === 'StackVideoViewer'}
|
||||||
<VideoViewer
|
<VideoViewer
|
||||||
|
{transitionName}
|
||||||
asset={previewStackedAsset!}
|
asset={previewStackedAsset!}
|
||||||
|
assetId={previewStackedAsset!.id}
|
||||||
cacheKey={previewStackedAsset!.thumbhash}
|
cacheKey={previewStackedAsset!.thumbhash}
|
||||||
projectionType={previewStackedAsset!.exifInfo?.projectionType}
|
projectionType={previewStackedAsset!.exifInfo?.projectionType}
|
||||||
loopVideo={true}
|
loopVideo={true}
|
||||||
@@ -533,6 +656,7 @@
|
|||||||
/>
|
/>
|
||||||
{:else if viewerKind === 'LiveVideoViewer'}
|
{:else if viewerKind === 'LiveVideoViewer'}
|
||||||
<VideoViewer
|
<VideoViewer
|
||||||
|
{transitionName}
|
||||||
{asset}
|
{asset}
|
||||||
assetId={asset.livePhotoVideoId!}
|
assetId={asset.livePhotoVideoId!}
|
||||||
cacheKey={asset.thumbhash}
|
cacheKey={asset.thumbhash}
|
||||||
@@ -544,13 +668,20 @@
|
|||||||
{playOriginalVideo}
|
{playOriginalVideo}
|
||||||
/>
|
/>
|
||||||
{:else if viewerKind === 'ImagePanaramaViewer'}
|
{:else if viewerKind === 'ImagePanaramaViewer'}
|
||||||
<ImagePanoramaViewer {asset} />
|
<ImagePanoramaViewer {asset} {transitionName} {letterboxTransitionName} />
|
||||||
{:else if viewerKind === 'CropArea'}
|
{:else if viewerKind === 'CropArea'}
|
||||||
<CropArea {asset} />
|
<CropArea {asset} />
|
||||||
{:else if viewerKind === 'PhotoViewer'}
|
{:else if viewerKind === 'PhotoViewer'}
|
||||||
<PhotoViewer cursor={{ ...cursor, current: asset }} {sharedLink} {onSwipe} />
|
<PhotoViewer
|
||||||
|
{transitionName}
|
||||||
|
{letterboxTransitionName}
|
||||||
|
cursor={{ ...cursor, current: asset }}
|
||||||
|
{sharedLink}
|
||||||
|
{onSwipe}
|
||||||
|
/>
|
||||||
{:else if viewerKind === 'VideoViewer'}
|
{:else if viewerKind === 'VideoViewer'}
|
||||||
<VideoViewer
|
<VideoViewer
|
||||||
|
{transitionName}
|
||||||
{asset}
|
{asset}
|
||||||
cacheKey={asset.thumbhash}
|
cacheKey={asset.thumbhash}
|
||||||
projectionType={asset.exifInfo?.projectionType}
|
projectionType={asset.exifInfo?.projectionType}
|
||||||
@@ -584,15 +715,20 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if $slideshowState === SlideshowState.None && showNavigation && !assetViewerManager.isShowEditor && !isFaceEditMode.value && nextAsset}
|
{#if $slideshowState === SlideshowState.None && showNavigation && !assetViewerManager.isShowEditor && !isFaceEditMode.value && nextAsset}
|
||||||
<div class="my-auto col-span-1 col-start-4 row-span-full row-start-1 justify-self-end">
|
<div
|
||||||
|
data-test-id="next-asset"
|
||||||
|
class="my-auto col-span-1 col-start-4 row-span-full row-start-1 justify-self-end"
|
||||||
|
style:view-transition-name="exclude-rightbutton"
|
||||||
|
>
|
||||||
<NextAssetAction onNextAsset={() => navigateAsset('next')} />
|
<NextAssetAction onNextAsset={() => navigateAsset('next')} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if showDetailPanel || assetViewerManager.isShowEditor}
|
{#if showDetailPanel || assetViewerManager.isShowEditor}
|
||||||
<div
|
<div
|
||||||
transition:fly={{ duration: 150 }}
|
transition:slide={{ axis: 'x', duration: 150 }}
|
||||||
id="detail-panel"
|
id="detail-panel"
|
||||||
|
style:view-transition-name={detailPanelTransitionName}
|
||||||
class="row-start-1 row-span-4 overflow-y-auto transition-all dark:border-l dark:border-s-immich-dark-gray bg-light"
|
class="row-start-1 row-span-4 overflow-y-auto transition-all dark:border-l dark:border-s-immich-dark-gray bg-light"
|
||||||
translate="yes"
|
translate="yes"
|
||||||
>
|
>
|
||||||
@@ -608,9 +744,14 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if stack && withStacked && !assetViewerManager.isShowEditor}
|
{#if stack && withStacked && !assetViewerManager.isShowEditor && $slideshowState === SlideshowState.None}
|
||||||
{@const stackedAssets = stack.assets}
|
{@const stackedAssets = stack.assets}
|
||||||
<div id="stack-slideshow" class="absolute bottom-0 w-full col-span-4 col-start-1 pointer-events-none">
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
|
<div
|
||||||
|
id="stack-slideshow"
|
||||||
|
class="absolute bottom-0 w-full col-span-4 col-start-1 pointer-events-none"
|
||||||
|
onmouseleave={handleStackSlideshowMouseLeave}
|
||||||
|
>
|
||||||
<div class="relative flex flex-row no-wrap overflow-x-auto overflow-y-hidden horizontal-scrollbar">
|
<div class="relative flex flex-row no-wrap overflow-x-auto overflow-y-hidden horizontal-scrollbar">
|
||||||
{#each stackedAssets as stackedAsset (stackedAsset.id)}
|
{#each stackedAssets as stackedAsset (stackedAsset.id)}
|
||||||
<div
|
<div
|
||||||
@@ -623,11 +764,12 @@
|
|||||||
dimmed={stackedAsset.id !== asset.id}
|
dimmed={stackedAsset.id !== asset.id}
|
||||||
asset={toTimelineAsset(stackedAsset)}
|
asset={toTimelineAsset(stackedAsset)}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
removeCrossfadeOverlay();
|
||||||
cursor.current = stackedAsset;
|
cursor.current = stackedAsset;
|
||||||
previewStackedAsset = undefined;
|
previewStackedAsset = undefined;
|
||||||
isFaceEditMode.value = false;
|
isFaceEditMode.value = false;
|
||||||
}}
|
}}
|
||||||
onMouseEvent={({ isMouseOver }) => handleStackedAssetMouseEvent(isMouseOver, stackedAsset)}
|
onMouseEvent={({ isMouseOver }) => isMouseOver && handleStackedAssetMouseEnter(stackedAsset)}
|
||||||
readonly
|
readonly
|
||||||
thumbnailSize={stackedAsset.id === asset.id ? stackSelectedThumbnailSize : stackThumbnailSize}
|
thumbnailSize={stackedAsset.id === asset.id ? stackSelectedThumbnailSize : stackThumbnailSize}
|
||||||
showStackedIcon={false}
|
showStackedIcon={false}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
import { Icon } from '@immich/ui';
|
import { Icon } from '@immich/ui';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
asset: AssetResponseDto;
|
asset: AssetResponseDto;
|
||||||
@@ -74,6 +75,8 @@
|
|||||||
alt={$getAltText(toTimelineAsset(asset))}
|
alt={$getAltText(toTimelineAsset(asset))}
|
||||||
class="h-full select-none transition-transform motion-reduce:transition-none"
|
class="h-full select-none transition-transform motion-reduce:transition-none"
|
||||||
style:transform={imageTransform}
|
style:transform={imageTransform}
|
||||||
|
onload={() => eventManager.emit('ViewerOpenTransitionReady')}
|
||||||
|
onerror={() => eventManager.emit('ViewerOpenTransitionReady')}
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
|
|||||||
@@ -4,13 +4,14 @@
|
|||||||
import { AssetMediaSize, viewAsset, type AssetResponseDto } from '@immich/sdk';
|
import { AssetMediaSize, viewAsset, type AssetResponseDto } from '@immich/sdk';
|
||||||
import { LoadingSpinner } from '@immich/ui';
|
import { LoadingSpinner } from '@immich/ui';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
import { fade } from 'svelte/transition';
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
transitionName?: string;
|
||||||
|
letterboxTransitionName?: string;
|
||||||
asset: AssetResponseDto;
|
asset: AssetResponseDto;
|
||||||
};
|
};
|
||||||
|
|
||||||
let { asset }: Props = $props();
|
let { transitionName, letterboxTransitionName, asset }: Props = $props();
|
||||||
|
|
||||||
const assetId = $derived(asset.id);
|
const assetId = $derived(asset.id);
|
||||||
|
|
||||||
@@ -20,11 +21,16 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div transition:fade={{ duration: 150 }} class="flex h-full select-none place-content-center place-items-center">
|
<div class="flex h-dvh w-dvw select-none place-content-center place-items-center">
|
||||||
{#await Promise.all([loadAssetData(assetId), import('./photo-sphere-viewer-adapter.svelte')])}
|
{#await Promise.all([loadAssetData(assetId), import('./photo-sphere-viewer-adapter.svelte')])}
|
||||||
<LoadingSpinner />
|
<LoadingSpinner />
|
||||||
{:then [data, { default: PhotoSphereViewer }]}
|
{:then [data, { default: PhotoSphereViewer }]}
|
||||||
<PhotoSphereViewer panorama={data} originalPanorama={getAssetUrl({ asset, forceOriginal: true })} />
|
<PhotoSphereViewer
|
||||||
|
{transitionName}
|
||||||
|
{letterboxTransitionName}
|
||||||
|
panorama={data}
|
||||||
|
originalPanorama={getAssetUrl({ asset, forceOriginal: true })}
|
||||||
|
/>
|
||||||
{:catch}
|
{:catch}
|
||||||
{$t('errors.failed_to_load_asset')}
|
{$t('errors.failed_to_load_asset')}
|
||||||
{/await}
|
{/await}
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
interface Props {
|
||||||
|
letterboxTransitionName?: string | undefined;
|
||||||
|
show?: boolean;
|
||||||
|
scaledDimensions: {
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
};
|
||||||
|
container: {
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let { letterboxTransitionName, show = true, scaledDimensions, container }: Props = $props();
|
||||||
|
|
||||||
|
const shouldShowLetterboxes = $derived(show && !!letterboxTransitionName);
|
||||||
|
|
||||||
|
const letterboxes = $derived.by(() => {
|
||||||
|
const { width, height } = scaledDimensions;
|
||||||
|
const horizontalOffset = (container.width - width) / 2;
|
||||||
|
const verticalOffset = (container.height - height) / 2;
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
name: 'letterbox-left',
|
||||||
|
width: horizontalOffset + 'px',
|
||||||
|
height: container.height + 'px',
|
||||||
|
left: '0px',
|
||||||
|
top: '0px',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'letterbox-right',
|
||||||
|
width: horizontalOffset + 'px',
|
||||||
|
height: container.height + 'px',
|
||||||
|
left: container.width - horizontalOffset + 'px',
|
||||||
|
top: '0px',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'letterbox-top',
|
||||||
|
width: width + 'px',
|
||||||
|
height: verticalOffset + 'px',
|
||||||
|
left: horizontalOffset + 'px',
|
||||||
|
top: '0px',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'letterbox-bottom',
|
||||||
|
width: width + 'px',
|
||||||
|
height: verticalOffset + 'px',
|
||||||
|
left: horizontalOffset + 'px',
|
||||||
|
top: container.height - verticalOffset + 'px',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if shouldShowLetterboxes}
|
||||||
|
{#each letterboxes as box (box.name)}
|
||||||
|
<div
|
||||||
|
class="absolute"
|
||||||
|
style:view-transition-name={box.name}
|
||||||
|
style:left={box.left}
|
||||||
|
style:top={box.top}
|
||||||
|
style:width={box.width}
|
||||||
|
style:height={box.height}
|
||||||
|
></div>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { shortcuts } from '$lib/actions/shortcut';
|
import { shortcuts } from '$lib/actions/shortcut';
|
||||||
import AssetViewerEvents from '$lib/components/AssetViewerEvents.svelte';
|
import AssetViewerEvents from '$lib/components/AssetViewerEvents.svelte';
|
||||||
|
import Letterboxes from '$lib/components/asset-viewer/letterboxes.svelte';
|
||||||
import { assetViewerManager } from '$lib/managers/asset-viewer-manager.svelte';
|
import { assetViewerManager } from '$lib/managers/asset-viewer-manager.svelte';
|
||||||
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||||
import { ocrManager, type OcrBoundingBox } from '$lib/stores/ocr.svelte';
|
import { ocrManager, type OcrBoundingBox } from '$lib/stores/ocr.svelte';
|
||||||
import { boundingBoxesArray, type Faces } from '$lib/stores/people.store';
|
import { boundingBoxesArray, type Faces } from '$lib/stores/people.store';
|
||||||
import { alwaysLoadOriginalFile } from '$lib/stores/preferences.store';
|
import { alwaysLoadOriginalFile } from '$lib/stores/preferences.store';
|
||||||
@@ -41,6 +43,8 @@
|
|||||||
'flex items-center justify-center text-white bg-black/50 cursor-text pointer-events-auto whitespace-pre-wrap wrap-break-word select-text';
|
'flex items-center justify-center text-white bg-black/50 cursor-text pointer-events-auto whitespace-pre-wrap wrap-break-word select-text';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
transitionName?: string;
|
||||||
|
letterboxTransitionName?: string;
|
||||||
panorama: string | { source: string };
|
panorama: string | { source: string };
|
||||||
originalPanorama?: string | { source: string };
|
originalPanorama?: string | { source: string };
|
||||||
adapter?: AdapterConstructor | [AdapterConstructor, unknown];
|
adapter?: AdapterConstructor | [AdapterConstructor, unknown];
|
||||||
@@ -48,11 +52,21 @@
|
|||||||
navbar?: boolean;
|
navbar?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
let { panorama, originalPanorama, adapter = EquirectangularAdapter, plugins = [], navbar = false }: Props = $props();
|
let {
|
||||||
|
transitionName,
|
||||||
|
letterboxTransitionName,
|
||||||
|
panorama,
|
||||||
|
originalPanorama,
|
||||||
|
adapter = EquirectangularAdapter,
|
||||||
|
plugins = [],
|
||||||
|
navbar = false,
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
let container: HTMLDivElement | undefined = $state();
|
let container: HTMLDivElement | undefined = $state();
|
||||||
let viewer: Viewer;
|
let viewer: Viewer;
|
||||||
|
|
||||||
|
const fullscreenDimensions = { width: globalThis.innerWidth || 0, height: globalThis.innerHeight || 0 };
|
||||||
|
|
||||||
let animationInProgress: { cancel: () => void } | undefined;
|
let animationInProgress: { cancel: () => void } | undefined;
|
||||||
let previousFaces: Faces[] = [];
|
let previousFaces: Faces[] = [];
|
||||||
|
|
||||||
@@ -210,6 +224,7 @@
|
|||||||
zoomSpeed: 0.5,
|
zoomSpeed: 0.5,
|
||||||
fisheye: false,
|
fisheye: false,
|
||||||
});
|
});
|
||||||
|
viewer.addEventListener('ready', () => eventManager.emit('ViewerOpenTransitionReady'), { once: true });
|
||||||
const resolutionPlugin = viewer.getPlugin<ResolutionPlugin>(ResolutionPlugin);
|
const resolutionPlugin = viewer.getPlugin<ResolutionPlugin>(ResolutionPlugin);
|
||||||
const zoomHandler = ({ zoomLevel }: events.ZoomUpdatedEvent) => {
|
const zoomHandler = ({ zoomLevel }: events.ZoomUpdatedEvent) => {
|
||||||
// zoomLevel is 0-100
|
// zoomLevel is 0-100
|
||||||
@@ -254,7 +269,15 @@
|
|||||||
<AssetViewerEvents {onZoom} />
|
<AssetViewerEvents {onZoom} />
|
||||||
|
|
||||||
<svelte:document use:shortcuts={[{ shortcut: { key: 'z' }, onShortcut: onZoom, preventDefault: true }]} />
|
<svelte:document use:shortcuts={[{ shortcut: { key: 'z' }, onShortcut: onZoom, preventDefault: true }]} />
|
||||||
<div class="h-full w-full mb-0" bind:this={container}></div>
|
<div
|
||||||
|
id="sphere"
|
||||||
|
class="h-full w-full h-dvh w-dvw mb-0"
|
||||||
|
bind:this={container}
|
||||||
|
style:view-transition-name={transitionName}
|
||||||
|
></div>
|
||||||
|
|
||||||
|
<!-- Zero-sized letterboxes for view transitions from/to regular photos -->
|
||||||
|
<Letterboxes {letterboxTransitionName} scaledDimensions={fullscreenDimensions} container={fullscreenDimensions} />
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* Reset the default tooltip styling */
|
/* Reset the default tooltip styling */
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
import AssetViewerEvents from '$lib/components/AssetViewerEvents.svelte';
|
import AssetViewerEvents from '$lib/components/AssetViewerEvents.svelte';
|
||||||
import { assetViewerManager } from '$lib/managers/asset-viewer-manager.svelte';
|
import { assetViewerManager } from '$lib/managers/asset-viewer-manager.svelte';
|
||||||
import { castManager } from '$lib/managers/cast-manager.svelte';
|
import { castManager } from '$lib/managers/cast-manager.svelte';
|
||||||
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||||
import { isEditFacesPanelOpen, isFaceEditMode } from '$lib/stores/face-edit.svelte';
|
import { isEditFacesPanelOpen, isFaceEditMode } from '$lib/stores/face-edit.svelte';
|
||||||
import { ocrManager } from '$lib/stores/ocr.svelte';
|
import { ocrManager } from '$lib/stores/ocr.svelte';
|
||||||
import { boundingBoxesArray, type Faces } from '$lib/stores/people.store';
|
import { boundingBoxesArray, type Faces } from '$lib/stores/people.store';
|
||||||
@@ -29,14 +30,26 @@
|
|||||||
cursor: AssetCursor;
|
cursor: AssetCursor;
|
||||||
element?: HTMLDivElement;
|
element?: HTMLDivElement;
|
||||||
sharedLink?: SharedLinkResponseDto;
|
sharedLink?: SharedLinkResponseDto;
|
||||||
onReady?: () => void;
|
transitionName?: string;
|
||||||
|
letterboxTransitionName?: string;
|
||||||
onError?: () => void;
|
onError?: () => void;
|
||||||
onSwipe?: (event: SwipeCustomEvent) => void;
|
onSwipe?: (event: SwipeCustomEvent) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
let { cursor, element = $bindable(), sharedLink, onReady, onError, onSwipe }: Props = $props();
|
let {
|
||||||
|
cursor,
|
||||||
|
element = $bindable(),
|
||||||
|
sharedLink,
|
||||||
|
transitionName,
|
||||||
|
letterboxTransitionName,
|
||||||
|
onError,
|
||||||
|
onSwipe,
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
const { slideshowState, slideshowLook } = slideshowStore;
|
const { slideshowState, slideshowLook } = slideshowStore;
|
||||||
|
const objectFit = $derived(
|
||||||
|
$slideshowState !== SlideshowState.None && $slideshowLook === SlideshowLook.Cover ? 'cover' : 'contain',
|
||||||
|
);
|
||||||
const asset = $derived(cursor.current);
|
const asset = $derived(cursor.current);
|
||||||
|
|
||||||
let visibleImageReady: boolean = $state(false);
|
let visibleImageReady: boolean = $state(false);
|
||||||
@@ -181,20 +194,23 @@
|
|||||||
{asset}
|
{asset}
|
||||||
{sharedLink}
|
{sharedLink}
|
||||||
{container}
|
{container}
|
||||||
objectFit={$slideshowState !== SlideshowState.None && $slideshowLook === SlideshowLook.Cover ? 'cover' : 'contain'}
|
{objectFit}
|
||||||
{onUrlChange}
|
{onUrlChange}
|
||||||
onImageReady={() => {
|
onImageReady={() => {
|
||||||
visibleImageReady = true;
|
visibleImageReady = true;
|
||||||
onReady?.();
|
eventManager.emit('ViewerOpenTransitionReady');
|
||||||
}}
|
}}
|
||||||
onError={() => {
|
onError={() => {
|
||||||
onError?.();
|
onError?.();
|
||||||
onReady?.();
|
eventManager.emit('ViewerOpenTransitionReady');
|
||||||
}}
|
}}
|
||||||
bind:imgRef={assetViewerManager.imgRef}
|
bind:imgRef={assetViewerManager.imgRef}
|
||||||
bind:imgNaturalSize={imageDimensions}
|
bind:imgNaturalSize={imageDimensions}
|
||||||
bind:imgScaledSize={scaledDimensions}
|
bind:imgScaledSize={scaledDimensions}
|
||||||
bind:ref={adaptiveImage}
|
bind:ref={adaptiveImage}
|
||||||
|
{transitionName}
|
||||||
|
{letterboxTransitionName}
|
||||||
|
showLetterboxes={!blurredSlideshow}
|
||||||
>
|
>
|
||||||
{#snippet backdrop()}
|
{#snippet backdrop()}
|
||||||
{#if blurredSlideshow}
|
{#if blurredSlideshow}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import VideoRemoteViewer from '$lib/components/asset-viewer/video-remote-viewer.svelte';
|
import VideoRemoteViewer from '$lib/components/asset-viewer/video-remote-viewer.svelte';
|
||||||
import { assetViewerFadeDuration } from '$lib/constants';
|
import { assetViewerFadeDuration } from '$lib/constants';
|
||||||
import { castManager } from '$lib/managers/cast-manager.svelte';
|
import { castManager } from '$lib/managers/cast-manager.svelte';
|
||||||
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||||
import { isFaceEditMode } from '$lib/stores/face-edit.svelte';
|
import { isFaceEditMode } from '$lib/stores/face-edit.svelte';
|
||||||
import {
|
import {
|
||||||
autoPlayVideo,
|
autoPlayVideo,
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
transitionName?: string;
|
||||||
assetId: string;
|
assetId: string;
|
||||||
imageSize: Size;
|
imageSize: Size;
|
||||||
loopVideo: boolean;
|
loopVideo: boolean;
|
||||||
@@ -32,6 +34,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
transitionName,
|
||||||
assetId,
|
assetId,
|
||||||
imageSize,
|
imageSize,
|
||||||
loopVideo,
|
loopVideo,
|
||||||
@@ -61,7 +64,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
// reactive on `assetFileUrl` changes
|
|
||||||
if (assetFileUrl) {
|
if (assetFileUrl) {
|
||||||
hasFocused = false;
|
hasFocused = false;
|
||||||
videoPlayer?.load();
|
videoPlayer?.load();
|
||||||
@@ -142,6 +144,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<video
|
<video
|
||||||
|
style:view-transition-name={transitionName}
|
||||||
bind:this={videoPlayer}
|
bind:this={videoPlayer}
|
||||||
loop={$loopVideoPreference && loopVideo}
|
loop={$loopVideoPreference && loopVideo}
|
||||||
autoplay={$autoPlayVideo}
|
autoplay={$autoPlayVideo}
|
||||||
@@ -150,6 +153,7 @@
|
|||||||
disablePictureInPicture
|
disablePictureInPicture
|
||||||
class="h-full object-contain"
|
class="h-full object-contain"
|
||||||
{...useSwipe(onSwipe)}
|
{...useSwipe(onSwipe)}
|
||||||
|
onloadedmetadata={() => eventManager.emit('ViewerOpenTransitionReady')}
|
||||||
oncanplay={(e) => handleCanPlay(e.currentTarget)}
|
oncanplay={(e) => handleCanPlay(e.currentTarget)}
|
||||||
onended={onVideoEnded}
|
onended={onVideoEnded}
|
||||||
onvolumechange={(e) => ($videoViewerMuted = e.currentTarget.muted)}
|
onvolumechange={(e) => ($videoViewerMuted = e.currentTarget.muted)}
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
import type { AssetResponseDto } from '@immich/sdk';
|
import type { AssetResponseDto } from '@immich/sdk';
|
||||||
import { LoadingSpinner } from '@immich/ui';
|
import { LoadingSpinner } from '@immich/ui';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
import { fade } from 'svelte/transition';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
transitionName?: string;
|
||||||
asset: AssetResponseDto;
|
asset: AssetResponseDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { asset }: Props = $props();
|
const { asset, transitionName }: Props = $props();
|
||||||
|
|
||||||
const modules = Promise.all([
|
const modules = Promise.all([
|
||||||
import('./photo-sphere-viewer-adapter.svelte').then((module) => module.default),
|
import('./photo-sphere-viewer-adapter.svelte').then((module) => module.default),
|
||||||
@@ -19,11 +19,12 @@
|
|||||||
]);
|
]);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div transition:fade={{ duration: 150 }} class="flex h-full select-none place-content-center place-items-center">
|
<div class="flex h-full select-none place-content-center place-items-center">
|
||||||
{#await modules}
|
{#await modules}
|
||||||
<LoadingSpinner />
|
<LoadingSpinner />
|
||||||
{:then [PhotoSphereViewer, adapter, videoPlugin]}
|
{:then [PhotoSphereViewer, adapter, videoPlugin]}
|
||||||
<PhotoSphereViewer
|
<PhotoSphereViewer
|
||||||
|
{transitionName}
|
||||||
panorama={{ source: getAssetPlaybackUrl({ id: asset.id }) }}
|
panorama={{ source: getAssetPlaybackUrl({ id: asset.id }) }}
|
||||||
originalPanorama={{ source: getAssetUrl({ asset, forceOriginal: true })! }}
|
originalPanorama={{ source: getAssetUrl({ asset, forceOriginal: true })! }}
|
||||||
plugins={[videoPlugin]}
|
plugins={[videoPlugin]}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import type { AssetResponseDto } from '@immich/sdk';
|
import type { AssetResponseDto } from '@immich/sdk';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
transitionName?: string;
|
||||||
asset: AssetResponseDto;
|
asset: AssetResponseDto;
|
||||||
assetId?: string;
|
assetId?: string;
|
||||||
projectionType: string | null | undefined;
|
projectionType: string | null | undefined;
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
transitionName,
|
||||||
asset,
|
asset,
|
||||||
assetId,
|
assetId,
|
||||||
projectionType,
|
projectionType,
|
||||||
@@ -36,9 +38,10 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if projectionType === ProjectionType.EQUIRECTANGULAR}
|
{#if projectionType === ProjectionType.EQUIRECTANGULAR}
|
||||||
<VideoPanoramaViewer {asset} />
|
<VideoPanoramaViewer {transitionName} {asset} />
|
||||||
{:else}
|
{:else}
|
||||||
<VideoNativeViewer
|
<VideoNativeViewer
|
||||||
|
{transitionName}
|
||||||
{loopVideo}
|
{loopVideo}
|
||||||
{cacheKey}
|
{cacheKey}
|
||||||
assetId={effectiveAssetId}
|
assetId={effectiveAssetId}
|
||||||
|
|||||||
@@ -6,10 +6,11 @@
|
|||||||
import { useActions, type ActionArray } from '$lib/actions/use-actions';
|
import { useActions, type ActionArray } from '$lib/actions/use-actions';
|
||||||
import NavigationBar from '$lib/components/shared-components/navigation-bar/navigation-bar.svelte';
|
import NavigationBar from '$lib/components/shared-components/navigation-bar/navigation-bar.svelte';
|
||||||
import UserSidebar from '$lib/components/shared-components/side-bar/user-sidebar.svelte';
|
import UserSidebar from '$lib/components/shared-components/side-bar/user-sidebar.svelte';
|
||||||
|
import { appManager } from '$lib/managers/app-manager.svelte';
|
||||||
import type { HeaderButtonActionItem } from '$lib/types';
|
import type { HeaderButtonActionItem } from '$lib/types';
|
||||||
import { openFileUploadDialog } from '$lib/utils/file-uploader';
|
import { openFileUploadDialog } from '$lib/utils/file-uploader';
|
||||||
import { Button, ContextMenuButton, HStack, isMenuItemType, type MenuItemType } from '@immich/ui';
|
import { Button, ContextMenuButton, HStack, isMenuItemType, type MenuItemType } from '@immich/ui';
|
||||||
import type { Snippet } from 'svelte';
|
import { type Snippet } from 'svelte';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -44,12 +45,17 @@
|
|||||||
|
|
||||||
let scrollbarClass = $derived(scrollbar ? 'immich-scrollbar' : 'scrollbar-hidden');
|
let scrollbarClass = $derived(scrollbar ? 'immich-scrollbar' : 'scrollbar-hidden');
|
||||||
let hasTitleClass = $derived(title ? 'top-16 h-[calc(100%-(--spacing(16)))]' : 'top-0 h-full');
|
let hasTitleClass = $derived(title ? 'top-16 h-[calc(100%-(--spacing(16)))]' : 'top-0 h-full');
|
||||||
|
let isAssetViewer = $derived(appManager.isAssetViewer);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
{#if !hideNavbar}
|
{#if !hideNavbar && !isAssetViewer}
|
||||||
<NavigationBar onUploadClick={() => openFileUploadDialog()} />
|
<NavigationBar onUploadClick={() => openFileUploadDialog()} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if isAssetViewer}
|
||||||
|
<div class="max-md:h-(--navbar-height-md) h-(--navbar-height)"></div>
|
||||||
|
{/if}
|
||||||
</header>
|
</header>
|
||||||
<div
|
<div
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
@@ -58,13 +64,15 @@
|
|||||||
{hideNavbar ? 'pt-(--navbar-height)' : ''}
|
{hideNavbar ? 'pt-(--navbar-height)' : ''}
|
||||||
{hideNavbar ? 'max-md:pt-(--navbar-height-md)' : ''}"
|
{hideNavbar ? 'max-md:pt-(--navbar-height-md)' : ''}"
|
||||||
>
|
>
|
||||||
{#if sidebar}
|
{#if isAssetViewer}
|
||||||
|
<div></div>
|
||||||
|
{:else if sidebar}
|
||||||
{@render sidebar()}
|
{@render sidebar()}
|
||||||
{:else}
|
{:else}
|
||||||
<UserSidebar />
|
<UserSidebar />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<main class="relative">
|
<main class="relative w-full">
|
||||||
<div class="{scrollbarClass} absolute {hasTitleClass} w-full overflow-y-auto p-2" use:useActions={use}>
|
<div class="{scrollbarClass} absolute {hasTitleClass} w-full overflow-y-auto p-2" use:useActions={use}>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,10 +3,13 @@
|
|||||||
import { shortcuts, type ShortcutOptions } from '$lib/actions/shortcut';
|
import { shortcuts, type ShortcutOptions } from '$lib/actions/shortcut';
|
||||||
import type { Action } from '$lib/components/asset-viewer/actions/action';
|
import type { Action } from '$lib/components/asset-viewer/actions/action';
|
||||||
import Thumbnail from '$lib/components/assets/thumbnail/thumbnail.svelte';
|
import Thumbnail from '$lib/components/assets/thumbnail/thumbnail.svelte';
|
||||||
|
import { focusAsset } from '$lib/components/timeline/actions/focus-actions';
|
||||||
import { AssetAction } from '$lib/constants';
|
import { AssetAction } from '$lib/constants';
|
||||||
import Portal from '$lib/elements/Portal.svelte';
|
import Portal from '$lib/elements/Portal.svelte';
|
||||||
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||||
import { featureFlagsManager } from '$lib/managers/feature-flags-manager.svelte';
|
import { featureFlagsManager } from '$lib/managers/feature-flags-manager.svelte';
|
||||||
import type { TimelineAsset, Viewport } from '$lib/managers/timeline-manager/types';
|
import type { TimelineAsset, Viewport } from '$lib/managers/timeline-manager/types';
|
||||||
|
import { viewTransitionManager } from '$lib/managers/ViewTransitionManager.svelte';
|
||||||
import AssetDeleteConfirmModal from '$lib/modals/AssetDeleteConfirmModal.svelte';
|
import AssetDeleteConfirmModal from '$lib/modals/AssetDeleteConfirmModal.svelte';
|
||||||
import ShortcutsModal from '$lib/modals/ShortcutsModal.svelte';
|
import ShortcutsModal from '$lib/modals/ShortcutsModal.svelte';
|
||||||
import { Route } from '$lib/route';
|
import { Route } from '$lib/route';
|
||||||
@@ -27,9 +30,11 @@
|
|||||||
import { getJustifiedLayoutFromAssets } from '$lib/utils/layout-utils';
|
import { getJustifiedLayoutFromAssets } from '$lib/utils/layout-utils';
|
||||||
import { navigate } from '$lib/utils/navigation';
|
import { navigate } from '$lib/utils/navigation';
|
||||||
import { isTimelineAsset, toTimelineAsset } from '$lib/utils/timeline-util';
|
import { isTimelineAsset, toTimelineAsset } from '$lib/utils/timeline-util';
|
||||||
|
import { startViewerTransition } from '$lib/utils/transition-utils';
|
||||||
import { AssetVisibility, type AssetResponseDto } from '@immich/sdk';
|
import { AssetVisibility, type AssetResponseDto } from '@immich/sdk';
|
||||||
import { modalManager } from '@immich/ui';
|
import { modalManager } from '@immich/ui';
|
||||||
import { debounce } from 'lodash-es';
|
import { debounce } from 'lodash-es';
|
||||||
|
import { onMount, tick } from 'svelte';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -65,6 +70,16 @@
|
|||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
let { isViewing: isViewerOpen, asset: viewingAsset } = assetViewingStore;
|
let { isViewing: isViewerOpen, asset: viewingAsset } = assetViewingStore;
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if ($isViewerOpen) {
|
||||||
|
document.documentElement.style.overflow = 'hidden';
|
||||||
|
}
|
||||||
|
return () => {
|
||||||
|
document.documentElement.style.overflow = '';
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const navigationAssets = $derived(viewerAssets ?? assets);
|
const navigationAssets = $derived(viewerAssets ?? assets);
|
||||||
|
|
||||||
const geometry = $derived(
|
const geometry = $derived(
|
||||||
@@ -107,6 +122,36 @@
|
|||||||
|
|
||||||
const updateSlidingWindow = () => (scrollTop = document.scrollingElement?.scrollTop ?? 0);
|
const updateSlidingWindow = () => (scrollTop = document.scrollingElement?.scrollTop ?? 0);
|
||||||
|
|
||||||
|
const scrollGalleryToAsset = async (assetId: string) => {
|
||||||
|
const index = assets.findIndex((asset) => asset.id === assetId);
|
||||||
|
if (index === -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const assetTopPage = geometry.getTop(index) + slidingWindowOffset;
|
||||||
|
const assetBottomPage = assetTopPage + geometry.getHeight(index);
|
||||||
|
const currentScrollTop = document.scrollingElement?.scrollTop ?? 0;
|
||||||
|
const visibleTop = currentScrollTop + pageHeaderOffset;
|
||||||
|
const visibleBottom = currentScrollTop + viewport.height;
|
||||||
|
|
||||||
|
if (assetTopPage >= visibleTop && assetBottomPage <= visibleBottom) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const distanceToAlignTop = Math.abs(assetTopPage - pageHeaderOffset - currentScrollTop);
|
||||||
|
const distanceToAlignBottom = Math.abs(assetBottomPage - viewport.height - currentScrollTop);
|
||||||
|
const newScrollTop =
|
||||||
|
distanceToAlignTop < distanceToAlignBottom ? assetTopPage - pageHeaderOffset : assetBottomPage - viewport.height;
|
||||||
|
if (document.scrollingElement) {
|
||||||
|
document.scrollingElement.scrollTop = newScrollTop;
|
||||||
|
}
|
||||||
|
updateSlidingWindow();
|
||||||
|
await tick();
|
||||||
|
};
|
||||||
|
|
||||||
|
const scrollToAndFocusAsset = async (assetId: string) => {
|
||||||
|
await scrollGalleryToAsset(assetId);
|
||||||
|
focusAsset(assetId);
|
||||||
|
};
|
||||||
|
|
||||||
const debouncedOnIntersected = debounce(() => onIntersected?.(), 750, { maxWait: 100, leading: true });
|
const debouncedOnIntersected = debounce(() => onIntersected?.(), 750, { maxWait: 100, leading: true });
|
||||||
|
|
||||||
let lastIntersectedHeight = 0;
|
let lastIntersectedHeight = 0;
|
||||||
@@ -356,6 +401,63 @@
|
|||||||
nextAsset: getNextAsset(navigationAssets, $viewingAsset),
|
nextAsset: getNextAsset(navigationAssets, $viewingAsset),
|
||||||
previousAsset: getPreviousAsset(navigationAssets, $viewingAsset),
|
previousAsset: getPreviousAsset(navigationAssets, $viewingAsset),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let toViewerTransitionId = $state<string | null>(null);
|
||||||
|
let toGalleryTransitionId = $state<string | null>(null);
|
||||||
|
const transitionTargetId = $derived(toViewerTransitionId ?? toGalleryTransitionId);
|
||||||
|
|
||||||
|
const handleThumbnailClick = (asset: AssetResponseDto, currentAsset: TimelineAsset) => {
|
||||||
|
if (assetInteraction.selectionActive) {
|
||||||
|
handleSelectAssets(currentAsset);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const doNavigate = () => void navigateToAsset(asset);
|
||||||
|
|
||||||
|
if (!viewTransitionManager.isSupported()) {
|
||||||
|
doNavigate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
startViewerTransition(asset.id, doNavigate, (id) => (toViewerTransitionId = id));
|
||||||
|
};
|
||||||
|
|
||||||
|
const transitionToGalleryCallback = ({ id }: { id: string }) => {
|
||||||
|
void viewTransitionManager.startTransition({
|
||||||
|
types: ['timeline'],
|
||||||
|
prepareOldSnapshot: () => {
|
||||||
|
void scrollGalleryToAsset(id);
|
||||||
|
},
|
||||||
|
performUpdate: async () => {
|
||||||
|
eventManager.emit('ViewerCloseTransitionReady');
|
||||||
|
toGalleryTransitionId = id;
|
||||||
|
await tick();
|
||||||
|
},
|
||||||
|
onFinished: () => {
|
||||||
|
toGalleryTransitionId = null;
|
||||||
|
focusAsset(id);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (viewTransitionManager.isSupported()) {
|
||||||
|
onMount(() => eventManager.on({ ViewerCloseTransition: transitionToGalleryCallback }));
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleClose = async (asset: { id: string }) => {
|
||||||
|
const useTransition = viewTransitionManager.isSupported();
|
||||||
|
if (useTransition) {
|
||||||
|
const transitionReady = eventManager.untilNext('ViewerCloseTransitionReady');
|
||||||
|
eventManager.emit('ViewerCloseTransition', { id: asset.id });
|
||||||
|
await transitionReady;
|
||||||
|
}
|
||||||
|
assetViewingStore.showAssetViewer(false);
|
||||||
|
if (!useTransition) {
|
||||||
|
await tick();
|
||||||
|
await scrollToAndFocusAsset(asset.id);
|
||||||
|
}
|
||||||
|
handlePromiseError(navigate({ targetRoute: 'current', assetId: null }, { noScroll: true }));
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:document
|
<svelte:document
|
||||||
@@ -375,16 +477,17 @@
|
|||||||
{#each assets as asset, i (asset.id + '-' + i)}
|
{#each assets as asset, i (asset.id + '-' + i)}
|
||||||
{#if isIntersecting(i)}
|
{#if isIntersecting(i)}
|
||||||
{@const currentAsset = toTimelineAsset(asset)}
|
{@const currentAsset = toTimelineAsset(asset)}
|
||||||
<div class="absolute" style:overflow="clip" style={getStyle(i)}>
|
{@const transitionName = transitionTargetId === asset.id ? 'hero' : undefined}
|
||||||
|
<div
|
||||||
|
class="absolute"
|
||||||
|
style:overflow="clip"
|
||||||
|
style={getStyle(i)}
|
||||||
|
style:view-transition-name={transitionName}
|
||||||
|
data-transition-name={transitionName}
|
||||||
|
>
|
||||||
<Thumbnail
|
<Thumbnail
|
||||||
readonly={disableAssetSelect}
|
readonly={disableAssetSelect}
|
||||||
onClick={() => {
|
onClick={() => handleThumbnailClick(asset, currentAsset)}
|
||||||
if (assetInteraction.selectionActive) {
|
|
||||||
handleSelectAssets(currentAsset);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
void navigateToAsset(asset);
|
|
||||||
}}
|
|
||||||
onSelect={() => handleSelectAssets(currentAsset)}
|
onSelect={() => handleSelectAssets(currentAsset)}
|
||||||
onMouseEvent={() => assetMouseEventHandler(currentAsset)}
|
onMouseEvent={() => assetMouseEventHandler(currentAsset)}
|
||||||
{showArchiveIcon}
|
{showArchiveIcon}
|
||||||
@@ -416,10 +519,7 @@
|
|||||||
onAction={handleAction}
|
onAction={handleAction}
|
||||||
onRandom={handleRandom}
|
onRandom={handleRandom}
|
||||||
onAssetChange={updateCurrentAsset}
|
onAssetChange={updateCurrentAsset}
|
||||||
onClose={() => {
|
onClose={(asset) => handleClose(asset)}
|
||||||
assetViewingStore.showAssetViewer(false);
|
|
||||||
handlePromiseError(navigate({ targetRoute: 'current', assetId: null }));
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
{/await}
|
{/await}
|
||||||
</Portal>
|
</Portal>
|
||||||
|
|||||||
@@ -50,7 +50,11 @@
|
|||||||
|
|
||||||
<svelte:window bind:innerWidth />
|
<svelte:window bind:innerWidth />
|
||||||
|
|
||||||
<nav id="dashboard-navbar" class="max-md:h-(--navbar-height-md) h-(--navbar-height) w-dvw text-sm">
|
<nav
|
||||||
|
id="dashboard-navbar"
|
||||||
|
class="max-md:h-(--navbar-height-md) h-(--navbar-height) w-dvw text-sm relative z-10"
|
||||||
|
style:view-transition-name="exclude"
|
||||||
|
>
|
||||||
<SkipLink text={$t('skip_to_content')} />
|
<SkipLink text={$t('skip_to_content')} />
|
||||||
<div
|
<div
|
||||||
class="grid h-full grid-cols-[--spacing(32)_auto] items-center py-2 sidebar:grid-cols-[--spacing(64)_auto] {noBorder
|
class="grid h-full grid-cols-[--spacing(32)_auto] items-center py-2 sidebar:grid-cols-[--spacing(64)_auto] {noBorder
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
||||||
|
import { filterIntersecting } from '$lib/managers/timeline-manager/utils.svelte';
|
||||||
import type { ViewerAsset } from '$lib/managers/timeline-manager/viewer-asset.svelte';
|
import type { ViewerAsset } from '$lib/managers/timeline-manager/viewer-asset.svelte';
|
||||||
import type { VirtualScrollManager } from '$lib/managers/VirtualScrollManager/VirtualScrollManager.svelte';
|
|
||||||
import { uploadAssetsStore } from '$lib/stores/upload';
|
import { uploadAssetsStore } from '$lib/stores/upload';
|
||||||
import type { CommonPosition } from '$lib/utils/layout-utils';
|
import type { CommonPosition } from '$lib/utils/layout-utils';
|
||||||
import type { Snippet } from 'svelte';
|
import type { Snippet } from 'svelte';
|
||||||
import { flip } from 'svelte/animate';
|
import { flip } from 'svelte/animate';
|
||||||
import { scale } from 'svelte/transition';
|
import { scale } from 'svelte/transition';
|
||||||
|
|
||||||
let { isUploading } = uploadAssetsStore;
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
animationTargetAssetId?: string | null;
|
||||||
|
suspendTransitions?: boolean;
|
||||||
viewerAssets: ViewerAsset[];
|
viewerAssets: ViewerAsset[];
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
manager: VirtualScrollManager;
|
|
||||||
thumbnail: Snippet<
|
thumbnail: Snippet<
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@@ -26,14 +25,20 @@
|
|||||||
customThumbnailLayout?: Snippet<[asset: TimelineAsset]>;
|
customThumbnailLayout?: Snippet<[asset: TimelineAsset]>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const { viewerAssets, width, height, manager, thumbnail, customThumbnailLayout }: Props = $props();
|
let { isUploading } = uploadAssetsStore;
|
||||||
|
|
||||||
const transitionDuration = $derived(manager.suspendTransitions && !$isUploading ? 0 : 150);
|
const {
|
||||||
|
animationTargetAssetId,
|
||||||
|
suspendTransitions = false,
|
||||||
|
viewerAssets,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
thumbnail,
|
||||||
|
customThumbnailLayout,
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
|
const transitionDuration = $derived(suspendTransitions && !$isUploading ? 0 : 150);
|
||||||
const scaleDuration = $derived(transitionDuration === 0 ? 0 : transitionDuration + 100);
|
const scaleDuration = $derived(transitionDuration === 0 ? 0 : transitionDuration + 100);
|
||||||
|
|
||||||
const filterIntersecting = <T extends { intersecting: boolean }>(intersectables: T[]) => {
|
|
||||||
return intersectables.filter(({ intersecting }) => intersecting);
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Image grid -->
|
<!-- Image grid -->
|
||||||
@@ -41,11 +46,14 @@
|
|||||||
{#each filterIntersecting(viewerAssets) as viewerAsset (viewerAsset.id)}
|
{#each filterIntersecting(viewerAssets) as viewerAsset (viewerAsset.id)}
|
||||||
{@const position = viewerAsset.position!}
|
{@const position = viewerAsset.position!}
|
||||||
{@const asset = viewerAsset.asset!}
|
{@const asset = viewerAsset.asset!}
|
||||||
|
{@const transitionName = animationTargetAssetId === asset.id ? 'hero' : undefined}
|
||||||
|
|
||||||
<!-- note: don't remove data-asset-id - its used by web e2e tests -->
|
<!-- note: don't remove data-asset-id - its used by web e2e tests -->
|
||||||
<div
|
<div
|
||||||
data-asset-id={asset.id}
|
data-asset-id={asset.id}
|
||||||
class="absolute"
|
class="absolute"
|
||||||
|
data-transition-name={transitionName}
|
||||||
|
style:view-transition-name={transitionName}
|
||||||
style:top={position.top + 'px'}
|
style:top={position.top + 'px'}
|
||||||
style:inset-inline-start={position.left + 'px'}
|
style:inset-inline-start={position.left + 'px'}
|
||||||
style:width={position.width + 'px'}
|
style:width={position.width + 'px'}
|
||||||
|
|||||||
@@ -1,34 +1,37 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { focusAsset } from '$lib/components/timeline/actions/focus-actions';
|
||||||
import AssetLayout from '$lib/components/timeline/AssetLayout.svelte';
|
import AssetLayout from '$lib/components/timeline/AssetLayout.svelte';
|
||||||
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||||
import { DayGroup } from '$lib/managers/timeline-manager/day-group.svelte';
|
import { DayGroup } from '$lib/managers/timeline-manager/day-group.svelte';
|
||||||
import type { MonthGroup } from '$lib/managers/timeline-manager/month-group.svelte';
|
import type { MonthGroup } from '$lib/managers/timeline-manager/month-group.svelte';
|
||||||
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
||||||
import { assetsSnapshot } from '$lib/managers/timeline-manager/utils.svelte';
|
import { assetsSnapshot, filterIntersecting } from '$lib/managers/timeline-manager/utils.svelte';
|
||||||
import type { VirtualScrollManager } from '$lib/managers/VirtualScrollManager/VirtualScrollManager.svelte';
|
import { viewTransitionManager } from '$lib/managers/ViewTransitionManager.svelte';
|
||||||
import type { AssetInteraction } from '$lib/stores/asset-interaction.svelte';
|
import type { AssetInteraction } from '$lib/stores/asset-interaction.svelte';
|
||||||
import { uploadAssetsStore } from '$lib/stores/upload';
|
import { uploadAssetsStore } from '$lib/stores/upload';
|
||||||
import type { CommonPosition } from '$lib/utils/layout-utils';
|
import type { CommonPosition } from '$lib/utils/layout-utils';
|
||||||
import { fromTimelinePlainDate, getDateLocaleString } from '$lib/utils/timeline-util';
|
import { fromTimelinePlainDate, getDateLocaleString } from '$lib/utils/timeline-util';
|
||||||
import { Icon } from '@immich/ui';
|
import { Icon } from '@immich/ui';
|
||||||
import { mdiCheckCircle, mdiCircleOutline } from '@mdi/js';
|
import { mdiCheckCircle, mdiCircleOutline } from '@mdi/js';
|
||||||
import type { Snippet } from 'svelte';
|
import { onMount, tick, type Snippet } from 'svelte';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
toAssetViewerTransitionId?: string | null;
|
||||||
thumbnail: Snippet<[{ asset: TimelineAsset; position: CommonPosition; dayGroup: DayGroup; groupIndex: number }]>;
|
thumbnail: Snippet<[{ asset: TimelineAsset; position: CommonPosition; dayGroup: DayGroup; groupIndex: number }]>;
|
||||||
customThumbnailLayout?: Snippet<[TimelineAsset]>;
|
customThumbnailLayout?: Snippet<[TimelineAsset]>;
|
||||||
singleSelect: boolean;
|
singleSelect: boolean;
|
||||||
assetInteraction: AssetInteraction;
|
assetInteraction: AssetInteraction;
|
||||||
monthGroup: MonthGroup;
|
monthGroup: MonthGroup;
|
||||||
manager: VirtualScrollManager;
|
|
||||||
onDayGroupSelect: (dayGroup: DayGroup, assets: TimelineAsset[]) => void;
|
onDayGroupSelect: (dayGroup: DayGroup, assets: TimelineAsset[]) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
toAssetViewerTransitionId,
|
||||||
thumbnail: thumbnailWithGroup,
|
thumbnail: thumbnailWithGroup,
|
||||||
customThumbnailLayout,
|
customThumbnailLayout,
|
||||||
singleSelect,
|
singleSelect,
|
||||||
assetInteraction,
|
assetInteraction,
|
||||||
monthGroup,
|
monthGroup,
|
||||||
manager,
|
|
||||||
onDayGroupSelect,
|
onDayGroupSelect,
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
@@ -37,10 +40,6 @@
|
|||||||
|
|
||||||
const transitionDuration = $derived(monthGroup.timelineManager.suspendTransitions && !$isUploading ? 0 : 150);
|
const transitionDuration = $derived(monthGroup.timelineManager.suspendTransitions && !$isUploading ? 0 : 150);
|
||||||
|
|
||||||
const filterIntersecting = <T extends { intersecting: boolean }>(intersectables: T[]) => {
|
|
||||||
return intersectables.filter(({ intersecting }) => intersecting);
|
|
||||||
};
|
|
||||||
|
|
||||||
const getDayGroupFullDate = (dayGroup: DayGroup): string => {
|
const getDayGroupFullDate = (dayGroup: DayGroup): string => {
|
||||||
const { month, year } = dayGroup.monthGroup.yearMonth;
|
const { month, year } = dayGroup.monthGroup.yearMonth;
|
||||||
const date = fromTimelinePlainDate({
|
const date = fromTimelinePlainDate({
|
||||||
@@ -50,6 +49,32 @@
|
|||||||
});
|
});
|
||||||
return getDateLocaleString(date);
|
return getDateLocaleString(date);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let toTimelineTransitionAssetId = $state<string | null>(null);
|
||||||
|
let animationTargetAssetId = $derived(toTimelineTransitionAssetId ?? toAssetViewerTransitionId ?? null);
|
||||||
|
|
||||||
|
const transitionToTimelineCallback = ({ id }: { id: string }) => {
|
||||||
|
const asset = monthGroup.findAssetById({ id });
|
||||||
|
if (!asset) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void viewTransitionManager.startTransition({
|
||||||
|
types: ['timeline'],
|
||||||
|
performUpdate: async () => {
|
||||||
|
eventManager.emit('ViewerCloseTransitionReady');
|
||||||
|
const event = await eventManager.untilNext('TimelineLoaded');
|
||||||
|
toTimelineTransitionAssetId = event.id;
|
||||||
|
await tick();
|
||||||
|
},
|
||||||
|
onFinished: () => {
|
||||||
|
toTimelineTransitionAssetId = null;
|
||||||
|
focusAsset(asset.id);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
if (viewTransitionManager.isSupported()) {
|
||||||
|
onMount(() => eventManager.on({ ViewerCloseTransition: transitionToTimelineCallback }));
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#each filterIntersecting(monthGroup.dayGroups) as dayGroup, groupIndex (dayGroup.day)}
|
{#each filterIntersecting(monthGroup.dayGroups) as dayGroup, groupIndex (dayGroup.day)}
|
||||||
@@ -93,7 +118,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<AssetLayout
|
<AssetLayout
|
||||||
{manager}
|
{animationTargetAssetId}
|
||||||
|
suspendTransitions={monthGroup.timelineManager.suspendTransitions}
|
||||||
viewerAssets={dayGroup.viewerAssets}
|
viewerAssets={dayGroup.viewerAssets}
|
||||||
height={dayGroup.height}
|
height={dayGroup.height}
|
||||||
width={dayGroup.width}
|
width={dayGroup.width}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
import { fade, fly } from 'svelte/transition';
|
import { fade, fly } from 'svelte/transition';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
invisible: boolean;
|
||||||
/** Offset from the top of the timeline (e.g., for headers) */
|
/** Offset from the top of the timeline (e.g., for headers) */
|
||||||
timelineTopOffset?: number;
|
timelineTopOffset?: number;
|
||||||
/** Offset from the bottom of the timeline (e.g., for footers) */
|
/** Offset from the bottom of the timeline (e.g., for footers) */
|
||||||
@@ -39,6 +40,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
invisible = false,
|
||||||
timelineTopOffset = 0,
|
timelineTopOffset = 0,
|
||||||
timelineBottomOffset = 0,
|
timelineBottomOffset = 0,
|
||||||
height = 0,
|
height = 0,
|
||||||
@@ -438,7 +440,7 @@
|
|||||||
next = forward
|
next = forward
|
||||||
? (focusable[(index + 1) % focusable.length] as HTMLElement)
|
? (focusable[(index + 1) % focusable.length] as HTMLElement)
|
||||||
: (focusable[(index - 1) % focusable.length] as HTMLElement);
|
: (focusable[(index - 1) % focusable.length] as HTMLElement);
|
||||||
next.focus();
|
next?.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -509,6 +511,7 @@
|
|||||||
aria-valuemin={toScrollY(0)}
|
aria-valuemin={toScrollY(0)}
|
||||||
data-id="scrubber"
|
data-id="scrubber"
|
||||||
class="absolute end-0 z-1 select-none hover:cursor-row-resize"
|
class="absolute end-0 z-1 select-none hover:cursor-row-resize"
|
||||||
|
class:invisible
|
||||||
style:padding-top={PADDING_TOP + 'px'}
|
style:padding-top={PADDING_TOP + 'px'}
|
||||||
style:padding-bottom={PADDING_BOTTOM + 'px'}
|
style:padding-bottom={PADDING_BOTTOM + 'px'}
|
||||||
style:width
|
style:width
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
import HotModuleReload from '$lib/elements/HotModuleReload.svelte';
|
import HotModuleReload from '$lib/elements/HotModuleReload.svelte';
|
||||||
import Portal from '$lib/elements/Portal.svelte';
|
import Portal from '$lib/elements/Portal.svelte';
|
||||||
import Skeleton from '$lib/elements/Skeleton.svelte';
|
import Skeleton from '$lib/elements/Skeleton.svelte';
|
||||||
|
import { startViewerTransition } from '$lib/utils/transition-utils';
|
||||||
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||||
import type { DayGroup } from '$lib/managers/timeline-manager/day-group.svelte';
|
import type { DayGroup } from '$lib/managers/timeline-manager/day-group.svelte';
|
||||||
import { isIntersecting } from '$lib/managers/timeline-manager/internal/intersection-support.svelte';
|
import { isIntersecting } from '$lib/managers/timeline-manager/internal/intersection-support.svelte';
|
||||||
import type { MonthGroup } from '$lib/managers/timeline-manager/month-group.svelte';
|
import type { MonthGroup } from '$lib/managers/timeline-manager/month-group.svelte';
|
||||||
@@ -102,6 +104,7 @@
|
|||||||
// Overall scroll percentage through the entire timeline (0-1)
|
// Overall scroll percentage through the entire timeline (0-1)
|
||||||
let timelineScrollPercent: number = $state(0);
|
let timelineScrollPercent: number = $state(0);
|
||||||
let scrubberWidth = $state(0);
|
let scrubberWidth = $state(0);
|
||||||
|
let toAssetViewerTransitionId = $state<string | null>(null);
|
||||||
|
|
||||||
const isEmpty = $derived(timelineManager.isInitialized && timelineManager.months.length === 0);
|
const isEmpty = $derived(timelineManager.isInitialized && timelineManager.months.length === 0);
|
||||||
const maxMd = $derived(mediaQueryManager.maxMd);
|
const maxMd = $derived(mediaQueryManager.maxMd);
|
||||||
@@ -209,7 +212,7 @@
|
|||||||
timelineManager.viewportWidth = rect.width;
|
timelineManager.viewportWidth = rect.width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const scrollTarget = $gridScrollTarget?.at;
|
const scrollTarget = getScrollTarget();
|
||||||
let scrolled = false;
|
let scrolled = false;
|
||||||
if (scrollTarget) {
|
if (scrollTarget) {
|
||||||
scrolled = await scrollAndLoadAsset(scrollTarget);
|
scrolled = await scrollAndLoadAsset(scrollTarget);
|
||||||
@@ -221,7 +224,7 @@
|
|||||||
await tick();
|
await tick();
|
||||||
focusAsset(scrollTarget);
|
focusAsset(scrollTarget);
|
||||||
}
|
}
|
||||||
invisible = false;
|
invisible = isAssetViewerRoute(page) ? true : false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// note: only modified once in afterNavigate()
|
// note: only modified once in afterNavigate()
|
||||||
@@ -239,10 +242,13 @@
|
|||||||
hasNavigatedToOrFromAssetViewer = isNavigatingToAssetViewer !== isNavigatingFromAssetViewer;
|
hasNavigatedToOrFromAssetViewer = isNavigatingToAssetViewer !== isNavigatingFromAssetViewer;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getScrollTarget = () => {
|
||||||
|
return $gridScrollTarget?.at ?? page.params.assetId ?? null;
|
||||||
|
};
|
||||||
// afterNavigate is only called after navigation to a new URL, {complete} will resolve
|
// afterNavigate is only called after navigation to a new URL, {complete} will resolve
|
||||||
// after successful navigation.
|
// after successful navigation.
|
||||||
afterNavigate(({ complete }) => {
|
afterNavigate(({ complete }) => {
|
||||||
void complete.finally(() => {
|
void complete.finally(async () => {
|
||||||
const isAssetViewerPage = isAssetViewerRoute(page);
|
const isAssetViewerPage = isAssetViewerRoute(page);
|
||||||
|
|
||||||
// Set initial load state only once - if initialLoadWasAssetViewer is null, then
|
// Set initial load state only once - if initialLoadWasAssetViewer is null, then
|
||||||
@@ -251,8 +257,13 @@
|
|||||||
if (isDirectNavigation) {
|
if (isDirectNavigation) {
|
||||||
initialLoadWasAssetViewer = isAssetViewerPage && !hasNavigatedToOrFromAssetViewer;
|
initialLoadWasAssetViewer = isAssetViewerPage && !hasNavigatedToOrFromAssetViewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollAfterNavigate();
|
void scrollAfterNavigate();
|
||||||
|
if (!isAssetViewerPage) {
|
||||||
|
const scrollTarget = getScrollTarget();
|
||||||
|
await tick();
|
||||||
|
|
||||||
|
eventManager.emit('TimelineLoaded', { id: scrollTarget });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -260,7 +271,7 @@
|
|||||||
// note: don't throttle, debounch, or otherwise do this function async - it causes flicker
|
// note: don't throttle, debounch, or otherwise do this function async - it causes flicker
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (!enableRouting) {
|
if (!enableRouting && !isAssetViewerRoute(page)) {
|
||||||
invisible = false;
|
invisible = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -524,6 +535,33 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const defaultThumbnailClick = (
|
||||||
|
timelineManager: TimelineManager,
|
||||||
|
assets: TimelineAsset[],
|
||||||
|
groupTitle: string,
|
||||||
|
asset: TimelineAsset,
|
||||||
|
) => {
|
||||||
|
if (isSelectionMode || assetInteraction.selectionActive) {
|
||||||
|
assetSelectHandler(timelineManager, asset, assets, groupTitle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void navigate({ targetRoute: 'current', assetId: asset.id });
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleThumbnailClick = (asset: TimelineAsset, dayGroup: DayGroup) => {
|
||||||
|
if (typeof onThumbnailClick === 'function' || isSelectionMode || assetInteraction.selectionActive) {
|
||||||
|
if (typeof onThumbnailClick === 'function') {
|
||||||
|
onThumbnailClick(asset, timelineManager, dayGroup, defaultThumbnailClick);
|
||||||
|
} else {
|
||||||
|
defaultThumbnailClick(timelineManager, dayGroup.getAssets(), dayGroup.groupTitle, asset);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const openViewer = () => void navigate({ targetRoute: 'current', assetId: asset.id });
|
||||||
|
startViewerTransition(asset.id, openViewer, (id) => (toAssetViewerTransitionId = id));
|
||||||
|
};
|
||||||
|
|
||||||
const assetSelectHandler = (
|
const assetSelectHandler = (
|
||||||
timelineManager: TimelineManager,
|
timelineManager: TimelineManager,
|
||||||
asset: TimelineAsset,
|
asset: TimelineAsset,
|
||||||
@@ -544,19 +582,6 @@
|
|||||||
|
|
||||||
assetInteraction.selectAll = timelineManager.assetCount === assetInteraction.selectedAssets.length;
|
assetInteraction.selectAll = timelineManager.assetCount === assetInteraction.selectedAssets.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
const _onClick = (
|
|
||||||
timelineManager: TimelineManager,
|
|
||||||
assets: TimelineAsset[],
|
|
||||||
groupTitle: string,
|
|
||||||
asset: TimelineAsset,
|
|
||||||
) => {
|
|
||||||
if (isSelectionMode || assetInteraction.selectionActive) {
|
|
||||||
assetSelectHandler(timelineManager, asset, assets, groupTitle);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
void navigate({ targetRoute: 'current', assetId: asset.id });
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:document onkeydown={onKeyDown} onkeyup={onKeyUp} />
|
<svelte:document onkeydown={onKeyDown} onkeyup={onKeyUp} />
|
||||||
@@ -587,6 +612,7 @@
|
|||||||
{#if timelineManager.months.length > 0}
|
{#if timelineManager.months.length > 0}
|
||||||
<Scrubber
|
<Scrubber
|
||||||
{timelineManager}
|
{timelineManager}
|
||||||
|
{invisible}
|
||||||
height={timelineManager.viewportHeight}
|
height={timelineManager.viewportHeight}
|
||||||
timelineTopOffset={timelineManager.topSectionHeight}
|
timelineTopOffset={timelineManager.topSectionHeight}
|
||||||
timelineBottomOffset={timelineManager.bottomSectionHeight}
|
timelineBottomOffset={timelineManager.bottomSectionHeight}
|
||||||
@@ -618,6 +644,7 @@
|
|||||||
id="asset-grid"
|
id="asset-grid"
|
||||||
class={['scrollbar-hidden h-full overflow-y-auto outline-none', { 'm-0': isEmpty }, { 'ms-0': !isEmpty }]}
|
class={['scrollbar-hidden h-full overflow-y-auto outline-none', { 'm-0': isEmpty }, { 'ms-0': !isEmpty }]}
|
||||||
style:margin-inline-end={(usingMobileDevice ? 0 : scrubberWidth) + 'px'}
|
style:margin-inline-end={(usingMobileDevice ? 0 : scrubberWidth) + 'px'}
|
||||||
|
data-initialized={timelineManager.isInitialized || undefined}
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
bind:clientHeight={timelineManager.viewportHeight}
|
bind:clientHeight={timelineManager.viewportHeight}
|
||||||
bind:clientWidth={timelineManager.viewportWidth}
|
bind:clientWidth={timelineManager.viewportWidth}
|
||||||
@@ -666,11 +693,11 @@
|
|||||||
style:width="100%"
|
style:width="100%"
|
||||||
>
|
>
|
||||||
<Month
|
<Month
|
||||||
|
{toAssetViewerTransitionId}
|
||||||
{assetInteraction}
|
{assetInteraction}
|
||||||
{customThumbnailLayout}
|
{customThumbnailLayout}
|
||||||
{singleSelect}
|
{singleSelect}
|
||||||
{monthGroup}
|
{monthGroup}
|
||||||
manager={timelineManager}
|
|
||||||
onDayGroupSelect={handleGroupSelect}
|
onDayGroupSelect={handleGroupSelect}
|
||||||
>
|
>
|
||||||
{#snippet thumbnail({ asset, position, dayGroup, groupIndex })}
|
{#snippet thumbnail({ asset, position, dayGroup, groupIndex })}
|
||||||
@@ -684,13 +711,7 @@
|
|||||||
{asset}
|
{asset}
|
||||||
{albumUsers}
|
{albumUsers}
|
||||||
{groupIndex}
|
{groupIndex}
|
||||||
onClick={(asset) => {
|
onClick={(asset) => handleThumbnailClick(asset, dayGroup)}
|
||||||
if (typeof onThumbnailClick === 'function') {
|
|
||||||
onThumbnailClick(asset, timelineManager, dayGroup, _onClick);
|
|
||||||
} else {
|
|
||||||
_onClick(timelineManager, dayGroup.getAssets(), dayGroup.groupTitle, asset);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
if (isSelectionMode || assetInteraction.selectionActive) {
|
if (isSelectionMode || assetInteraction.selectionActive) {
|
||||||
assetSelectHandler(timelineManager, asset, dayGroup.getAssets(), dayGroup.groupTitle);
|
assetSelectHandler(timelineManager, asset, dayGroup.getAssets(), dayGroup.groupTitle);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
import { AssetAction } from '$lib/constants';
|
import { AssetAction } from '$lib/constants';
|
||||||
import { assetCacheManager } from '$lib/managers/AssetCacheManager.svelte';
|
import { assetCacheManager } from '$lib/managers/AssetCacheManager.svelte';
|
||||||
import { authManager } from '$lib/managers/auth-manager.svelte';
|
import { authManager } from '$lib/managers/auth-manager.svelte';
|
||||||
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||||
|
import { viewTransitionManager } from '$lib/managers/ViewTransitionManager.svelte';
|
||||||
import { TimelineManager } from '$lib/managers/timeline-manager/timeline-manager.svelte';
|
import { TimelineManager } from '$lib/managers/timeline-manager/timeline-manager.svelte';
|
||||||
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
||||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||||
@@ -98,6 +100,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleClose = async (asset: { id: string }) => {
|
const handleClose = async (asset: { id: string }) => {
|
||||||
|
if (viewTransitionManager.isSupported()) {
|
||||||
|
const transitionReady = eventManager.untilNext('ViewerCloseTransitionReady');
|
||||||
|
eventManager.emit('ViewerCloseTransition', { id: asset.id });
|
||||||
|
await transitionReady;
|
||||||
|
}
|
||||||
|
|
||||||
invisible = true;
|
invisible = true;
|
||||||
$gridScrollTarget = { at: asset.id };
|
$gridScrollTarget = { at: asset.id };
|
||||||
await navigate({ targetRoute: 'current', assetId: null, assetGridRouteSearchParams: $gridScrollTarget });
|
await navigate({ targetRoute: 'current', assetId: null, assetGridRouteSearchParams: $gridScrollTarget });
|
||||||
|
|||||||
@@ -0,0 +1,363 @@
|
|||||||
|
import { ViewTransitionManager } from '$lib/managers/ViewTransitionManager.svelte';
|
||||||
|
|
||||||
|
describe('ViewTransitionManager', () => {
|
||||||
|
let manager: ViewTransitionManager;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
manager = new ViewTransitionManager();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
delete (document as Partial<typeof document> & { startViewTransition?: unknown }).startViewTransition;
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when View Transition API is not supported', () => {
|
||||||
|
it('should still call performUpdate', async () => {
|
||||||
|
const performUpdate = vi.fn().mockResolvedValue(undefined);
|
||||||
|
|
||||||
|
await manager.startTransition({ performUpdate });
|
||||||
|
|
||||||
|
expect(performUpdate).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call onFinished after performUpdate', async () => {
|
||||||
|
const callOrder: string[] = [];
|
||||||
|
const performUpdate = vi.fn().mockImplementation(() => {
|
||||||
|
callOrder.push('performUpdate');
|
||||||
|
});
|
||||||
|
const onFinished = vi.fn().mockImplementation(() => {
|
||||||
|
callOrder.push('onFinished');
|
||||||
|
});
|
||||||
|
|
||||||
|
await manager.startTransition({ performUpdate, onFinished });
|
||||||
|
|
||||||
|
expect(onFinished).toHaveBeenCalledOnce();
|
||||||
|
expect(callOrder).toEqual(['performUpdate', 'onFinished']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not call prepareOldSnapshot or prepareNewSnapshot', async () => {
|
||||||
|
const prepareOldSnapshot = vi.fn();
|
||||||
|
const prepareNewSnapshot = vi.fn();
|
||||||
|
const performUpdate = vi.fn().mockResolvedValue(undefined);
|
||||||
|
|
||||||
|
await manager.startTransition({ performUpdate, prepareOldSnapshot, prepareNewSnapshot });
|
||||||
|
|
||||||
|
expect(prepareOldSnapshot).not.toHaveBeenCalled();
|
||||||
|
expect(prepareNewSnapshot).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when a transition is already active', () => {
|
||||||
|
it('should skip the second transition', async () => {
|
||||||
|
let resolveFinished!: () => void;
|
||||||
|
const finished = new Promise<void>((resolve) => {
|
||||||
|
resolveFinished = resolve;
|
||||||
|
});
|
||||||
|
let resolveUpdate!: () => void;
|
||||||
|
const updateCallbackDone = new Promise<void>((resolve) => {
|
||||||
|
resolveUpdate = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
document.startViewTransition = vi.fn().mockImplementation((arg: unknown) => {
|
||||||
|
const updateFn = typeof arg === 'function' ? arg : (arg as { update: () => Promise<void> }).update;
|
||||||
|
void updateFn();
|
||||||
|
return { updateCallbackDone, finished, ready: Promise.resolve(), skipTransition: vi.fn() };
|
||||||
|
});
|
||||||
|
|
||||||
|
const secondPerformUpdate = vi.fn().mockResolvedValue(undefined);
|
||||||
|
|
||||||
|
// Start first — it will be blocked on updateCallbackDone
|
||||||
|
const firstPromise = manager.startTransition({
|
||||||
|
performUpdate: async () => {},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Flush microtasks so the first transition reaches the startViewTransition call
|
||||||
|
await new Promise<void>((r) => queueMicrotask(r));
|
||||||
|
|
||||||
|
// While first is active, try a second — should be skipped
|
||||||
|
await manager.startTransition({ performUpdate: secondPerformUpdate });
|
||||||
|
expect(secondPerformUpdate).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
// Clean up
|
||||||
|
resolveUpdate();
|
||||||
|
resolveFinished();
|
||||||
|
await firstPromise;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('skipTransitions', () => {
|
||||||
|
it('should return false when no transition is active', () => {
|
||||||
|
expect(manager.skipTransitions()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call skipTransition on the active transition and return true', async () => {
|
||||||
|
let resolveFinished!: () => void;
|
||||||
|
const finished = new Promise<void>((resolve) => {
|
||||||
|
resolveFinished = resolve;
|
||||||
|
});
|
||||||
|
let resolveUpdate!: () => void;
|
||||||
|
const updateCallbackDone = new Promise<void>((resolve) => {
|
||||||
|
resolveUpdate = resolve;
|
||||||
|
});
|
||||||
|
const skipTransition = vi.fn();
|
||||||
|
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
document.startViewTransition = vi.fn().mockImplementation((arg: unknown) => {
|
||||||
|
const updateFn = typeof arg === 'function' ? arg : (arg as { update: () => Promise<void> }).update;
|
||||||
|
void updateFn();
|
||||||
|
return { updateCallbackDone, finished, ready: Promise.resolve(), skipTransition };
|
||||||
|
});
|
||||||
|
|
||||||
|
const promise = manager.startTransition({ performUpdate: async () => {} });
|
||||||
|
await new Promise<void>((r) => queueMicrotask(r));
|
||||||
|
|
||||||
|
const skipped = manager.skipTransitions();
|
||||||
|
expect(skipped).toBe(true);
|
||||||
|
expect(skipTransition).toHaveBeenCalledOnce();
|
||||||
|
|
||||||
|
resolveUpdate();
|
||||||
|
resolveFinished();
|
||||||
|
await promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should allow a new transition after skipping', async () => {
|
||||||
|
let resolveFinished!: () => void;
|
||||||
|
const finished = new Promise<void>((resolve) => {
|
||||||
|
resolveFinished = resolve;
|
||||||
|
});
|
||||||
|
let resolveUpdate!: () => void;
|
||||||
|
const updateCallbackDone = new Promise<void>((resolve) => {
|
||||||
|
resolveUpdate = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
document.startViewTransition = vi.fn().mockImplementation((arg: unknown) => {
|
||||||
|
const updateFn = typeof arg === 'function' ? arg : (arg as { update: () => Promise<void> }).update;
|
||||||
|
void updateFn();
|
||||||
|
return { updateCallbackDone, finished, ready: Promise.resolve(), skipTransition: vi.fn() };
|
||||||
|
});
|
||||||
|
|
||||||
|
const promise = manager.startTransition({ performUpdate: async () => {} });
|
||||||
|
await new Promise<void>((r) => queueMicrotask(r));
|
||||||
|
|
||||||
|
manager.skipTransitions();
|
||||||
|
resolveUpdate();
|
||||||
|
resolveFinished();
|
||||||
|
await promise;
|
||||||
|
|
||||||
|
// Now start a second transition — it should NOT be skipped
|
||||||
|
const secondUpdate = vi.fn().mockResolvedValue(undefined);
|
||||||
|
const secondFinished = Promise.resolve();
|
||||||
|
const secondUpdateDone = Promise.resolve();
|
||||||
|
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
document.startViewTransition = vi.fn().mockImplementation((arg: unknown) => {
|
||||||
|
const updateFn = typeof arg === 'function' ? arg : (arg as { update: () => Promise<void> }).update;
|
||||||
|
void updateFn();
|
||||||
|
return {
|
||||||
|
updateCallbackDone: secondUpdateDone,
|
||||||
|
finished: secondFinished,
|
||||||
|
ready: Promise.resolve(),
|
||||||
|
skipTransition: vi.fn(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
await manager.startTransition({ performUpdate: secondUpdate });
|
||||||
|
expect(secondUpdate).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('error handling', () => {
|
||||||
|
it('should propagate error from performUpdate when API is not supported', async () => {
|
||||||
|
const error = new Error('update failed');
|
||||||
|
const performUpdate = vi.fn().mockRejectedValue(error);
|
||||||
|
|
||||||
|
await expect(manager.startTransition({ performUpdate })).rejects.toThrow('update failed');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should clean up activeViewTransition when performUpdate throws (API supported)', async () => {
|
||||||
|
const error = new Error('update failed');
|
||||||
|
let resolveFinished!: () => void;
|
||||||
|
const finished = new Promise<void>((resolve) => {
|
||||||
|
resolveFinished = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
document.startViewTransition = vi.fn().mockImplementation((arg: unknown) => {
|
||||||
|
const updateFn = typeof arg === 'function' ? arg : (arg as { update: () => Promise<void> }).update;
|
||||||
|
const updateCallbackDone = updateFn();
|
||||||
|
return { updateCallbackDone, finished, ready: Promise.resolve(), skipTransition: vi.fn() };
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(manager.startTransition({ performUpdate: () => Promise.reject(error) })).rejects.toThrow(
|
||||||
|
'update failed',
|
||||||
|
);
|
||||||
|
|
||||||
|
// Simulate transition finishing after error
|
||||||
|
resolveFinished();
|
||||||
|
await new Promise<void>((r) => queueMicrotask(r));
|
||||||
|
|
||||||
|
// Manager should accept new transitions after cleanup
|
||||||
|
const secondUpdate = vi.fn().mockResolvedValue(undefined);
|
||||||
|
const secondFinished = Promise.resolve();
|
||||||
|
const secondUpdateDone = Promise.resolve();
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
document.startViewTransition = vi.fn().mockImplementation((arg: unknown) => {
|
||||||
|
const updateFn = typeof arg === 'function' ? arg : (arg as { update: () => Promise<void> }).update;
|
||||||
|
void updateFn();
|
||||||
|
return {
|
||||||
|
updateCallbackDone: secondUpdateDone,
|
||||||
|
finished: secondFinished,
|
||||||
|
ready: Promise.resolve(),
|
||||||
|
skipTransition: vi.fn(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
await manager.startTransition({ performUpdate: secondUpdate });
|
||||||
|
expect(secondUpdate).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('fallback path', () => {
|
||||||
|
it('should fall back to function argument when object argument throws', async () => {
|
||||||
|
const performUpdate = vi.fn().mockResolvedValue(undefined);
|
||||||
|
const prepareNewSnapshot = vi.fn();
|
||||||
|
const finished = Promise.resolve();
|
||||||
|
const updateCallbackDone = Promise.resolve();
|
||||||
|
|
||||||
|
let callCount = 0;
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
document.startViewTransition = vi.fn().mockImplementation((arg: unknown) => {
|
||||||
|
callCount++;
|
||||||
|
if (callCount === 1 && typeof arg !== 'function') {
|
||||||
|
throw new TypeError('object form not supported');
|
||||||
|
}
|
||||||
|
const updateFn = typeof arg === 'function' ? arg : (arg as { update: () => Promise<void> }).update;
|
||||||
|
void updateFn();
|
||||||
|
return { updateCallbackDone, finished, ready: Promise.resolve(), skipTransition: vi.fn() };
|
||||||
|
});
|
||||||
|
|
||||||
|
await manager.startTransition({ performUpdate, prepareNewSnapshot, types: ['test'] });
|
||||||
|
|
||||||
|
expect(performUpdate).toHaveBeenCalledOnce();
|
||||||
|
expect(prepareNewSnapshot).toHaveBeenCalledOnce();
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
expect(document.startViewTransition).toHaveBeenCalledTimes(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('abort signal', () => {
|
||||||
|
it('should pass an AbortSignal to performUpdate', async () => {
|
||||||
|
const performUpdate = vi.fn().mockResolvedValue(undefined);
|
||||||
|
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
document.startViewTransition = vi.fn().mockImplementation((arg: unknown) => {
|
||||||
|
const updateFn = typeof arg === 'function' ? arg : (arg as { update: () => Promise<void> }).update;
|
||||||
|
void updateFn();
|
||||||
|
return {
|
||||||
|
updateCallbackDone: Promise.resolve(),
|
||||||
|
finished: Promise.resolve(),
|
||||||
|
ready: Promise.resolve(),
|
||||||
|
skipTransition: vi.fn(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
await manager.startTransition({ performUpdate });
|
||||||
|
|
||||||
|
expect(performUpdate).toHaveBeenCalledWith(expect.any(AbortSignal));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should abort the signal when transition.ready rejects', async () => {
|
||||||
|
let capturedSignal: AbortSignal | undefined;
|
||||||
|
let resolveUpdate!: () => void;
|
||||||
|
const updateCallbackDone = new Promise<void>((resolve) => {
|
||||||
|
resolveUpdate = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
|
const readyError = new Error('Transition was aborted because of timeout in DOM update');
|
||||||
|
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
document.startViewTransition = vi.fn().mockImplementation((arg: unknown) => {
|
||||||
|
const updateFn = typeof arg === 'function' ? arg : (arg as { update: () => Promise<void> }).update;
|
||||||
|
void updateFn();
|
||||||
|
return {
|
||||||
|
updateCallbackDone,
|
||||||
|
finished: Promise.reject(readyError),
|
||||||
|
ready: Promise.reject(readyError),
|
||||||
|
skipTransition: vi.fn(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const performUpdate = vi.fn().mockImplementation((signal: AbortSignal) => {
|
||||||
|
capturedSignal = signal;
|
||||||
|
return new Promise<void>((resolve) => {
|
||||||
|
signal.addEventListener('abort', () => resolve(), { once: true });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const promise = manager.startTransition({ performUpdate });
|
||||||
|
|
||||||
|
// Flush microtasks so ready rejection fires and aborts the signal
|
||||||
|
await new Promise<void>((r) => queueMicrotask(r));
|
||||||
|
await new Promise<void>((r) => queueMicrotask(r));
|
||||||
|
|
||||||
|
expect(capturedSignal?.aborted).toBe(true);
|
||||||
|
|
||||||
|
resolveUpdate();
|
||||||
|
await promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not abort the signal when transition completes normally', async () => {
|
||||||
|
let capturedSignal: AbortSignal | undefined;
|
||||||
|
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
document.startViewTransition = vi.fn().mockImplementation((arg: unknown) => {
|
||||||
|
const updateFn = typeof arg === 'function' ? arg : (arg as { update: () => Promise<void> }).update;
|
||||||
|
void updateFn();
|
||||||
|
return {
|
||||||
|
updateCallbackDone: Promise.resolve(),
|
||||||
|
finished: Promise.resolve(),
|
||||||
|
ready: Promise.resolve(),
|
||||||
|
skipTransition: vi.fn(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
await manager.startTransition({
|
||||||
|
performUpdate: (signal) => {
|
||||||
|
capturedSignal = signal;
|
||||||
|
return Promise.resolve();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(capturedSignal?.aborted).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass a non-aborted signal in the unsupported fallback path', async () => {
|
||||||
|
let capturedSignal: AbortSignal | undefined;
|
||||||
|
|
||||||
|
await manager.startTransition({
|
||||||
|
performUpdate: (signal) => {
|
||||||
|
capturedSignal = signal;
|
||||||
|
return Promise.resolve();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(capturedSignal).toBeInstanceOf(AbortSignal);
|
||||||
|
expect(capturedSignal?.aborted).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('isSupported', () => {
|
||||||
|
it('should return false when startViewTransition is not in document', () => {
|
||||||
|
expect(manager.isSupported()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true when startViewTransition is in document', () => {
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
document.startViewTransition = vi.fn();
|
||||||
|
|
||||||
|
expect(manager.isSupported()).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
import { tick } from 'svelte';
|
||||||
|
|
||||||
|
interface TransitionRequest {
|
||||||
|
types?: string[];
|
||||||
|
prepareOldSnapshot?: () => void;
|
||||||
|
performUpdate: (signal: AbortSignal) => Promise<void>;
|
||||||
|
prepareNewSnapshot?: () => void;
|
||||||
|
onFinished?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ViewTransitionManager {
|
||||||
|
#activeViewTransition = $state<ViewTransition | null>(null);
|
||||||
|
|
||||||
|
get activeViewTransition() {
|
||||||
|
return this.#activeViewTransition;
|
||||||
|
}
|
||||||
|
|
||||||
|
isSupported() {
|
||||||
|
return 'startViewTransition' in document;
|
||||||
|
}
|
||||||
|
|
||||||
|
skipTransitions() {
|
||||||
|
const skipped = !!this.#activeViewTransition;
|
||||||
|
this.#activeViewTransition?.skipTransition();
|
||||||
|
this.#activeViewTransition = null;
|
||||||
|
return skipped;
|
||||||
|
}
|
||||||
|
|
||||||
|
async startTransition({
|
||||||
|
types,
|
||||||
|
prepareOldSnapshot,
|
||||||
|
performUpdate,
|
||||||
|
prepareNewSnapshot,
|
||||||
|
onFinished,
|
||||||
|
}: TransitionRequest) {
|
||||||
|
if (this.#activeViewTransition) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.isSupported()) {
|
||||||
|
await performUpdate(AbortSignal.timeout(10_000));
|
||||||
|
onFinished?.();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
prepareOldSnapshot?.();
|
||||||
|
await tick();
|
||||||
|
|
||||||
|
const abortController = new AbortController();
|
||||||
|
let transition: ViewTransition;
|
||||||
|
try {
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
transition = document.startViewTransition({
|
||||||
|
update: async () => {
|
||||||
|
await performUpdate(abortController.signal);
|
||||||
|
prepareNewSnapshot?.();
|
||||||
|
await tick();
|
||||||
|
},
|
||||||
|
types,
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
transition = document.startViewTransition(async () => {
|
||||||
|
await performUpdate(abortController.signal);
|
||||||
|
prepareNewSnapshot?.();
|
||||||
|
await tick();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.#activeViewTransition = transition;
|
||||||
|
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
void transition.ready.catch((error: unknown) => {
|
||||||
|
abortController.abort(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Let animation run in the background — don't block the caller.
|
||||||
|
// This allows skipTransitions() to abort mid-animation for rapid navigation.
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
void transition.finished
|
||||||
|
.catch(() => {})
|
||||||
|
.finally(() => {
|
||||||
|
this.#activeViewTransition = null;
|
||||||
|
onFinished?.();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Wait only until the DOM update completes (both snapshots captured),
|
||||||
|
// not for the animation to finish.
|
||||||
|
// eslint-disable-next-line tscompat/tscompat
|
||||||
|
await transition.updateCallbackDone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const viewTransitionManager = new ViewTransitionManager();
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AppManager {
|
||||||
|
isAssetViewer = $state(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const appManager = new AppManager();
|
||||||
@@ -89,6 +89,15 @@ export type Events = {
|
|||||||
ReleaseEvent: [ReleaseEvent];
|
ReleaseEvent: [ReleaseEvent];
|
||||||
|
|
||||||
WebsocketConnect: [];
|
WebsocketConnect: [];
|
||||||
|
|
||||||
|
TimelineLoaded: [{ id: string | null }];
|
||||||
|
TimelineScrolledToAsset: [{ id: string }];
|
||||||
|
|
||||||
|
ViewerAfterNavigate: [];
|
||||||
|
ViewerCloseTransition: [{ id: string }];
|
||||||
|
ViewerCloseTransitionReady: [];
|
||||||
|
ViewerOpenTransition: [];
|
||||||
|
ViewerOpenTransitionReady: [];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const eventManager = new BaseEventManager<Events>();
|
export const eventManager = new BaseEventManager<Events>();
|
||||||
|
|||||||
@@ -2,3 +2,11 @@ import type { TimelineAsset } from './types';
|
|||||||
|
|
||||||
export const assetSnapshot = (asset: TimelineAsset): TimelineAsset => $state.snapshot(asset);
|
export const assetSnapshot = (asset: TimelineAsset): TimelineAsset => $state.snapshot(asset);
|
||||||
export const assetsSnapshot = (assets: TimelineAsset[]) => assets.map((asset) => $state.snapshot(asset));
|
export const assetsSnapshot = (assets: TimelineAsset[]) => assets.map((asset) => $state.snapshot(asset));
|
||||||
|
|
||||||
|
export function* filterIntersecting<T extends { intersecting: boolean }>(items: T[]) {
|
||||||
|
for (const item of items) {
|
||||||
|
if (item.intersecting) {
|
||||||
|
yield item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { readonly, writable } from 'svelte/store';
|
|||||||
|
|
||||||
function createAssetViewingStore() {
|
function createAssetViewingStore() {
|
||||||
const viewingAssetStoreState = writable<AssetResponseDto>();
|
const viewingAssetStoreState = writable<AssetResponseDto>();
|
||||||
|
const invisible = writable<boolean>(false);
|
||||||
const viewState = writable<boolean>(false);
|
const viewState = writable<boolean>(false);
|
||||||
const gridScrollTarget = writable<AssetGridRouteSearchParams | null | undefined>();
|
const gridScrollTarget = writable<AssetGridRouteSearchParams | null | undefined>();
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ function createAssetViewingStore() {
|
|||||||
setAsset,
|
setAsset,
|
||||||
setAssetId,
|
setAssetId,
|
||||||
showAssetViewer,
|
showAssetViewer,
|
||||||
|
invisible,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,50 @@ export class BaseEventManager<Events extends EventsBase> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
once<T extends keyof Events>(event: T, callback: EventCallback<Events, T>) {
|
||||||
|
const unsubscribe = this.#onEvent(event, (...args: Events[T]) => {
|
||||||
|
unsubscribe();
|
||||||
|
return callback(...args);
|
||||||
|
});
|
||||||
|
return unsubscribe;
|
||||||
|
}
|
||||||
|
|
||||||
|
untilNext<T extends keyof Events>(
|
||||||
|
event: T,
|
||||||
|
{ timeoutMs = 10_000, signal }: { timeoutMs?: number; signal?: AbortSignal } = {},
|
||||||
|
): Promise<Events[T] extends [] ? void : Events[T][0]> {
|
||||||
|
type Result = Events[T] extends [] ? void : Events[T][0];
|
||||||
|
return new Promise<Result>((resolve, reject) => {
|
||||||
|
let settled = false;
|
||||||
|
const settle = () => {
|
||||||
|
if (settled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
settled = true;
|
||||||
|
unsubscribe();
|
||||||
|
clearTimeout(timer);
|
||||||
|
signal?.removeEventListener('abort', onAbort);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
const unsubscribe = this.once(event, (...args: Events[T]) => {
|
||||||
|
if (settle()) {
|
||||||
|
resolve(args[0] as Result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
if (settle()) {
|
||||||
|
reject(new Error(`untilNext('${String(event)}') timed out after ${timeoutMs}ms`));
|
||||||
|
}
|
||||||
|
}, timeoutMs);
|
||||||
|
const onAbort = () => {
|
||||||
|
if (settle()) {
|
||||||
|
resolve(undefined as Result);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
signal?.addEventListener('abort', onAbort, { once: true });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
emit<T extends keyof Events>(event: T, ...params: Events[T]) {
|
emit<T extends keyof Events>(event: T, ...params: Events[T]) {
|
||||||
const listeners = this.getListeners(event);
|
const listeners = this.getListeners(event);
|
||||||
for (const listener of listeners) {
|
for (const listener of listeners) {
|
||||||
|
|||||||
@@ -1,66 +1,36 @@
|
|||||||
import { handleError } from '$lib/utils/handle-error';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tracks the state of asynchronous invocations to handle race conditions and stale operations.
|
|
||||||
* This class helps manage concurrent operations by tracking which invocations are active
|
|
||||||
* and allowing operations to check if they're still valid.
|
|
||||||
*/
|
|
||||||
export class InvocationTracker {
|
export class InvocationTracker {
|
||||||
/** Counter for the number of invocations that have been started */
|
|
||||||
invocationsStarted = 0;
|
invocationsStarted = 0;
|
||||||
/** Counter for the number of invocations that have been completed */
|
|
||||||
invocationsEnded = 0;
|
invocationsEnded = 0;
|
||||||
|
|
||||||
constructor() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts a new invocation and returns an object with utilities to manage the invocation lifecycle.
|
|
||||||
* @returns An object containing methods to manage the invocation:
|
|
||||||
* - isInvalidInvocationError: Checks if an error is an invalid invocation error
|
|
||||||
* - checkStillValid: Throws an error if the invocation is no longer valid
|
|
||||||
* - endInvocation: Marks the invocation as complete
|
|
||||||
*/
|
|
||||||
startInvocation() {
|
startInvocation() {
|
||||||
this.invocationsStarted++;
|
this.invocationsStarted++;
|
||||||
const invocation = this.invocationsStarted;
|
const invocation = this.invocationsStarted;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
isStillValid: () => invocation === this.invocationsStarted,
|
||||||
* Throws an error if this invocation is no longer valid
|
|
||||||
* @throws {Error} If the invocation is no longer valid
|
|
||||||
*/
|
|
||||||
isStillValid: () => {
|
|
||||||
if (invocation !== this.invocationsStarted) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Marks this invocation as complete
|
|
||||||
*/
|
|
||||||
endInvocation: () => {
|
endInvocation: () => {
|
||||||
this.invocationsEnded = invocation;
|
this.invocationsEnded = Math.max(this.invocationsEnded, invocation);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if there are any active invocations
|
|
||||||
* @returns True if there are active invocations, false otherwise
|
|
||||||
*/
|
|
||||||
isActive() {
|
isActive() {
|
||||||
return this.invocationsStarted !== this.invocationsEnded;
|
return this.invocationsStarted !== this.invocationsEnded;
|
||||||
}
|
}
|
||||||
|
|
||||||
async invoke<T>(invocable: () => Promise<T>, localizedMessage: string) {
|
async invoke<T>(invocable: () => Promise<T>, catchCallback?: (error: unknown) => void, finallyCallback?: () => void) {
|
||||||
const invocation = this.startInvocation();
|
const invocation = this.startInvocation();
|
||||||
try {
|
try {
|
||||||
return await invocable();
|
return await invocable();
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
handleError(error, localizedMessage);
|
if (catchCallback) {
|
||||||
|
catchCallback(error);
|
||||||
|
} else {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
invocation.endInvocation();
|
invocation.endInvocation();
|
||||||
|
finallyCallback?.();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||||
|
import { viewTransitionManager } from '$lib/managers/ViewTransitionManager.svelte';
|
||||||
|
import { tick } from 'svelte';
|
||||||
|
|
||||||
|
export function startViewerTransition(
|
||||||
|
assetId: string,
|
||||||
|
navigate: () => void,
|
||||||
|
setTransitionId: (id: string | null) => void,
|
||||||
|
) {
|
||||||
|
void viewTransitionManager.startTransition({
|
||||||
|
types: ['viewer'],
|
||||||
|
prepareOldSnapshot: () => {
|
||||||
|
setTransitionId(assetId);
|
||||||
|
},
|
||||||
|
performUpdate: async (signal) => {
|
||||||
|
setTransitionId(null);
|
||||||
|
const ready = eventManager.untilNext('ViewerOpenTransitionReady', { signal });
|
||||||
|
navigate();
|
||||||
|
await ready;
|
||||||
|
eventManager.emit('ViewerOpenTransition');
|
||||||
|
await tick();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let activeOverlay: HTMLElement | undefined;
|
||||||
|
|
||||||
|
export function removeCrossfadeOverlay() {
|
||||||
|
if (activeOverlay) {
|
||||||
|
activeOverlay.remove();
|
||||||
|
activeOverlay = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function crossfadeViewerContent(updateFn: () => void | Promise<void>, duration = 200) {
|
||||||
|
const viewerContent = document.querySelector<HTMLElement>('[data-viewer-content]');
|
||||||
|
if (!viewerContent) {
|
||||||
|
await updateFn();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeCrossfadeOverlay();
|
||||||
|
|
||||||
|
const clone = viewerContent.cloneNode(true) as HTMLElement;
|
||||||
|
Object.assign(clone.style, {
|
||||||
|
position: 'absolute',
|
||||||
|
inset: '0',
|
||||||
|
zIndex: '1',
|
||||||
|
pointerEvents: 'none',
|
||||||
|
});
|
||||||
|
delete clone.dataset.viewerContent;
|
||||||
|
if (!viewerContent.parentElement) {
|
||||||
|
await updateFn();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
viewerContent.parentElement.append(clone);
|
||||||
|
activeOverlay = clone;
|
||||||
|
|
||||||
|
const ready = eventManager.untilNext('ViewerOpenTransitionReady');
|
||||||
|
await updateFn();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await ready;
|
||||||
|
} catch {
|
||||||
|
clone.remove();
|
||||||
|
if (activeOverlay === clone) {
|
||||||
|
activeOverlay = undefined;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fadeOut = clone.animate([{ opacity: 1 }, { opacity: 0 }], {
|
||||||
|
duration,
|
||||||
|
easing: 'cubic-bezier(0.4, 0, 1, 1)',
|
||||||
|
fill: 'forwards',
|
||||||
|
});
|
||||||
|
|
||||||
|
void fadeOut.finished.then(() => {
|
||||||
|
clone.remove();
|
||||||
|
if (activeOverlay === clone) {
|
||||||
|
activeOverlay = undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class:display-none={$showAssetViewer}>
|
<div class:invisible={$showAssetViewer}>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
<UploadCover />
|
<UploadCover />
|
||||||
@@ -33,7 +33,4 @@
|
|||||||
:root {
|
:root {
|
||||||
overscroll-behavior: none;
|
overscroll-behavior: none;
|
||||||
}
|
}
|
||||||
.display-none {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -6,13 +6,16 @@
|
|||||||
import { timeToLoadTheMap } from '$lib/constants';
|
import { timeToLoadTheMap } from '$lib/constants';
|
||||||
import Portal from '$lib/elements/Portal.svelte';
|
import Portal from '$lib/elements/Portal.svelte';
|
||||||
import { featureFlagsManager } from '$lib/managers/feature-flags-manager.svelte';
|
import { featureFlagsManager } from '$lib/managers/feature-flags-manager.svelte';
|
||||||
|
import { viewTransitionManager } from '$lib/managers/ViewTransitionManager.svelte';
|
||||||
import { Route } from '$lib/route';
|
import { Route } from '$lib/route';
|
||||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||||
import { handlePromiseError } from '$lib/utils';
|
import { handlePromiseError } from '$lib/utils';
|
||||||
import { delay } from '$lib/utils/asset-utils';
|
import { delay } from '$lib/utils/asset-utils';
|
||||||
import { navigate } from '$lib/utils/navigation';
|
import { navigate } from '$lib/utils/navigation';
|
||||||
import { LoadingSpinner } from '@immich/ui';
|
import { LoadingSpinner } from '@immich/ui';
|
||||||
|
import { linear } from 'svelte/easing';
|
||||||
import { onDestroy } from 'svelte';
|
import { onDestroy } from 'svelte';
|
||||||
|
import { fly } from 'svelte/transition';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -41,9 +44,14 @@
|
|||||||
handlePromiseError(goto(Route.photos()));
|
handlePromiseError(goto(Route.photos()));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onViewAssets(assetIds: string[]) {
|
function onViewAssets(assetIds: string[]) {
|
||||||
await setAssetId(assetIds[0]);
|
void viewTransitionManager.startTransition({
|
||||||
closeTimelinePanel();
|
types: ['viewer'],
|
||||||
|
performUpdate: async () => {
|
||||||
|
await setAssetId(assetIds[0]);
|
||||||
|
closeTimelinePanel();
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClusterSelect(assetIds: string[], bbox: SelectionBBox) {
|
function onClusterSelect(assetIds: string[], bbox: SelectionBBox) {
|
||||||
@@ -77,7 +85,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if isTimelinePanelVisible && selectedClusterBBox}
|
{#if isTimelinePanelVisible && selectedClusterBBox}
|
||||||
<div class="h-1/2 min-h-0 w-full pt-2 sm:h-full sm:w-1/3 sm:ps-2 sm:pt-0">
|
<div
|
||||||
|
transition:fly={{ x: 400, duration: 150, easing: linear }}
|
||||||
|
class="h-1/2 min-h-0 w-full pt-2 sm:h-full sm:w-1/3 sm:ps-2 sm:pt-0"
|
||||||
|
>
|
||||||
<MapTimelinePanel
|
<MapTimelinePanel
|
||||||
bbox={selectedClusterBBox}
|
bbox={selectedClusterBBox}
|
||||||
{selectedClusterIds}
|
{selectedClusterIds}
|
||||||
@@ -89,7 +100,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</UserPageLayout>
|
</UserPageLayout>
|
||||||
<Portal target="body">
|
<Portal target="body">
|
||||||
{#if $showAssetViewer}
|
{#if $showAssetViewer && !isTimelinePanelVisible}
|
||||||
{#await import('$lib/components/asset-viewer/asset-viewer.svelte') then { default: AssetViewer }}
|
{#await import('$lib/components/asset-viewer/asset-viewer.svelte') then { default: AssetViewer }}
|
||||||
<AssetViewer
|
<AssetViewer
|
||||||
cursor={{ current: $viewingAsset }}
|
cursor={{ current: $viewingAsset }}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { afterNavigate, beforeNavigate, goto } from '$app/navigation';
|
import { afterNavigate, beforeNavigate, goto, onNavigate } from '$app/navigation';
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import { shortcut } from '$lib/actions/shortcut';
|
import { shortcut } from '$lib/actions/shortcut';
|
||||||
import DownloadPanel from '$lib/components/asset-viewer/download-panel.svelte';
|
import DownloadPanel from '$lib/components/asset-viewer/download-panel.svelte';
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
import NavigationLoadingBar from '$lib/components/shared-components/navigation-loading-bar.svelte';
|
import NavigationLoadingBar from '$lib/components/shared-components/navigation-loading-bar.svelte';
|
||||||
import UploadPanel from '$lib/components/shared-components/upload-panel.svelte';
|
import UploadPanel from '$lib/components/shared-components/upload-panel.svelte';
|
||||||
import VersionAnnouncement from '$lib/components/VersionAnnouncement.svelte';
|
import VersionAnnouncement from '$lib/components/VersionAnnouncement.svelte';
|
||||||
|
import { appManager } from '$lib/managers/app-manager.svelte';
|
||||||
import { eventManager } from '$lib/managers/event-manager.svelte';
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||||
import { serverConfigManager } from '$lib/managers/server-config-manager.svelte';
|
import { serverConfigManager } from '$lib/managers/server-config-manager.svelte';
|
||||||
import { themeManager } from '$lib/managers/theme-manager.svelte';
|
import { themeManager } from '$lib/managers/theme-manager.svelte';
|
||||||
@@ -77,6 +78,8 @@
|
|||||||
|
|
||||||
let showNavigationLoadingBar = $state(false);
|
let showNavigationLoadingBar = $state(false);
|
||||||
|
|
||||||
|
appManager.isAssetViewer = isAssetViewerRoute(page);
|
||||||
|
|
||||||
const getMyImmichLink = () => {
|
const getMyImmichLink = () => {
|
||||||
return new URL(page.url.pathname + page.url.search, 'https://my.immich.app');
|
return new URL(page.url.pathname + page.url.search, 'https://my.immich.app');
|
||||||
};
|
};
|
||||||
@@ -102,8 +105,15 @@
|
|||||||
showNavigationLoadingBar = true;
|
showNavigationLoadingBar = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterNavigate(() => {
|
onNavigate(({ to }) => {
|
||||||
showNavigationLoadingBar = false;
|
appManager.isAssetViewer = isAssetViewerRoute(to);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterNavigate(({ to, complete }) => {
|
||||||
|
appManager.isAssetViewer = isAssetViewerRoute(to);
|
||||||
|
void complete.finally(() => {
|
||||||
|
showNavigationLoadingBar = false;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const { serverRestarting } = websocketStore;
|
const { serverRestarting } = websocketStore;
|
||||||
|
|||||||
Reference in New Issue
Block a user