Commit 37d4ffa2 authored by hewenhao's avatar hewenhao

feat: type

parent eba4c7b1
import { Image } from '@tarojs/components'
import { useEffect, useRef, useMemo } from 'react'
import { usePageScroll, createIntersectionObserver, getCurrentInstance, getMenuButtonBoundingClientRect } from '@tarojs/taro'
import { usePageScroll, createIntersectionObserver, getCurrentInstance, getMenuButtonBoundingClientRect, IntersectionObserver } from '@tarojs/taro'
type RoundTagProps = {
url: string;
......@@ -22,11 +22,14 @@ const RoundTag = (props: RoundTagProps) => {
const uid = useMemo(() => `tag_${id}`, [id])
useEffect(() => {
let observer
let observer: IntersectionObserver | null = null
if (ready) {
lastEffectedScroll.current = scrollRef.current
const navVal = nav.current
observer = (createIntersectionObserver as any)().relativeToViewport({ bottom: 0, top: -navVal.height - navVal.top - 5 })
// @ts-ignore
observer = createIntersectionObserver()
observer
.relativeToViewport({ bottom: 0, top: -navVal.height - navVal.top - 5 })
.observe(`#${uid}`, ({ intersectionRatio }) => {
const show = intersectionRatio > 0
......
......@@ -23,7 +23,10 @@ const ShortCut = (props: ShortCutProps) => {
useEffect(() => {
lastEffectedScroll.current = scrollRef.current
let observer = (createIntersectionObserver as any)().relativeToViewport({ bottom: 0 })
// @ts-ignore
let observer = createIntersectionObserver()
observer
.relativeToViewport({ bottom: 0 })
.observe(`#${CurrentRoundId}`, ({ intersectionRatio }) => {
const show = intersectionRatio > 0
setIsShow(show)
......@@ -36,7 +39,7 @@ const ShortCut = (props: ShortCutProps) => {
return () => {
if (observer) {
observer.disconnect()
observer = null
observer = null!
}
}
}, [])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment