fix ptr interfering with layout container

This commit is contained in:
k00b 2024-11-18 17:33:45 -06:00
parent 570c842934
commit 5d71e57839
2 changed files with 22 additions and 25 deletions

View File

@ -15,18 +15,16 @@ export default function Layout ({
return (
<>
{seo && <Seo sub={sub} item={item} user={user} />}
<PullToRefresh android> {/* android prop if true disables its native PTR */}
<Navigation sub={sub} />
{contain
? (
<Container as='main' className={`px-sm-0 ${styles.contain}`}>
{children}
</Container>
)
: children}
{footer && <Footer links={footerLinks} />}
<NavFooter sub={sub} />
</PullToRefresh>
<Navigation sub={sub} />
{contain
? (
<Container as={PullToRefresh} className={`px-sm-0 ${styles.contain}`}>
{children}
</Container>
)
: children}
{footer && <Footer links={footerLinks} />}
<NavFooter sub={sub} />
</>
)
}

View File

@ -4,7 +4,7 @@ import styles from './pull-to-refresh.module.css'
const REFRESH_THRESHOLD = 50
export default function PullToRefresh ({ children, android }) {
export default function PullToRefresh ({ children, android, className }) {
const router = useRouter()
const [pullDistance, setPullDistance] = useState(0)
const [isPWA, setIsPWA] = useState(false)
@ -68,17 +68,16 @@ export default function PullToRefresh ({ children, android }) {
}, [pullDistance])
return (
<div>
<div
onTouchStart={handleTouchStart}
onTouchMove={handleTouchMove}
onTouchEnd={handleTouchEnd}
>
<p className={`${styles.pullMessage}`} style={{ top: `${Math.max(-20, Math.min(-20 + pullDistance / 2, 5))}px` }}>
{pullMessage}
</p>
{children}
</div>
</div>
<main
className={className}
onTouchStart={handleTouchStart}
onTouchMove={handleTouchMove}
onTouchEnd={handleTouchEnd}
>
<p className={`${styles.pullMessage}`} style={{ top: `${Math.max(-20, Math.min(-20 + pullDistance / 2, 5))}px` }}>
{pullMessage}
</p>
{children}
</main>
)
}