fix: clean up home top mask measurement

This commit is contained in:
2026-08-08 01:45:17 +08:00
parent fc4b8f7e3d
commit 30eeb8611a
+12 -2
View File
@@ -90,10 +90,15 @@ export default function Index() {
}
useEffect(() => {
let cancelled = false
let measureTimer: ReturnType<typeof setTimeout> | null = null
const measureTitle = () => {
if (cancelled) return
Taro.createSelectorQuery()
.select('.home-header')
.boundingClientRect((rect: { top?: number; bottom?: number; height?: number } | null) => {
.boundingClientRect((rect: any) => {
if (cancelled) return
if (!rect || typeof rect.bottom !== 'number' || typeof rect.height !== 'number') {
const fallbackRange = Math.max(48, safe.headerPaddingTop * 0.45)
titleMetricsRef.current = {
@@ -113,10 +118,15 @@ export default function Index() {
}
Taro.nextTick(() => {
setTimeout(measureTitle, 80)
if (cancelled) return
measureTimer = setTimeout(measureTitle, 80)
})
return () => {
cancelled = true
if (measureTimer !== null) {
clearTimeout(measureTimer)
}
if (scrollFrameRef.current !== null) {
clearTimeout(scrollFrameRef.current)
}