From 2d23d2e9963d08dc14bfcaf24b343045127e1cc2 Mon Sep 17 00:00:00 2001 From: plebbitor Date: Fri, 10 Mar 2023 12:36:04 +0100 Subject: [PATCH] fix touch bug --- src/components/Board.jsx | 81 +++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/src/components/Board.jsx b/src/components/Board.jsx index 1b2c95fc..1a66afdc 100644 --- a/src/components/Board.jsx +++ b/src/components/Board.jsx @@ -280,10 +280,18 @@ const Board = ({ setBodyStyle }) => { const targetElement = [...document.querySelectorAll('.post-reply')] .find(el => el.innerHTML.includes(cid)); if (targetElement) { + const rect = targetElement.getBoundingClientRect(); + if (rect.top < 0 || rect.bottom > window.innerHeight) { targetElement.scrollIntoView({ behavior: "instant" }); + } } } + function handleTouch(event) { + event.preventDefault(); + event.target.click(); + } + const handleStyleChange = (event) => { switch (event.target.value) { @@ -379,17 +387,17 @@ const Board = ({ setBodyStyle }) => { {defaultSubplebbits.map(subplebbit => ( [ - handleClickTitle(subplebbit.title, subplebbit.address)} + handleClickTitle(subplebbit.title, subplebbit.address)} >{subplebbit.title} ]  ))} [ - Settings + Settings ] [ - handleStyleChange({target: {value: "Yotsuba"}} + handleStyleChange({target: {value: "Yotsuba"}} )}>Home ] @@ -405,9 +413,9 @@ const Board = ({ setBodyStyle }) => {
- Settings + Settings   - handleStyleChange({target: {value: "Yotsuba"}} + handleStyleChange({target: {value: "Yotsuba"}} )}>Home
@@ -468,8 +476,11 @@ const Board = ({ setBodyStyle }) => { - - + + + + + @@ -489,12 +500,12 @@ const Board = ({ setBodyStyle }) => {
[ - Catalog + Catalog ]
- Catalog + Catalog
@@ -521,7 +532,7 @@ const Board = ({ setBodyStyle }) => { File:  filename.something (metadata) - + filename.something @@ -575,22 +586,22 @@ const Board = ({ setBodyStyle }) => { {getDate(thread.timestamp)}   - c/ - {thread.cid.slice(0, 8)} + c/ + {thread.cid.slice(0, 8)}   [ - handleClickThread(thread.cid)} className="reply-link" >Reply + handleClickThread(thread.cid)} className="reply-link" >Reply ] - ▶ +