Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Photos: smoother scrolling and opening; a photo no longer runs off the window; Info closes

Yashwanth Kamireddi4d25d6216c5b
diff --git a/.uiverify/photos-caption.mjs b/.uiverify/photos-caption.mjs
index d5b60b2..2118527 100644
--- a/.uiverify/photos-caption.mjs
+++ b/.uiverify/photos-caption.mjs
@@ -36,7 +36,8 @@ await page.keyboard.press("Escape");
await page.waitForTimeout(650);
await page.locator(".px-tile").nth(1).dblclick();
await page.waitForTimeout(600);
-ok((await page.locator(".px-info").count()) === 1, "Info is still open on the next photo opened");
+ok((await page.locator(".px-info").count()) === 0, "the next photo opens without Info");
+await page.keyboard.press("i");
ok((await page.getByLabel("Title").inputValue()) === "Ferry" && (await page.getByLabel("Caption").inputValue()) === "Half five, fish and hills",
"and both are there when the photo opens again");
await page.getByLabel("Title").click();
diff --git a/.uiverify/photos-rating.mjs b/.uiverify/photos-rating.mjs
index 24f7d56..56da45a 100644
--- a/.uiverify/photos-rating.mjs
+++ b/.uiverify/photos-rating.mjs
@@ -35,6 +35,7 @@ await page.waitForTimeout(250);
ok((await page.locator(".px-month-title").allInnerTexts()).join() === "5 Stars,3 Stars", `and Rated has it under 3 Stars ${JSON.stringify(await page.locator(".px-month-title").allInnerTexts())}`);
await page.locator(".px-tile").nth(1).dblclick();
await page.waitForTimeout(600);
+await page.keyboard.press("i");
await page.getByRole("radio", { name: "3 stars" }).click();
await page.waitForTimeout(300);
ok((await page.evaluate(() => window.__ratings.at(-1).rating)) === 0, "the same star again takes the rating away");
diff --git a/.uiverify/photos-viewer-real.mjs b/.uiverify/photos-viewer-real.mjs
index ae736b6..744647f 100644
--- a/.uiverify/photos-viewer-real.mjs
+++ b/.uiverify/photos-viewer-real.mjs
@@ -58,5 +58,15 @@ await page.keyboard.press("ArrowLeft");
await page.waitForTimeout(1200);
b1 = await boxes();
ok(lies(b1) && inside(b1), `and on the next photo ${JSON.stringify(b1)}`);
+await page.keyboard.press("Escape");
+await page.waitForTimeout(700);
+// A narrow window, a photo opened in it: inside, never wider than the window lets it be.
+await page.setViewportSize({ width: 760, height: 700 });
+await page.waitForTimeout(300);
+await page.locator(".px-tile").nth(0).dblclick();
+await page.waitForTimeout(1200);
+b1 = await boxes();
+const win = await page.evaluate(() => window.innerWidth);
+ok(inside(b1) && b1.shown.x + b1.shown.w <= win, `in a narrow window the photo stays inside it ${JSON.stringify(b1)}`);
await b.close();
process.exitCode = failures ? 1 : (process.exitCode ?? 0);
diff --git a/src/screens/PhotosView.tsx b/src/screens/PhotosView.tsx
index 06f2540..8129a83 100644
--- a/src/screens/PhotosView.tsx
+++ b/src/screens/PhotosView.tsx
@@ -1265,21 +1265,33 @@ export function PhotosView() {
const [here, setHere] = useState<string | null>(null);
const scroller = useRef<HTMLDivElement | null>(null);
const looking = useRef(false);
+ // Read a few times a second, not every frame, and by halving rather than going down every
+ // month: at the foot of three hundred months, measuring each one on every frame was work
+ // the scroll itself was waiting for.
const onScroll = useCallback(() => {
if (looking.current) return;
looking.current = true;
- requestAnimationFrame(() => {
+ window.setTimeout(() => {
looking.current = false;
const el = scroller.current;
if (!el || album) return setHere(null);
if (el.scrollTop < 24) return setHere(null);
const edge = el.getBoundingClientRect().top + 96;
- for (const m of el.querySelectorAll<HTMLElement>(".px-month")) {
- if (m.getBoundingClientRect().bottom > edge) return setHere(m.getAttribute("aria-label"));
+ const months = el.querySelectorAll<HTMLElement>(".px-month");
+ let [lo, hi] = [0, months.length - 1];
+ while (lo < hi) {
+ const mid = (lo + hi) >> 1;
+ if (months[mid].getBoundingClientRect().bottom > edge) hi = mid;
+ else lo = mid + 1;
}
- });
+ setHere(months[lo]?.getAttribute("aria-label") ?? null);
+ }, 120);
}, [album]);
useEffect(() => setHere(null), [view, album]);
+ // Info closes with the photo: the next photo opens plain, as he expects it to.
+ useEffect(() => {
+ if (open === null) setInfo(false);
+ }, [open === null]); // eslint-disable-line react-hooks/exhaustive-deps
useEffect(() => {
setChosen(new Set());
anchor.current = null;
diff --git a/src/styles/photos.css b/src/styles/photos.css
index 9234bb1..83fe5a1 100644
--- a/src/styles/photos.css
+++ b/src/styles/photos.css
@@ -119,9 +119,10 @@
height: 34px;
padding: 0 3px;
border-radius: 17px;
- background: var(--glass);
- -webkit-backdrop-filter: var(--glass-blur);
- backdrop-filter: var(--glass-blur);
+ /* No live blur: these sit over a scrolling grid and a photo that moves, and WebKitGTK blurs
+ what is behind again on every frame of either — the stutter in scrolling and the flash as a
+ photo opened. The glass is in the rim, the lift and a fill near enough to solid. */
+ background: color-mix(in srgb, var(--sheet) 90%, transparent);
box-shadow: var(--glass-float);
}
.px-cap {
@@ -195,15 +196,23 @@
}
.px-empty { margin: 18vh auto 0; max-width: 36ch; color: var(--text-2); text-align: center; }
-/* The library runs up under the floating bar and fades out against the top edge — Apple's
- scroll edge effect, done with a mask, which costs nothing per frame. */
+/* The library runs up under the floating bar and fades out at the top edge — Apple's scroll
+ edge effect. Done with a still layer in the window's colour over the top, not a mask on the
+ scroller: WebKitGTK composited a masked scroller again on every frame, and the scroll stuttered. */
.px-scroll {
flex: 1;
min-height: 0;
overflow-y: auto;
padding: 80px 2px 24px;
- -webkit-mask-image: linear-gradient(to bottom, transparent 0, transparent 44px, #000 104px);
- mask-image: linear-gradient(to bottom, transparent 0, transparent 44px, #000 104px);
+}
+.px-bar { isolation: isolate; }
+.px-bar::before {
+ content: "";
+ position: absolute;
+ inset: 0 0 -34px 0;
+ z-index: -1;
+ background: linear-gradient(to bottom, var(--bg) 0, var(--bg) 58%, color-mix(in srgb, var(--bg) 0%, transparent) 100%);
+ pointer-events: none;
}
/* A month not yet built: one cell laid out on the very grid its photos will use, as tall as
all its rows — square tiles, 2px between — so nothing moves when it is built. */
@@ -288,6 +297,9 @@
z-index: 5;
isolation: isolate;
display: grid;
+ /* One column the window sizes — never the photo: sized by what was in it, the column grew
+ to the photo, the photo was fitted to the column, and a photo ran off the window. */
+ grid-template-columns: minmax(0, 1fr);
grid-template-rows: minmax(0, 1fr);
color: var(--text);
}
@@ -310,7 +322,7 @@
.px-viewer-when strong { font-size: var(--t-13); font-weight: 600; }
.px-viewer-when span { color: var(--text-2); font-size: var(--t-11); }
.px-cap[aria-pressed="true"] { background: color-mix(in srgb, var(--text) 12%, transparent); }
-.px-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 62px 64px 22px; }
+.px-stage { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; overflow: hidden; padding: 62px 64px 22px; }
.px-stage img, .px-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
/* The photo's frame: what zooms and pans. The full picture lies over the screen-sized one,
faded in once loaded, so zooming never shows a blank. */
@@ -346,9 +358,7 @@
padding: 0;
border: 0;
border-radius: 50%;
- background: var(--glass);
- -webkit-backdrop-filter: var(--glass-blur);
- backdrop-filter: var(--glass-blur);
+ background: color-mix(in srgb, var(--sheet) 90%, transparent);
box-shadow: var(--glass-float);
color: var(--text);
transition: transform 160ms var(--spring-quick);