diff options
| author | Adam Soltys <[email protected]> | 2026-10-13 06:17:39 +0000 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-13 06:17:39 +0000 |
| commit | 8f80948eb174a273f3b1dea963bb91745bcf323b (patch) | |
| tree | a8e704dd6896be17df41c7f844e21f18be5fdb92 /tools/feed-media-views-test.js | |
| parent | b330cc707fab62365c29b57d414c46aa198febef (diff) | |
| download | coinosv3-8f80948eb174a273f3b1dea963bb91745bcf323b.tar.gz coinosv3-8f80948eb174a273f3b1dea963bb91745bcf323b.zip | |
Media pager: up and down go from post to post, left and right along a post's pictures. Adam: swipes and arrows up/down should go to the next post's media, left/right to the next within a post. The pager is now posts stacked top to bottom, each a row of its pictures or clips side by side — a quoted post's join the post that quotes it — with dots along the top when a post has more than one, saying how many and which. Up and down (swipe, arrows, j/k, Page) move a post at a time and land on a post where its row was left; left and right (swipe, arrows, h/l) move within the post and stop at its ends. A post's pictures all load as it comes near (those along its row too); a clip's head start goes to the next post's (where its row rests), the next along this one, and the post after next, at half; the look-ahead (the feed paging on, the media crawl) counts posts. Pictures pan sideways as well as up and down at 1×. Tests find the slide on screen by where it sits (the pager's children are posts now); feed-picture-pager walks right within a post, down past one with none, back up to where a post was left, left to its first, and a sideways swipe next to a swipe up; quote-pager walks the quoting post's row (its own picture, then the quote's).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KPw21NEpWeTGu6swVASmBt
Diffstat (limited to 'tools/feed-media-views-test.js')
| -rw-r--r-- | tools/feed-media-views-test.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/feed-media-views-test.js b/tools/feed-media-views-test.js index 6649a93..2c84b14 100644 --- a/tools/feed-media-views-test.js +++ b/tools/feed-media-views-test.js @@ -95,8 +95,8 @@ const pagerState = () => page.evaluate(() => { const p = document.querySelector('.media-pager'); if (!p) return null; const sc = p.querySelector('.mp-scroll'); - const slides = [...sc.querySelectorAll(':scope > .mp-slide')]; // (not the loading screen at the end) - const i = Math.round(sc.scrollTop / sc.clientHeight); + const slides = [...sc.querySelectorAll('.mp-slide')]; // (not the loading screen at the end) + const i = slides.findIndex((x) => { const r = x.getBoundingClientRect(); return Math.abs(r.top) < 4 && Math.abs(r.left) < 4; }); // the slide on screen const vids = slides.map((s) => s.querySelector('video')); return { n: slides.length, i, src: (slides[i]?.querySelector('.mp-media')?.getAttribute('data-src') || '').split('/').pop(), playing: vids.map((v) => !!(v && !v.paused)), show: p.classList.contains('show'), @@ -145,12 +145,12 @@ try { await page.evaluate(() => { const p = document.querySelector('.media-pager'); p.querySelector('.mp-slide').dispatchEvent(new MouseEvent('click', { bubbles: true })); }); await sleep(300); st = await pagerState(); - const meta = await page.evaluate(() => { const s = [...document.querySelectorAll('.mp-slide')][Math.round(document.querySelector('.mp-scroll').scrollTop / document.querySelector('.mp-scroll').clientHeight)]; return { author: s.querySelector('.mp-author > span:last-child').textContent, caption: s.querySelector('.mp-caption')?.textContent }; }); + const meta = await page.evaluate(() => { const s = [...document.querySelectorAll('.mp-slide')].find((x) => { const r = x.getBoundingClientRect(); return Math.abs(r.top) < 4 && Math.abs(r.left) < 4; }); return { author: s.querySelector('.mp-author > span:last-child').textContent, caption: s.querySelector('.mp-caption')?.textContent }; }); check('a tap shows the author and the words, without the links', st.show && st.meta === '1' && meta.author === 'Shutterbug' && meta.caption === 'two at once', JSON.stringify(meta)); await page.keyboard.press('ArrowUp'); await sleep(900); st = await pagerState(); check('↑ goes to the previous picture', st.src === 'p1.jpg', JSON.stringify(st)); - check('its like shows in the corner', await waitFor(() => { const p = document.querySelector('.media-pager'); const sc = p.querySelector('.mp-scroll'); const s = sc.children[Math.round(sc.scrollTop / sc.clientHeight)]; return s.querySelector('.mp-like .n').textContent === '1'; }, 6000)); + check('its like shows in the corner', await waitFor(() => { const p = document.querySelector('.media-pager'); const sc = p.querySelector('.mp-scroll'); const s = [...document.querySelectorAll('.mp-slide')].find((x) => { const r = x.getBoundingClientRect(); return Math.abs(r.top) < 4 && Math.abs(r.left) < 4; }); return s.querySelector('.mp-like .n').textContent === '1'; }, 6000)); await shot('pager-meta'); await page.goBack(); await sleep(600); check('Back closes the pager, leaving the grid', await page.evaluate(() => !document.querySelector('.media-pager') && !!document.querySelector('.media-grid'))); |
