Commit 4cf29630 authored by hewenhao's avatar hewenhao

feat: update

parent e908bd76
......@@ -48,6 +48,7 @@ const StageTag = (props: StageTagProps) => {
const page = useMemo(() => getCurrentInstance().page, [])
const nav = useRef(getMenuButtonBoundingClientRect())
const { url, className, id, ready } = props
const [isAnimated, setIsAnimated] = useState(false)
const isFocus = useFocus()
const scrollRef = useRef(0)
......@@ -55,10 +56,15 @@ const StageTag = (props: StageTagProps) => {
scrollRef.current = payload.scrollTop
})
useEffect(() => {
setIsAnimated(false)
}, [url])
const uid = useMemo(() => `tag_${id}`, [id])
useEffect(() => {
let observer: IntersectionObserver | null = null
if (isAnimated) return
const fn = () => {
if (ready && isFocus) {
const navVal = nav.current
......@@ -71,6 +77,7 @@ const StageTag = (props: StageTagProps) => {
if (intersectionRatio > 0) {
animationQueue.push(() => {
palyAudio(audio['蹦蹦top出现首页.wav'].u)
setIsAnimated(true)
page?.animate?.(`#${uid}`, [
{ opacity: 0, translateY: 50, scale: [1, 1] },
{ opacity: 1, translateY: -20, scale: [1.5, 1.5], offset: 0.5 },
......@@ -97,7 +104,7 @@ const StageTag = (props: StageTagProps) => {
observer = null
}
}
}, [uid, ready, url, page, isFocus])
}, [uid, ready, url, page, isFocus, isAnimated])
if (!ready) {
return 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