From cd70bf87db6b4118570dbace19714f76c39207e3 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 20 Feb 2023 17:51:41 +0800 Subject: [PATCH 1/3] Animate position-object when link is focused --- src/components/status.css | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/status.css b/src/components/status.css index 5a349c6b..1eac8f58 100644 --- a/src/components/status.css +++ b/src/components/status.css @@ -421,7 +421,8 @@ object-position: 50% 50%; } } -.status .media img:hover { +.status .media img:is(:hover, :focus), +a:focus-visible .status .media img { animation: position-object 5s ease-in-out 1s 5; } body:has(#modal-container .carousel) .status .media img:hover { @@ -625,7 +626,8 @@ body:has(#modal-container .carousel) .status .media img:hover { border-inline-end: 0; border-block-end: 1px solid var(--outline-color); } -.card:is(:hover, :focus) img { +.card:is(:hover, :focus) img, +a:focus-visible .card img { animation: position-object 5s ease-in-out 1s 5; } .card p { From 6e9661a70c6e7fb688b7ecc4a75b5d491a8e4388 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 20 Feb 2023 20:58:53 +0800 Subject: [PATCH 2/3] Use the right way --- src/components/timeline.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/timeline.jsx b/src/components/timeline.jsx index 6692368e..78cb035b 100644 --- a/src/components/timeline.jsx +++ b/src/components/timeline.jsx @@ -50,7 +50,7 @@ function Timeline({ if (firstLoad) { setItems(value); } else { - setItems([...items, ...value]); + setItems((items) => [...items, ...value]); } setShowMore(!done); } else { From 8e4ecd242b5c50357193b2b9bcf6b0d139b74093 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 20 Feb 2023 20:59:46 +0800 Subject: [PATCH 3/3] Revert flush to cancel, speed up scroll position caching Somehow the flush cache the scroll position for a different status ID --- src/pages/status.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/status.jsx b/src/pages/status.jsx index 10ab7071..c22e6bc0 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -62,13 +62,13 @@ function StatusPage() { if (uiState !== 'loading') { states.scrollPositions[id] = scrollTop; } - }, 100); + }, 50); scrollableRef.current.addEventListener('scroll', onScroll, { passive: true, }); onScroll(); return () => { - onScroll.flush(); + onScroll.cancel(); scrollableRef.current?.removeEventListener('scroll', onScroll); }; }, [id, uiState !== 'loading']);