Commit 37e157cf authored by hewenhao's avatar hewenhao

feat: update

parent 4791f652
import { Image } from '@tarojs/components' import { Image } from '@tarojs/components'
import { useEffect, useState, useRef, useMemo } from 'react' import { useEffect, useRef, useMemo } from 'react'
import { usePageScroll, createIntersectionObserver, getCurrentInstance, getMenuButtonBoundingClientRect } from '@tarojs/taro' import { usePageScroll, createIntersectionObserver, getCurrentInstance, getMenuButtonBoundingClientRect } from '@tarojs/taro'
type RoundTagProps = { type RoundTagProps = {
...@@ -11,7 +11,6 @@ type RoundTagProps = { ...@@ -11,7 +11,6 @@ type RoundTagProps = {
const RoundTag = (props: RoundTagProps) => { const RoundTag = (props: RoundTagProps) => {
const nav = useRef(getMenuButtonBoundingClientRect()) const nav = useRef(getMenuButtonBoundingClientRect())
const page = useMemo(() => getCurrentInstance().page, [])
const { url, className, id, ready } = props const { url, className, id, ready } = props
const scrollRef = useRef(0) const scrollRef = useRef(0)
const lastEffectedScroll = useRef(0) const lastEffectedScroll = useRef(0)
...@@ -32,6 +31,7 @@ const RoundTag = (props: RoundTagProps) => { ...@@ -32,6 +31,7 @@ const RoundTag = (props: RoundTagProps) => {
const show = intersectionRatio > 0 const show = intersectionRatio > 0
const isDown = lastEffectedScroll.current < scrollRef.current const isDown = lastEffectedScroll.current < scrollRef.current
const page = getCurrentInstance().page
if (show && !isDown) { if (show && !isDown) {
page?.animate?.(`#${uid}`, [ page?.animate?.(`#${uid}`, [
...@@ -54,7 +54,7 @@ const RoundTag = (props: RoundTagProps) => { ...@@ -54,7 +54,7 @@ const RoundTag = (props: RoundTagProps) => {
observer = null observer = null
} }
} }
}, [uid, ready, page]) }, [uid, ready])
return ( return (
<Image src={url} className={className} id={uid}></Image> <Image src={url} className={className} id={uid}></Image>
......
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