Skip to content

Commit 4d513cf

Browse files
Retsommclaude
andcommitted
fix(pwa): safe-area for Library + fix annotation-triggers-pageflip
- Library: add env(safe-area-inset-top) to both empty-state and main header so content isn't hidden behind iOS status bar - Reader iframe touchend: add isSelectingRef.current guard before swipe page-turn — previously only currentSel check was present; on iOS the selection can be cleared before touchend fires, causing long-press annotation attempts to trigger page turn Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0483b96 commit 4d513cf

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

pwa/src/page/Library.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const Library = ({ records, getCoverDataUrl, onAddBooks, onOpenBook, onRemoveBoo
6868
if (records.length === 0) {
6969
return (
7070
<div className="flex flex-col min-h-screen" style={{ background: paperBg, color: inkCol }}>
71-
<div className="flex items-center justify-between px-4 py-3">
71+
<div className="flex items-center justify-between px-4 py-3" style={{ paddingTop: 'max(env(safe-area-inset-top), 12px)' }}>
7272
<div className="flex-1" />
7373
<button className="p-2 rounded-full transition" style={{ color: ink3Col }} onClick={onToggleDark}>
7474
{darkMode ? <IconSun /> : <IconMoon />}
@@ -112,7 +112,7 @@ const Library = ({ records, getCoverDataUrl, onAddBooks, onOpenBook, onRemoveBoo
112112
<div className="flex flex-col min-h-screen" style={{ background: paperBg, color: inkCol }}>
113113

114114
{/* ── Header ── */}
115-
<div style={{ borderBottom: `1px solid ${borderCol}`, background: paperBg }}>
115+
<div style={{ borderBottom: `1px solid ${borderCol}`, background: paperBg, paddingTop: 'env(safe-area-inset-top)' }}>
116116
{/* 第一行:Logo + 標題 + 操作按鈕 */}
117117
<div className="flex items-center gap-2 px-4 pt-3 pb-2">
118118
<div ref={logoMenuRef} style={{ position: 'relative', flexShrink: 0 }}>

pwa/src/page/Reader.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ const Reader = ({ bookPath, bookId, bookRecord, getCoverDataUrl, onBack, darkMod
511511
const dy = e.changedTouches[0].clientY - start.y
512512
swipeStartRef.current = null
513513
if (Math.abs(dx) < 50 || Math.abs(dx) < Math.abs(dy) * 1.5) return
514-
// 有實際選取範圍(長按選字)時不翻頁
514+
// 正在選取文字或有選取範圍時不翻頁
515+
if (isSelectingRef.current) return
515516
const currentSel = doc.defaultView?.getSelection()
516517
if (currentSel && !currentSel.isCollapsed && currentSel.rangeCount > 0) return
517518
const isRtl = readingDirectionRef.current === 'rtl'

0 commit comments

Comments
 (0)