Commit 583aed3c authored by hewenhao's avatar hewenhao

feat: 首页优化

parent 8b8e29b4
......@@ -2,12 +2,14 @@ import { Image } from '@tarojs/components'
import { useEffect, useRef, useMemo, useState } from 'react'
import assets from '@/assets/oss/assets-round'
import { useFocus } from '@/hooks'
import classNames from 'classnames'
import {
usePageScroll, createIntersectionObserver, getCurrentInstance,
getMenuButtonBoundingClientRect, IntersectionObserver, nextTick,
createInnerAudioContext, onAppHide, onAppShow
} from '@tarojs/taro'
import audio from '@/assets/oss/assets-audio'
import styles from './stage.module.scss'
let isHide = false
......@@ -76,31 +78,39 @@ const StageTag = (props: StageTagProps) => {
useEffect(() => {
let observer: IntersectionObserver | null = null
if (isAnimated) return
const animateFn = () => {
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 },
{ opacity: 1, translateY: -20, scale: [1.5, 1.5], offset: 0.75 },
{ opacity: 1, translateY: 0, scale: [1, 1] },
], 1000, () => {})
if (observer) {
observer.disconnect()
observer = null
}
}
const fn = () => {
if (ready && isFocus) {
const navVal = nav.current
// @ts-ignore
observer = createIntersectionObserver()
if (url) {
// @ts-ignore
observer = createIntersectionObserver()
observer
.relativeToViewport({ bottom: 0, top: -navVal.height - navVal.top - 5 - 50 })
.observe(`#${uid}`, ({ intersectionRatio }) => {
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 },
{ opacity: 1, translateY: -20, scale: [1.5, 1.5], offset: 0.75 },
{ opacity: 1, translateY: 0, scale: [1, 1] },
], 1000, () => {})
if (observer) {
observer.disconnect()
observer = null
}
})
animationQueue.push(animateFn)
flushQueue()
} else if (!isAnimated) { // 隐藏了 还没有显示动画 就移除队列
const index = animationQueue.indexOf(animateFn)
if (index !== -1) {
animationQueue.splice(index, 1)
}
}
})
}
......@@ -126,7 +136,7 @@ const StageTag = (props: StageTagProps) => {
{url && (
<Image src={url} className={className} style={{ opacity: 0 }} id={uid}></Image>
)}
<Image src={assets['top-bg.png'].u} className={className}></Image>
<Image src={assets['top-bg.png'].u} className={classNames(className, styles.top_bg)}></Image>
</>
)
}
......
......@@ -50,6 +50,23 @@
height: 28px;
}
.top_bg {
animation-name: fadeIn;
animation-duration: 1s;
animation-timing-function: ease-out;
animation-fill-mode: backwards;
animation-iteration-count: 1;
}
@keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.uparrow {
position: absolute;
z-index: 3;
......
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