From 29e448442223c2383375eb86b0e92a8f22d4f045 Mon Sep 17 00:00:00 2001 From: copy-fywyf Date: Wed, 11 Feb 2026 11:14:19 +0800 Subject: [PATCH 01/12] =?UTF-8?q?refactor(=E5=90=8C=E6=AD=A5):=20=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E8=BF=9C=E7=A8=8B=E4=B9=A6=E7=B1=8D=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 usePrevious 钩子,直接依赖 remoteBooks 触发同步 - 将 readyToSync 状态改为 syncVersion 计数器,避免条件竞争 - 合并两个 useEffect,减少不必要的远程文件监听 --- apps/reader/src/pages/index.tsx | 49 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/apps/reader/src/pages/index.tsx b/apps/reader/src/pages/index.tsx index 65c1ab77..f6fa9735 100644 --- a/apps/reader/src/pages/index.tsx +++ b/apps/reader/src/pages/index.tsx @@ -12,7 +12,6 @@ import { MdOutlineShare, } from 'react-icons/md' import { useSet } from 'react-use' -import { usePrevious } from 'react-use' import { ReaderGridView, Button, TextField, DropZone } from '../components' import { BookRecord, CoverRecord, db } from '../db' @@ -102,43 +101,24 @@ const Library: React.FC = () => { const { data: remoteBooks, mutate: mutateRemoteBooks } = useRemoteBooks() const { data: remoteFiles, mutate: mutateRemoteFiles } = useRemoteFiles() - const previousRemoteBooks = usePrevious(remoteBooks) - const previousRemoteFiles = usePrevious(remoteFiles) const [select, toggleSelect] = useBoolean(false) const [selectedBookIds, { add, has, toggle, reset }] = useSet() const [loading, setLoading] = useState() - const [readyToSync, setReadyToSync] = useState(false) + const [syncVersion, setSyncVersion] = useState(0) const { groups } = useReaderSnapshot() useEffect(() => { - if (previousRemoteFiles && remoteFiles) { - // to remove effect dependency `books` - db?.books.toArray().then((books) => { - if (books.length === 0) return - - const newRemoteBooks = remoteFiles.map((f) => - books.find((b) => b.name === f.name), - ) as BookRecord[] - - uploadData(newRemoteBooks) - mutateRemoteBooks(newRemoteBooks, { revalidate: false }) - }) - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [mutateRemoteBooks, remoteFiles]) - - useEffect(() => { - if (!previousRemoteBooks && remoteBooks) { - db?.books.bulkPut(remoteBooks).then(() => setReadyToSync(true)) + if (remoteBooks) { + db?.books.bulkPut(remoteBooks).then(() => setSyncVersion((v) => v + 1)) } // eslint-disable-next-line react-hooks/exhaustive-deps }, [remoteBooks]) useEffect(() => { - if (!remoteFiles || !readyToSync) return + if (!remoteFiles || !syncVersion) return db?.books.toArray().then(async (books) => { for (const remoteFile of remoteFiles) { @@ -158,7 +138,7 @@ const Library: React.FC = () => { setLoading(undefined) } }) - }, [readyToSync, remoteFiles]) + }, [syncVersion, remoteFiles]) useEffect(() => { if (!select) reset() @@ -268,6 +248,16 @@ const Library: React.FC = () => { setLoading(undefined) mutateRemoteFiles() + mutateRemoteBooks((remoteBooks) => { + const newRemoteBooks = [ + ...(remoteBooks || []), + ...selectedBooks.filter( + (b) => !remoteBooks?.find((r) => r.id === b.id), + ), + ] + uploadData(newRemoteBooks) + return newRemoteBooks + }) } }} > @@ -296,6 +286,15 @@ const Library: React.FC = () => { }, { revalidate: false }, ) + + mutateRemoteBooks((remoteBooks) => { + const newRemoteBooks = + remoteBooks?.filter( + (b) => !selectedBooks.find((s) => s.id === b.id), + ) || [] + uploadData(newRemoteBooks) + return newRemoteBooks + }) }} > {t('delete')} From 8ca7c80f7d37dfa854b3ba4581645e7c6db81e15 Mon Sep 17 00:00:00 2001 From: copy-fywyf Date: Thu, 12 Feb 2026 14:15:37 +0800 Subject: [PATCH 02/12] =?UTF-8?q?fix:=20=E4=BB=85=E5=9C=A8=20iOS=20?= =?UTF-8?q?=E7=BC=A9=E6=94=BE=E6=97=B6=E9=98=BB=E6=AD=A2=20touchmove=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E8=A1=8C=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了在 iOS 上禁用捏合缩放时过度阻止 touch 事件的问题。之前会阻止所有 touchmove 事件,导致页面无法正常滚动。现在仅当检测到缩放操作(event.scale !== 1)时才阻止默认行为,从而允许正常的滚动交互。 --- apps/reader/src/hooks/useDisablePinchZooming.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/reader/src/hooks/useDisablePinchZooming.ts b/apps/reader/src/hooks/useDisablePinchZooming.ts index b75bbc9b..adc58366 100644 --- a/apps/reader/src/hooks/useDisablePinchZooming.ts +++ b/apps/reader/src/hooks/useDisablePinchZooming.ts @@ -6,7 +6,10 @@ export function useDisablePinchZooming(win?: Window) { const _win = win ?? window // Block pinch-zooming on iOS outside of the content area const handleTouchMove = (event: TouchEvent) => { - event.preventDefault() + // event.preventDefault() + if ((event as any).scale !== 1) { + event.preventDefault() + } } _win.document.addEventListener('touchmove', handleTouchMove, { From 65f4fe5244f804ac91e387e030039e76b6c14787 Mon Sep 17 00:00:00 2001 From: copy-fywyf Date: Thu, 12 Feb 2026 14:23:29 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E4=B8=8D=E5=86=8D=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E4=BB=BB=E4=BD=95=E8=A7=A6=E6=91=B8=E5=92=8C=E7=BC=A9=E6=94=BE?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/reader/src/components/Reader.tsx | 3 --- apps/reader/src/pages/index.tsx | 3 --- 2 files changed, 6 deletions(-) diff --git a/apps/reader/src/components/Reader.tsx b/apps/reader/src/components/Reader.tsx index 9f34ad71..c49d1b2e 100644 --- a/apps/reader/src/components/Reader.tsx +++ b/apps/reader/src/components/Reader.tsx @@ -23,7 +23,6 @@ import { hasSelection, useBackground, useColorScheme, - useDisablePinchZooming, useMobile, useSync, useTranslation, @@ -384,8 +383,6 @@ function BookPane({ tab, onMouseDown }: BookPaneProps) { } }) - useDisablePinchZooming(iframe) - return (
{ let src = router.query[SOURCE] if (!src) return From bad0794bd9de30ceccf05d167ebd07ccbd3739a8 Mon Sep 17 00:00:00 2001 From: copy-fywyf Date: Fri, 13 Feb 2026 12:47:27 +0800 Subject: [PATCH 04/12] =?UTF-8?q?fix:=20=E9=98=BB=E6=AD=A2=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E9=80=89=E6=8B=A9=E8=8F=9C=E5=8D=95=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=86=92=E6=B3=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在文本选择菜单的复制按钮上添加 onMouseDown 事件处理,调用 e.stopPropagation() 以防止鼠标事件冒泡到父元素,避免可能的意外交互。 --- apps/reader/src/components/TextSelectionMenu.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/reader/src/components/TextSelectionMenu.tsx b/apps/reader/src/components/TextSelectionMenu.tsx index afad66e8..32d8279d 100644 --- a/apps/reader/src/components/TextSelectionMenu.tsx +++ b/apps/reader/src/components/TextSelectionMenu.tsx @@ -188,6 +188,9 @@ const TextSelectionMenuRenderer: React.FC = ({ copy(text) } }} + onMouseDown={(e) => { + e.stopPropagation() + }} > {annotate ? (
From 895aafa8bc46693e1a7e9430745523a90c2cf88b Mon Sep 17 00:00:00 2001 From: copy-fywyf Date: Fri, 13 Feb 2026 13:00:38 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E5=90=8C=E4=B8=8A=E6=AC=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/reader/src/components/TextSelectionMenu.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/reader/src/components/TextSelectionMenu.tsx b/apps/reader/src/components/TextSelectionMenu.tsx index 32d8279d..dddc69c7 100644 --- a/apps/reader/src/components/TextSelectionMenu.tsx +++ b/apps/reader/src/components/TextSelectionMenu.tsx @@ -162,7 +162,7 @@ const TextSelectionMenuRenderer: React.FC = ({ setWidth(el.clientWidth) setHeight(el.clientHeight) if (!mobile) { - el.focus() + el.focus({ preventScroll: true }) } }} className={clsx( From 15b11759aa575e0a0330292ec8240332711b42b7 Mon Sep 17 00:00:00 2001 From: copy-fywyf Date: Fri, 13 Feb 2026 13:13:14 +0800 Subject: [PATCH 06/12] =?UTF-8?q?fix:=20=E5=9C=A8=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=B8=8A=E9=98=BB=E6=AD=A2=20iframe=20?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在移动端阅读时,iframe 的滚动会导致页面错位。通过监听滚动事件并强制重置滚动位置来确保阅读器界面稳定。 --- apps/reader/src/components/Reader.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/reader/src/components/Reader.tsx b/apps/reader/src/components/Reader.tsx index c49d1b2e..49d3a5cc 100644 --- a/apps/reader/src/components/Reader.tsx +++ b/apps/reader/src/components/Reader.tsx @@ -337,6 +337,12 @@ function BookPane({ tab, onMouseDown }: BookPaneProps) { } }) + useEventListener(iframe, 'scroll', () => { + if (mobile && iframe && (iframe.scrollX !== 0 || iframe.scrollY !== 0)) { + iframe.scrollTo(0, 0) + } + }) + useEventListener(iframe, 'keydown', handleKeyDown(tab)) useEventListener(iframe, 'touchstart', (e) => { From c45dd0b87e11b7f0ee958091574d8be94b77be17 Mon Sep 17 00:00:00 2001 From: copy-fywyf Date: Fri, 13 Feb 2026 13:23:26 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E5=90=8C=E4=B8=8A=E6=AC=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/reader/src/components/Reader.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/reader/src/components/Reader.tsx b/apps/reader/src/components/Reader.tsx index 49d3a5cc..878beffd 100644 --- a/apps/reader/src/components/Reader.tsx +++ b/apps/reader/src/components/Reader.tsx @@ -286,6 +286,17 @@ function BookPane({ tab, onMouseDown }: BookPaneProps) { setDragEvent(e) }) + useEventListener(iframe, 'scroll', () => { + if (!iframe || !mobile) return + const el = iframe.document.scrollingElement + if (!el) return + + const { scrollLeft, clientWidth } = el + if (scrollLeft % clientWidth !== 0) { + el.scrollLeft = Math.round(scrollLeft / clientWidth) * clientWidth + } + }) + useEventListener(iframe, 'mousedown', onMouseDown) useEventListener(iframe, 'click', (e) => { @@ -337,12 +348,6 @@ function BookPane({ tab, onMouseDown }: BookPaneProps) { } }) - useEventListener(iframe, 'scroll', () => { - if (mobile && iframe && (iframe.scrollX !== 0 || iframe.scrollY !== 0)) { - iframe.scrollTo(0, 0) - } - }) - useEventListener(iframe, 'keydown', handleKeyDown(tab)) useEventListener(iframe, 'touchstart', (e) => { From 9cf1aab5b3a924125221530a82912f9ab5833d8c Mon Sep 17 00:00:00 2001 From: copy-fywyf Date: Fri, 13 Feb 2026 13:28:16 +0800 Subject: [PATCH 08/12] =?UTF-8?q?fix(reader):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=E6=BB=9A=E5=8A=A8=E6=97=B6=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=81=8F=E7=A7=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加对 selectionchange 事件的监听,以处理文本选择导致的滚动问题。同时引入容差机制处理亚像素滚动差异,确保页面在移动设备上能正确对齐到整页宽度。 --- apps/reader/src/components/Reader.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/reader/src/components/Reader.tsx b/apps/reader/src/components/Reader.tsx index 878beffd..7c9c3718 100644 --- a/apps/reader/src/components/Reader.tsx +++ b/apps/reader/src/components/Reader.tsx @@ -286,16 +286,21 @@ function BookPane({ tab, onMouseDown }: BookPaneProps) { setDragEvent(e) }) - useEventListener(iframe, 'scroll', () => { + const handleScroll = () => { if (!iframe || !mobile) return const el = iframe.document.scrollingElement if (!el) return const { scrollLeft, clientWidth } = el - if (scrollLeft % clientWidth !== 0) { + // Use a small tolerance for sub-pixel scrolling differences + if (Math.abs(scrollLeft % clientWidth) > 1) { el.scrollLeft = Math.round(scrollLeft / clientWidth) * clientWidth } - }) + } + + useEventListener(iframe, 'scroll', handleScroll) + // Also listen to selectionchange on document to catch selection-induced scrolling + useEventListener(iframe?.document, 'selectionchange', handleScroll) useEventListener(iframe, 'mousedown', onMouseDown) From acdcabe15d6a29009cdf60678b0f6ee26c9f184c Mon Sep 17 00:00:00 2001 From: copy-fywyf Date: Fri, 13 Feb 2026 13:42:18 +0800 Subject: [PATCH 09/12] =?UTF-8?q?fix(reader):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=E6=BB=9A=E5=8A=A8=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=B9=B6=E4=BF=AE=E5=A4=8D=E6=BA=A2=E5=87=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除BookPane组件中移动端滚动对齐的冗余逻辑,该功能已由其他机制处理。 同时在全局样式中为html和body元素添加overflow: hidden以防止不必要的滚动条出现。 --- apps/reader/src/components/Reader.tsx | 16 ---------------- apps/reader/src/styles.ts | 2 ++ 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/apps/reader/src/components/Reader.tsx b/apps/reader/src/components/Reader.tsx index 7c9c3718..c49d1b2e 100644 --- a/apps/reader/src/components/Reader.tsx +++ b/apps/reader/src/components/Reader.tsx @@ -286,22 +286,6 @@ function BookPane({ tab, onMouseDown }: BookPaneProps) { setDragEvent(e) }) - const handleScroll = () => { - if (!iframe || !mobile) return - const el = iframe.document.scrollingElement - if (!el) return - - const { scrollLeft, clientWidth } = el - // Use a small tolerance for sub-pixel scrolling differences - if (Math.abs(scrollLeft % clientWidth) > 1) { - el.scrollLeft = Math.round(scrollLeft / clientWidth) * clientWidth - } - } - - useEventListener(iframe, 'scroll', handleScroll) - // Also listen to selectionchange on document to catch selection-induced scrolling - useEventListener(iframe?.document, 'selectionchange', handleScroll) - useEventListener(iframe, 'mousedown', onMouseDown) useEventListener(iframe, 'click', (e) => { diff --git a/apps/reader/src/styles.ts b/apps/reader/src/styles.ts index 59bd0be4..26112694 100644 --- a/apps/reader/src/styles.ts +++ b/apps/reader/src/styles.ts @@ -9,9 +9,11 @@ export const activeClass = 'bg-primary70' export const defaultStyle = { html: { padding: '0 !important', + overflow: 'hidden !important', }, body: { background: 'transparent', + overflow: 'hidden !important', }, 'a:any-link': { color: '#3b82f6 !important', From 1996fda39eaa6ced09f01d9bd327f6647da6ef76 Mon Sep 17 00:00:00 2001 From: copy-fywyf Date: Fri, 13 Feb 2026 13:58:46 +0800 Subject: [PATCH 10/12] =?UTF-8?q?fix(reader):=20=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF=E4=BA=A4=E4=BA=92=E6=97=B6=E9=94=81=E5=AE=9Aiframe?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E4=BD=8D=E7=BD=AE=E9=98=B2=E6=AD=A2=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=BB=9A=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在移动端设备上,当用户在iframe内进行选择文本等交互操作时,浏览器会自动滚动以保持选择区域可见,这会干扰阅读体验。通过监听touchstart/mousedown事件来锁定当前滚动位置,并在scroll和selectionchange事件中强制保持该位置,直到交互结束(mouseup/touchend)。这确保了用户交互期间视图的稳定性。 --- apps/reader/src/components/Reader.tsx | 39 ++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/apps/reader/src/components/Reader.tsx b/apps/reader/src/components/Reader.tsx index c49d1b2e..c4a21eea 100644 --- a/apps/reader/src/components/Reader.tsx +++ b/apps/reader/src/components/Reader.tsx @@ -286,7 +286,44 @@ function BookPane({ tab, onMouseDown }: BookPaneProps) { setDragEvent(e) }) - useEventListener(iframe, 'mousedown', onMouseDown) + // Lock scroll position during user interaction to prevent selection auto-scroll + const lockedScrollPos = useRef<{ left: number; top: number } | null>(null) + + const lockScroll = () => { + if (!iframe || !mobile) return + const el = iframe.document.scrollingElement + if (!el) return + lockedScrollPos.current = { left: el.scrollLeft, top: el.scrollTop } + } + + const unlockScroll = () => { + lockedScrollPos.current = null + } + + useEventListener(iframe, 'mousedown', () => { + lockScroll() + onMouseDown() + }) + useEventListener(iframe, 'touchstart', lockScroll) + useEventListener(iframe, 'mouseup', unlockScroll) + useEventListener(iframe, 'touchend', unlockScroll) + + const handleScroll = () => { + if (!lockedScrollPos.current || !iframe || !mobile) return + const el = iframe.document.scrollingElement + if (!el) return + + const { left, top } = lockedScrollPos.current + if ( + Math.abs(el.scrollLeft - left) > 1 || + Math.abs(el.scrollTop - top) > 1 + ) { + el.scrollTo(left, top) + } + } + + useEventListener(iframe, 'scroll', handleScroll) + useEventListener(iframe?.document, 'selectionchange', handleScroll) useEventListener(iframe, 'click', (e) => { // https://developer.chrome.com/blog/tap-to-search From e85f3e12b37c496ade5b7ca84822eee8b30313cf Mon Sep 17 00:00:00 2001 From: copy-fywyf Date: Fri, 13 Feb 2026 14:01:02 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E9=81=97=E6=BC=8F=E7=9A=84=E6=9B=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/reader/src/styles.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/reader/src/styles.ts b/apps/reader/src/styles.ts index 26112694..59bd0be4 100644 --- a/apps/reader/src/styles.ts +++ b/apps/reader/src/styles.ts @@ -9,11 +9,9 @@ export const activeClass = 'bg-primary70' export const defaultStyle = { html: { padding: '0 !important', - overflow: 'hidden !important', }, body: { background: 'transparent', - overflow: 'hidden !important', }, 'a:any-link': { color: '#3b82f6 !important', From 0b1c4950982799f552a1db1ce6a2a8dfb14e7a00 Mon Sep 17 00:00:00 2001 From: flyswxf Date: Tue, 17 Feb 2026 17:38:05 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E4=B9=8B=E5=89=8D?= =?UTF-8?q?=E7=9A=84=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/reader/src/components/Reader.tsx | 41 ++------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/apps/reader/src/components/Reader.tsx b/apps/reader/src/components/Reader.tsx index c4a21eea..dc21c0dd 100644 --- a/apps/reader/src/components/Reader.tsx +++ b/apps/reader/src/components/Reader.tsx @@ -286,44 +286,7 @@ function BookPane({ tab, onMouseDown }: BookPaneProps) { setDragEvent(e) }) - // Lock scroll position during user interaction to prevent selection auto-scroll - const lockedScrollPos = useRef<{ left: number; top: number } | null>(null) - - const lockScroll = () => { - if (!iframe || !mobile) return - const el = iframe.document.scrollingElement - if (!el) return - lockedScrollPos.current = { left: el.scrollLeft, top: el.scrollTop } - } - - const unlockScroll = () => { - lockedScrollPos.current = null - } - - useEventListener(iframe, 'mousedown', () => { - lockScroll() - onMouseDown() - }) - useEventListener(iframe, 'touchstart', lockScroll) - useEventListener(iframe, 'mouseup', unlockScroll) - useEventListener(iframe, 'touchend', unlockScroll) - - const handleScroll = () => { - if (!lockedScrollPos.current || !iframe || !mobile) return - const el = iframe.document.scrollingElement - if (!el) return - - const { left, top } = lockedScrollPos.current - if ( - Math.abs(el.scrollLeft - left) > 1 || - Math.abs(el.scrollTop - top) > 1 - ) { - el.scrollTo(left, top) - } - } - - useEventListener(iframe, 'scroll', handleScroll) - useEventListener(iframe?.document, 'selectionchange', handleScroll) + useEventListener(iframe, 'mousedown', onMouseDown) useEventListener(iframe, 'click', (e) => { // https://developer.chrome.com/blog/tap-to-search @@ -534,4 +497,4 @@ const Bar: React.FC = ({ className, ...props }) => { {...props} >
) -} +} \ No newline at end of file