Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Preserve Space viewer thumbnails and Latest card corners

Anand Baburajan17e267ea5754
diff --git a/web/apps/space/src/components/FileViewer.tsx b/web/apps/space/src/components/FileViewer.tsx
index cb5e43c69e..6b01f1b66f 100644
--- a/web/apps/space/src/components/FileViewer.tsx
+++ b/web/apps/space/src/components/FileViewer.tsx
@@ -32,6 +32,7 @@ import {
findViewerOrigin,
playViewerClose,
playViewerOpen,
+ viewerCornerRadii,
viewerOriginKey,
} from "components/viewer-transition";
import log from "ente-base/log";
@@ -58,6 +59,7 @@ import { clampSpaceMessageText } from "utils/message-limits";
import {
shownPhotoState,
viewerBackgroundOpacity,
+ type ViewerCornerRadii,
type ViewerPhotoState,
type ViewerRect,
} from "utils/viewer-geometry";
@@ -728,10 +730,11 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
viewerPhotosRef.current[pswp?.currIndex ?? activePhotoIndex];
const element = pswp?.currSlide?.content.element;
let from: ViewerPhotoState | undefined = motion.flight?.current();
- let src = from ? item?.imageUrl : undefined;
+ let src = from ? motion.flight?.src : undefined;
const rect = element?.getBoundingClientRect();
if (
!from &&
+ !motion.flight &&
rect &&
rect.width > 0 &&
rect.height > 0 &&
@@ -743,7 +746,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
from = shownPhotoState(
{ x: rect.left, y: rect.top, w: rect.width, h: rect.height },
{ x: 0, y: 0, w: window.innerWidth, h: window.innerHeight },
- (parseFloat(element.style.borderRadius) || 0) * scale,
+ viewerCornerRadii(element, scale),
);
src = element.currentSrc || element.src;
}
@@ -1496,7 +1499,12 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
// The drag pose and the parallax use the separate `scale` and
// `translate` properties, which leave PhotoSwipe's transform alone.
let posed:
- { container: HTMLElement; element?: HTMLElement } | undefined;
+ | {
+ container: HTMLElement;
+ element?: HTMLElement;
+ radii: ViewerCornerRadii;
+ }
+ | undefined;
const clearDismissPose = () => {
if (!posed) return;
posed.container.style.scale = "";
@@ -1516,7 +1524,19 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
clearDismissPose();
return;
}
- posed = { container: slide.container, element };
+ if (!posed) {
+ const item = viewerPhotosRef.current[pswp!.currIndex];
+ const origin = findViewerOrigin(
+ viewerOriginKey(item?.spaceId, item?.postId),
+ );
+ posed = {
+ container: slide.container,
+ element,
+ radii: origin
+ ? viewerCornerRadii(origin)
+ : [24, 24, 24, 24],
+ };
+ }
const scale =
1 -
0.32 *
@@ -1528,7 +1548,12 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
slide.container.style.scale = String(scale);
slide.container.style.translate = `${x * (1 - scale)}px ${y * (1 - scale)}px`;
if (element)
- element.style.borderRadius = `${(24 * Math.min(1, Math.abs(dy) / 140)) / scale}px`;
+ element.style.borderRadius = posed.radii
+ .map(
+ (radius) =>
+ `${(radius * Math.min(1, Math.abs(dy) / 140)) / scale}px`,
+ )
+ .join(" ");
};
pswp.on("zoomPanUpdate", () => {
applyDismissPose();
@@ -1754,6 +1779,8 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
{ pointerEvents: "none !important" },
"&[data-space-viewer-waiting='true'] [data-space-viewer-close], &[data-space-viewer-waiting='true'] [data-space-viewer-close] *":
{ pointerEvents: "auto !important" },
+ "&[data-space-viewer-waiting='true'] [data-space-viewer-chrome='true']":
+ { opacity: 1 },
"@media (prefers-reduced-motion: reduce)": {
transition: "none",
},
diff --git a/web/apps/space/src/components/viewer-transition.ts b/web/apps/space/src/components/viewer-transition.ts
index e576a7d711..dcf0f453ca 100644
--- a/web/apps/space/src/components/viewer-transition.ts
+++ b/web/apps/space/src/components/viewer-transition.ts
@@ -3,6 +3,8 @@ import {
mixPhotoState,
photoStateTravel,
tilePhotoState,
+ viewerBackgroundOpacity,
+ type ViewerCornerRadii,
type ViewerPhotoState,
type ViewerRect,
} from "utils/viewer-geometry";
@@ -49,8 +51,18 @@ const isOnScreen = (element: Element) => {
const prefersReducedMotion = () =>
window.matchMedia("(prefers-reduced-motion: reduce)").matches;
-const tileRadius = (tile: Element) =>
- parseFloat(getComputedStyle(tile).borderTopLeftRadius) || 0;
+export const viewerCornerRadii = (
+ element: Element,
+ scale = 1,
+): ViewerCornerRadii => {
+ const style = getComputedStyle(element);
+ return [
+ style.borderTopLeftRadius,
+ style.borderTopRightRadius,
+ style.borderBottomRightRadius,
+ style.borderBottomLeftRadius,
+ ].map((radius) => (parseFloat(radius) || 0) * scale) as ViewerCornerRadii;
+};
const runSpring = ({
from,
@@ -131,17 +143,54 @@ const createFlyer = (root: HTMLElement, src: string, base: ViewerRect) => {
flyer.append(image);
root.prepend(flyer);
- const draw = ({ image: i, visible: v, radius }: ViewerPhotoState) => {
+ const draw = ({ image: i, visible: v, radii }: ViewerPhotoState) => {
const sx = v.w / base.w;
const sy = v.h / base.h;
flyer.style.transform = `translate3d(${v.x}px, ${v.y}px, 0) scale(${sx}, ${sy})`;
- flyer.style.borderRadius = `${radius / sx}px / ${radius / sy}px`;
+ flyer.style.borderRadius = `${radii.map((radius) => `${radius / sx}px`).join(" ")} / ${radii.map((radius) => `${radius / sy}px`).join(" ")}`;
image.style.transform = `translate3d(${(i.x - v.x) / sx}px, ${(i.y - v.y) / sy}px, 0) scale(${i.w / v.w}, ${i.h / v.h})`;
};
- return { flyer, draw };
+ return { flyer, image, draw };
};
const createRider = (flyer: HTMLElement, tile: HTMLElement) => {
+ const card = tile.closest("article");
+ const header = card?.querySelector<HTMLElement>(
+ "[data-space-viewer-header]",
+ );
+ const shade = card?.querySelector<HTMLElement>(
+ "[data-space-viewer-header-shade]",
+ );
+ if (header && shade) {
+ const bounds = rectOf(tile);
+ const rider = document.createElement("div");
+ rider.setAttribute("aria-hidden", "true");
+ rider.inert = true;
+ rider.append(shade.cloneNode(true), header.cloneNode(true));
+ Object.assign(rider.style, {
+ borderRadius: getComputedStyle(tile).borderRadius,
+ height: `${bounds.h}px`,
+ left: `${bounds.x}px`,
+ overflow: "hidden",
+ pointerEvents: "none",
+ position: "absolute",
+ top: `${bounds.y}px`,
+ width: `${bounds.w}px`,
+ zIndex: "2",
+ });
+ flyer.after(rider);
+ header.style.opacity = "0";
+ return {
+ element: rider,
+ draw: (_state: ViewerPhotoState, t: number) => {
+ rider.style.opacity = String(1 - viewerBackgroundOpacity(t));
+ },
+ remove: () => rider.remove(),
+ reveal: () => {
+ header.style.opacity = "";
+ },
+ };
+ }
const button = tile.parentElement?.querySelector<HTMLElement>(
"[data-space-viewer-avatar]",
);
@@ -166,6 +215,7 @@ const createRider = (flyer: HTMLElement, tile: HTMLElement) => {
button.style.opacity = "0";
return {
+ element: rider,
draw: ({ visible: v }: ViewerPhotoState, t: number) => {
rider.style.transform = `translate3d(${v.x + left}px, ${v.y + v.h - fromBottom}px, 0)`;
rider.style.opacity = String(
@@ -189,21 +239,40 @@ export const playViewerOpen = (
) => {
if (prefersReducedMotion() || !isOnScreen(origin)) return undefined;
- const from = tilePhotoState(rectOf(origin), photo, tileRadius(origin));
+ const from = tilePhotoState(
+ rectOf(origin),
+ photo,
+ viewerCornerRadii(origin),
+ );
let end = fullPhotoState(to);
let t = 0;
- const { flyer, draw } = createFlyer(root, src, to);
- const rider = createRider(flyer, origin);
+ const tileImage = origin.querySelector<HTMLImageElement>(
+ "img:not([aria-hidden])",
+ );
+ const thumbnail =
+ origin.querySelector<HTMLImageElement>("img[aria-hidden]");
+ const preview =
+ tileImage?.complete && tileImage.naturalWidth > 0
+ ? tileImage
+ : thumbnail;
+ const flightSrc = preview?.currentSrc || src;
+ const { flyer, image, draw } = createFlyer(root, flightSrc, to);
+ let rider: ReturnType<typeof createRider>;
+ let started = false;
+ let disposed = false;
+ let stopSpring: () => void = () => undefined;
const drawAt = (value: number) => {
const state = mixPhotoState(from, end, value);
draw(state);
rider?.draw(state, value);
};
- origin.style.opacity = "0";
+ flyer.style.visibility = "hidden";
+ root.dataset.spaceViewerWaiting = "true";
drawAt(0);
setProgress(0);
const release = () => {
+ disposed = true;
flyer.remove();
rider?.remove();
};
@@ -211,22 +280,37 @@ export const playViewerOpen = (
origin.style.opacity = "";
rider?.reveal();
};
- const stopSpring = runSpring({
- from: 0,
- to: 1,
- velocity: 0,
- duration: openDuration,
- bounce: openBounce,
- restDelta: 1.5 / Math.max(1, photoStateTravel(from, end)),
- onUpdate: (value) => {
- t = value;
- drawAt(t);
- setProgress(t);
+ void image.decode().then(
+ () => {
+ if (disposed) return;
+ started = true;
+ flyer.style.visibility = "";
+ origin.style.opacity = "0";
+ delete root.dataset.spaceViewerWaiting;
+ rider = createRider(flyer, origin);
+ drawAt(0);
+ stopSpring = runSpring({
+ from: 0,
+ to: 1,
+ velocity: 0,
+ duration: openDuration,
+ bounce: openBounce,
+ restDelta: 1.5 / Math.max(1, photoStateTravel(from, end)),
+ onUpdate: (value) => {
+ t = value;
+ drawAt(t);
+ setProgress(t);
+ },
+ onDone: onLanded,
+ });
},
- onDone: onLanded,
- });
+ () => {
+ if (!disposed) onLanded();
+ },
+ );
return {
- current: () => mixPhotoState(from, end, t),
+ src: flightSrc,
+ current: () => (started ? mixPhotoState(from, end, t) : undefined),
release,
reveal,
retarget: (rect: ViewerRect) => {
@@ -252,7 +336,11 @@ export const playViewerClose = (
) => {
if (prefersReducedMotion() || !isOnScreen(origin)) return undefined;
- const end = tilePhotoState(rectOf(origin), photo, tileRadius(origin));
+ const end = tilePhotoState(
+ rectOf(origin),
+ photo,
+ viewerCornerRadii(origin),
+ );
const { flyer, draw } = createFlyer(root, src, from.image);
const rider = createRider(flyer, origin);
const drawAt = (t: number) => {
@@ -307,6 +395,15 @@ export const playViewerClose = (
zIndex: "1301",
});
document.body.append(ghost);
+ const overlay = rider?.element.cloneNode(true) as
+ HTMLElement | undefined;
+ if (overlay) {
+ Object.assign(overlay.style, {
+ position: "fixed",
+ zIndex: "1302",
+ });
+ document.body.append(overlay);
+ }
flyer.remove();
ghost
.animate([{ opacity: 1 }, { opacity: 0 }], {
@@ -314,7 +411,10 @@ export const playViewerClose = (
easing: "ease",
fill: "forwards",
})
- .addEventListener("finish", () => ghost.remove());
+ .addEventListener("finish", () => {
+ ghost.remove();
+ overlay?.remove();
+ });
}
onDone();
},
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index ce31708238..07b4a7c514 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -1452,6 +1452,7 @@ const FeedItem: React.FC<FeedItemProps> = ({
</Box>
<Box
aria-hidden
+ data-space-viewer-header-shade
sx={{
background:
"linear-gradient(180deg, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0))",
@@ -1466,6 +1467,7 @@ const FeedItem: React.FC<FeedItemProps> = ({
}}
/>
<Box
+ data-space-viewer-header
sx={{
alignItems: "center",
boxSizing: "border-box",
diff --git a/web/apps/space/src/utils/viewer-geometry.ts b/web/apps/space/src/utils/viewer-geometry.ts
index f0048493d3..d6b2237f25 100644
--- a/web/apps/space/src/utils/viewer-geometry.ts
+++ b/web/apps/space/src/utils/viewer-geometry.ts
@@ -5,17 +5,19 @@ export interface ViewerRect {
h: number;
}
+export type ViewerCornerRadii = [number, number, number, number];
+
// image is where the whole photo is, visible is the part of it that shows.
export interface ViewerPhotoState {
image: ViewerRect;
visible: ViewerRect;
- radius: number;
+ radii: ViewerCornerRadii;
}
export const tilePhotoState = (
tile: ViewerRect,
photo: { width: number; height: number },
- radius: number,
+ radii: ViewerCornerRadii,
): ViewerPhotoState => {
const scale = Math.max(tile.w / photo.width, tile.h / photo.height);
const w = photo.width * scale;
@@ -28,23 +30,23 @@ export const tilePhotoState = (
h,
},
visible: { ...tile },
- radius,
+ radii,
};
};
export const fullPhotoState = (
rect: ViewerRect,
- radius = 0,
-): ViewerPhotoState => ({ image: { ...rect }, visible: { ...rect }, radius });
+ radii: ViewerCornerRadii = [0, 0, 0, 0],
+): ViewerPhotoState => ({ image: { ...rect }, visible: { ...rect }, radii });
// A photo zoomed in past the viewport is cut to it.
export const shownPhotoState = (
image: ViewerRect,
viewport: ViewerRect,
- radius: number,
+ radii: ViewerCornerRadii,
): ViewerPhotoState => {
if (image.w <= viewport.w && image.h <= viewport.h)
- return fullPhotoState(image, radius);
+ return fullPhotoState(image, radii);
const x = Math.max(image.x, viewport.x);
const y = Math.max(image.y, viewport.y);
const w = Math.min(image.x + image.w, viewport.x + viewport.w) - x;
@@ -52,7 +54,7 @@ export const shownPhotoState = (
return {
image: { ...image },
visible: { x, y, w: Math.max(0, w), h: Math.max(0, h) },
- radius,
+ radii,
};
};
@@ -72,7 +74,9 @@ export const mixPhotoState = (
): ViewerPhotoState => ({
image: mixRect(from.image, to.image, t),
visible: mixRect(from.visible, to.visible, t),
- radius: Math.max(0, mix(from.radius, to.radius, t)),
+ radii: from.radii.map((radius, index) =>
+ Math.max(0, mix(radius, to.radii[index]!, t)),
+ ) as ViewerCornerRadii,
});
export const photoStateTravel = (a: ViewerPhotoState, b: ViewerPhotoState) =>
diff --git a/web/apps/space/tests/viewer-geometry.test.ts b/web/apps/space/tests/viewer-geometry.test.ts
index 0e70c20111..f5f32f81c5 100644
--- a/web/apps/space/tests/viewer-geometry.test.ts
+++ b/web/apps/space/tests/viewer-geometry.test.ts
@@ -11,24 +11,27 @@ import {
const tile = { x: 10, y: 20, w: 100, h: 100 };
test("a tile crops a wide photo to its centre", () => {
- expect(tilePhotoState(tile, { width: 200, height: 100 }, 12)).toEqual({
+ expect(
+ tilePhotoState(tile, { width: 200, height: 100 }, [12, 12, 12, 12]),
+ ).toEqual({
image: { x: -40, y: 20, w: 200, h: 100 },
visible: tile,
- radius: 12,
+ radii: [12, 12, 12, 12],
});
});
test("a tile crops a tall photo to its centre", () => {
- expect(tilePhotoState(tile, { width: 300, height: 900 }, 0).image).toEqual({
- x: 10,
- y: -80,
- w: 100,
- h: 300,
- });
+ expect(
+ tilePhotoState(tile, { width: 300, height: 900 }, [0, 0, 0, 0]).image,
+ ).toEqual({ x: 10, y: -80, w: 100, h: 300 });
});
test("a flight starts and ends exactly on its endpoints", () => {
- const from = tilePhotoState(tile, { width: 200, height: 100 }, 12);
+ const from = tilePhotoState(
+ tile,
+ { width: 200, height: 100 },
+ [12, 12, 12, 12],
+ );
const to = fullPhotoState({ x: 0, y: 100, w: 400, h: 200 });
expect(mixPhotoState(from, to, 0)).toEqual(from);
@@ -36,23 +39,44 @@ test("a flight starts and ends exactly on its endpoints", () => {
expect(mixPhotoState(from, to, 0.5)).toEqual({
image: { x: -20, y: 60, w: 300, h: 150 },
visible: { x: 5, y: 60, w: 250, h: 150 },
- radius: 6,
+ radii: [6, 6, 6, 6],
});
});
test("a spring overshoot never makes the corner radius negative", () => {
- const from = fullPhotoState(tile, 12);
+ const from = fullPhotoState(tile, [12, 12, 12, 12]);
const to = fullPhotoState(tile);
- expect(mixPhotoState(from, to, 1.2).radius).toBe(0);
+ expect(mixPhotoState(from, to, 1.2).radii).toEqual([0, 0, 0, 0]);
+});
+
+test("Latest photos keep square bottom corners throughout closing", () => {
+ const end = tilePhotoState(
+ tile,
+ { width: 200, height: 100 },
+ [24, 24, 0, 0],
+ );
+ const rect = { x: 0, y: 100, w: 400, h: 200 };
+ for (const from of [
+ fullPhotoState(rect),
+ fullPhotoState(rect, [12, 12, 0, 0]),
+ ]) {
+ for (const progress of [0, 0.25, 0.5, 0.75, 1]) {
+ const radii = mixPhotoState(from, end, progress).radii;
+ expect(radii.slice(2)).toEqual([0, 0]);
+ expect(radii[0]).toBeGreaterThanOrEqual(from.radii[0]);
+ expect(radii[0]).toBeLessThanOrEqual(24);
+ }
+ expect(mixPhotoState(from, end, 1).radii).toEqual([24, 24, 0, 0]);
+ }
});
test("a photo that fits on screen closes whole", () => {
const viewport = { x: 0, y: 0, w: 390, h: 844 };
const dragged = { x: 40, y: 700, w: 300, h: 400 };
- expect(shownPhotoState(dragged, viewport, 8)).toEqual(
- fullPhotoState(dragged, 8),
+ expect(shownPhotoState(dragged, viewport, [8, 8, 8, 8])).toEqual(
+ fullPhotoState(dragged, [8, 8, 8, 8]),
);
});
@@ -60,10 +84,10 @@ test("a zoomed-in photo closes from the part on screen", () => {
const viewport = { x: 0, y: 0, w: 390, h: 844 };
const zoomed = { x: -500, y: -200, w: 1800, h: 2400 };
- expect(shownPhotoState(zoomed, viewport, 0)).toEqual({
+ expect(shownPhotoState(zoomed, viewport, [0, 0, 0, 0])).toEqual({
image: zoomed,
visible: viewport,
- radius: 0,
+ radii: [0, 0, 0, 0],
});
});
diff --git a/web/apps/space/tests/viewer-transition.test.ts b/web/apps/space/tests/viewer-transition.test.ts
index c4ab55f51e..5be5628a1e 100644
--- a/web/apps/space/tests/viewer-transition.test.ts
+++ b/web/apps/space/tests/viewer-transition.test.ts
@@ -1,5 +1,10 @@
-import { expect, test } from "vitest";
-import { viewerOriginKey } from "../src/components/viewer-transition";
+import { afterEach, expect, test, vi } from "vitest";
+import {
+ playViewerOpen,
+ viewerOriginKey,
+} from "../src/components/viewer-transition";
+
+afterEach(() => vi.unstubAllGlobals());
test("tiles are matched by space and post", () => {
expect(viewerOriginKey("space", 12)).toBe("space:12");
@@ -7,3 +12,113 @@ test("tiles are matched by space and post", () => {
expect(viewerOriginKey(undefined, 12)).toBeUndefined();
expect(viewerOriginKey("space", undefined)).toBeUndefined();
});
+
+const pendingFlight = () => {
+ let resolveDecode!: () => void;
+ let rejectDecode!: (error: Error) => void;
+ const decoded = new Promise<void>((resolve, reject) => {
+ resolveDecode = resolve;
+ rejectDecode = reject;
+ });
+ const flyer = {
+ style: {} as Record<string, string>,
+ setAttribute: vi.fn(),
+ append: vi.fn(),
+ remove: vi.fn(),
+ };
+ const image = { style: {}, src: "", decode: () => decoded };
+ const origin = {
+ style: { opacity: "" },
+ closest: () => null,
+ getBoundingClientRect: () => ({
+ left: 10,
+ top: 20,
+ width: 100,
+ height: 100,
+ }),
+ querySelector: (selector: string) =>
+ selector == "img[aria-hidden]"
+ ? { currentSrc: "data:thumbnail" }
+ : null,
+ };
+ vi.stubGlobal("document", {
+ createElement: (tag: string) => (tag == "img" ? image : flyer),
+ });
+ vi.stubGlobal("window", {
+ innerWidth: 390,
+ innerHeight: 844,
+ matchMedia: () => ({ matches: false }),
+ });
+ vi.stubGlobal("getComputedStyle", () => ({
+ borderTopLeftRadius: "24px",
+ borderTopRightRadius: "24px",
+ borderBottomRightRadius: "0px",
+ borderBottomLeftRadius: "0px",
+ }));
+ const requestFrame = vi.fn(() => 1);
+ vi.stubGlobal("requestAnimationFrame", requestFrame);
+ vi.stubGlobal("cancelAnimationFrame", vi.fn());
+ const onLanded = vi.fn();
+ const flight = playViewerOpen(
+ { dataset: {}, prepend: vi.fn() } as unknown as HTMLElement,
+ {
+ origin: origin as unknown as HTMLElement,
+ src: "full-photo",
+ photo: { width: 200, height: 100 },
+ },
+ { x: 0, y: 100, w: 390, h: 195 },
+ vi.fn(),
+ onLanded,
+ )!;
+ return {
+ flight,
+ flyer,
+ image,
+ origin,
+ requestFrame,
+ resolveDecode,
+ rejectDecode,
+ onLanded,
+ };
+};
+
+test("the tile stays visible until its flying thumbnail has decoded", async () => {
+ const { flight, flyer, image, origin, requestFrame, resolveDecode } =
+ pendingFlight();
+ expect(image.src).toBe("data:thumbnail");
+ expect(origin.style.opacity).toBe("");
+ expect(flyer.style.visibility).toBe("hidden");
+ expect(flight.current()).toBeUndefined();
+ expect(requestFrame).not.toHaveBeenCalled();
+
+ resolveDecode();
+ await Promise.resolve();
+
+ expect(origin.style.opacity).toBe("0");
+ expect(flyer.style.visibility).toBe("");
+ expect(flight.current()?.radii).toEqual([24, 24, 0, 0]);
+ expect(requestFrame).toHaveBeenCalledOnce();
+ flight.stop();
+});
+
+test("closing before decoding cannot hide the tile afterward", async () => {
+ const { flight, flyer, origin, requestFrame, resolveDecode } =
+ pendingFlight();
+ flight.stop();
+ resolveDecode();
+ await Promise.resolve();
+
+ expect(origin.style.opacity).toBe("");
+ expect(flyer.remove).toHaveBeenCalledOnce();
+ expect(requestFrame).not.toHaveBeenCalled();
+});
+
+test("a failed flyer leaves the tile visible and allows viewer handover", async () => {
+ const { flight, origin, onLanded, rejectDecode } = pendingFlight();
+ rejectDecode(new Error("decode failed"));
+ await Promise.resolve();
+
+ expect(origin.style.opacity).toBe("");
+ expect(onLanded).toHaveBeenCalledOnce();
+ flight.stop();
+});