Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GeekLearnMathWeapp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
frontend
GeekLearnMathWeapp
Commits
583aed3c
Commit
583aed3c
authored
Apr 13, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 首页优化
parent
8b8e29b4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
13 deletions
+40
-13
stage-tag.tsx
src/pages/main/components/scene/stage-tag.tsx
+23
-13
stage.module.scss
src/pages/main/components/scene/stage.module.scss
+17
-0
No files found.
src/pages/main/components/scene/stage-tag.tsx
View file @
583aed3c
...
...
@@ -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,17 +78,8 @@ const StageTag = (props: StageTagProps) => {
useEffect
(()
=>
{
let
observer
:
IntersectionObserver
|
null
=
null
if
(
isAnimated
)
return
const
fn
=
()
=>
{
if
(
ready
&&
isFocus
)
{
const
navVal
=
nav
.
current
// @ts-ignore
observer
=
createIntersectionObserver
()
if
(
url
)
{
observer
.
relativeToViewport
({
bottom
:
0
,
top
:
-
navVal
.
height
-
navVal
.
top
-
5
-
50
})
.
observe
(
`#
${
uid
}
`
,
({
intersectionRatio
})
=>
{
if
(
intersectionRatio
>
0
)
{
animationQueue
.
push
(()
=>
{
const
animateFn
=
()
=>
{
palyAudio
(
audio
[
'蹦蹦top出现首页.wav'
].
u
)
setIsAnimated
(
true
)
page
?.
animate
?.(
`#
${
uid
}
`
,
[
...
...
@@ -99,8 +92,25 @@ const StageTag = (props: StageTagProps) => {
observer
.
disconnect
()
observer
=
null
}
})
}
const
fn
=
()
=>
{
if
(
ready
&&
isFocus
)
{
const
navVal
=
nav
.
current
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
(
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=
{
className
s
(
className
,
styles
.
top_bg
)
}
></
Image
>
</>
)
}
...
...
src/pages/main/components/scene/stage.module.scss
View file @
583aed3c
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment