Commit 4cf29630 authored by hewenhao's avatar hewenhao

feat: update

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