aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/features/messages.js41
-rw-r--r--src/style.css8
2 files changed, 47 insertions, 2 deletions
diff --git a/src/features/messages.js b/src/features/messages.js
index 8f8bdd4..245e1ce 100644
--- a/src/features/messages.js
+++ b/src/features/messages.js
@@ -7036,9 +7036,12 @@ export function messagesFeature(ctx) {
// make it): the server makes one
if (!got && (noCorsHost(url) || corsRefused.has(url) || typeof OffscreenCanvas === 'undefined')) got = await serverMediaThumb(url).catch(() => null);
if (got) {
+ // the grid tile made alongside it, for a post's run of pictures
+ // (see pictureRuns): looked up from disk when the copy was
+ await warmTileThumbs([url]).catch(() => {});
// no copy (small already, or a GIF): the original is what paints,
// so it's the one decoded ahead — the row mustn't decode it on sight
- await decodeAhead(got.thumb || url);
+ await Promise.all([decodeAhead(got.thumb || url), tileThumbs.has(url) ? decodeAhead(tileThumbs.get(url)) : null]);
mediaReady.set(url, got);
return;
}
@@ -10923,6 +10926,7 @@ export function messagesFeature(ctx) {
// opens the thread — not on the picture.
function onPicture(e) {
const el = e.currentTarget;
+ if (el.closest('.note-gallery')) return true; // a gallery tile is all picture (cropped to fill)
const r = el.getBoundingClientRect();
const nw = el.naturalWidth, nh = el.naturalHeight;
if (!nw || !nh || !r.width || !r.height) return true;
@@ -10953,7 +10957,7 @@ export function messagesFeature(ctx) {
// height-capped: see .note-img)
const known = size || mediaReady.get(url);
return h('img', {
- src: mediaSrc(url, known), class: 'note-img clickable', loading: feedPaint || known ? 'eager' : 'lazy', alt: label || '',
+ src: mediaSrc(url, known), 'data-pic': url, class: 'note-img clickable', loading: feedPaint || known ? 'eager' : 'lazy', alt: label || '',
// a few-ms decode of the copy paints with the page; an original never holds the page for its decode
decoding: known && known.thumb ? 'sync' : 'async',
width: size?.width, height: size?.height,
@@ -11381,6 +11385,39 @@ export function messagesFeature(ctx) {
for (const p of splitEmoji(part, emojiAt)) out.push(...(typeof p === 'string' ? mdInline(p) : [emojiImg(p.code, p.url)]));
} else out.push(...mdInline(part));
}
+ return pictureRuns(out);
+ }
+ // Two or more pictures in a row (only blank space between them) share one
+ // box of justified rows, the way the Images feed lays them out, instead of
+ // a screen each: a post of thirteen photos was thirteen screens to scroll
+ // past ("could we put them into a masonry grid layout within the post kinda
+ // like we do on our images feed", Adam, 2026-11-18). A tap still opens the
+ // picture in the pager, with the rest a swipe away.
+ const isNoteImg = (n) => !!n && n.nodeType === 1 && n.tagName === 'IMG' && n.classList.contains('note-img');
+ function pictureRuns(nodes) {
+ const out = [];
+ for (let i = 0; i < nodes.length; i++) {
+ if (!isNoteImg(nodes[i])) { out.push(nodes[i]); continue; }
+ const run = [nodes[i]];
+ let j = i + 1, last = i;
+ for (; j < nodes.length; j++) {
+ const n = nodes[j];
+ if (isNoteImg(n)) { run.push(n); last = j; continue; }
+ if (typeof n === 'string' && !n.trim()) continue;
+ break;
+ }
+ if (run.length < 2) { out.push(nodes[i]); continue; }
+ // A tile is painted from the Images feed's tile copy (360px, cut with a
+ // proper resize), not the 1100px column copy: shrunk eight times by the
+ // browser, that came out grainy (Adam, 2026-11-18).
+ for (const img of run) {
+ const url = img.getAttribute('data-pic'), tile = url && tileThumbs.get(url);
+ if (tile) img.setAttribute(img.hasAttribute('data-lazy-src') ? 'data-lazy-src' : 'src', tile);
+ else if (url && /^https?:/i.test(url)) queueTileThumbs([url]);
+ }
+ out.push(h('div', { class: 'note-gallery' }, ...run));
+ i = last;
+ }
return out;
}
diff --git a/src/style.css b/src/style.css
index f036fb8..a9ceadb 100644
--- a/src/style.css
+++ b/src/style.css
@@ -1631,6 +1631,14 @@ body::after {
320px would widen its tile, and the row's height with it */
.media-grid.justified .media-tile > img, .media-grid.justified .media-tile > video { position: absolute; inset: 0; }
@media (max-width: 600px) { .media-grid.justified { --row-h: 100px; } }
+/* a post's run of pictures: the same justified rows, inside the post */
+.note-gallery { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; border-radius: 10px; overflow: hidden; --row-h: 140px; }
+.note-gallery::after { content: ''; flex: 1000 1 0; }
+.note-gallery .note-img, .note-gallery .note-img.note-img-late {
+ margin: 0; border-radius: 0; width: auto; height: auto; max-width: none; max-height: none; min-width: 0;
+ aspect-ratio: var(--ar, 1); flex: var(--ar, 1) 1 calc(var(--ar, 1) * var(--row-h)); object-fit: cover; cursor: zoom-in;
+}
+@media (max-width: 600px) { .note-gallery { --row-h: 100px; } }
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.media-tile.broken { display: none; }
.media-tile-play {