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 ( return (
<> <>
{seo && <Seo sub={sub} item={item} user={user} />} {seo && <Seo sub={sub} item={item} user={user} />}
<PullToRefresh android> {/* android prop if true disables its native PTR */} <Navigation sub={sub} />
<Navigation sub={sub} /> {contain
{contain ? (
? ( <Container as={PullToRefresh} className={`px-sm-0 ${styles.contain}`}>
<Container as='main' className={`px-sm-0 ${styles.contain}`}> {children}
{children} </Container>
</Container> )
) : children}
: children} {footer && <Footer links={footerLinks} />}
{footer && <Footer links={footerLinks} />} <NavFooter sub={sub} />
<NavFooter sub={sub} />
</PullToRefresh>
</> </>
) )
} }

View File

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