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
0af1923d
Commit
0af1923d
authored
Apr 10, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
parent
e46903f7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
16 deletions
+38
-16
stage-tag.tsx
src/pages/main/components/scene/stage-tag.tsx
+38
-16
No files found.
src/pages/main/components/scene/stage-tag.tsx
View file @
0af1923d
...
@@ -4,11 +4,21 @@ import assets from '@/assets/oss/assets-round'
...
@@ -4,11 +4,21 @@ import assets from '@/assets/oss/assets-round'
import
{
useFocus
}
from
'@/hooks'
import
{
useFocus
}
from
'@/hooks'
import
{
import
{
usePageScroll
,
createIntersectionObserver
,
getCurrentInstance
,
usePageScroll
,
createIntersectionObserver
,
getCurrentInstance
,
getMenuButtonBoundingClientRect
,
IntersectionObserver
,
nextTick
getMenuButtonBoundingClientRect
,
IntersectionObserver
,
nextTick
,
createInnerAudioContext
}
from
'@tarojs/taro'
}
from
'@tarojs/taro'
import
{
palyAudio
}
from
'@/utils/play-audio'
import
audio
from
'@/assets/oss/assets-audio'
import
audio
from
'@/assets/oss/assets-audio'
function
palyAudio
(
src
:
string
)
{
// @ts-ignore
const
innerAudioContext
=
createInnerAudioContext
({
useWebAudioImplement
:
true
})
innerAudioContext
.
src
=
src
innerAudioContext
.
play
()
innerAudioContext
.
onEnded
=
()
=>
{
innerAudioContext
.
destroy
()
}
}
type
StageTagProps
=
{
type
StageTagProps
=
{
url
?:
string
;
url
?:
string
;
className
:
string
;
className
:
string
;
...
@@ -16,11 +26,28 @@ type StageTagProps = {
...
@@ -16,11 +26,28 @@ type StageTagProps = {
ready
:
boolean
;
ready
:
boolean
;
}
}
const
animationQueue
:
(()
=>
void
)[]
=
[]
let
isAnimating
=
false
function
flushQueue
()
{
if
(
isAnimating
)
{
return
}
const
fn
=
animationQueue
.
shift
()
if
(
fn
)
{
isAnimating
=
true
setTimeout
(()
=>
{
fn
()
isAnimating
=
false
flushQueue
()
},
300
)
}
}
const
StageTag
=
(
props
:
StageTagProps
)
=>
{
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
)
...
@@ -28,10 +55,6 @@ const StageTag = (props: StageTagProps) => {
...
@@ -28,10 +55,6 @@ 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
(()
=>
{
...
@@ -41,26 +64,25 @@ const StageTag = (props: StageTagProps) => {
...
@@ -41,26 +64,25 @@ const StageTag = (props: StageTagProps) => {
const
navVal
=
nav
.
current
const
navVal
=
nav
.
current
// @ts-ignore
// @ts-ignore
observer
=
createIntersectionObserver
()
observer
=
createIntersectionObserver
()
let
timer
:
NodeJS
.
Timeout
|
null
=
null
if
(
url
)
{
if
(
url
)
{
observer
observer
.
relativeToViewport
({
bottom
:
0
,
top
:
-
navVal
.
height
-
navVal
.
top
-
5
-
50
})
.
relativeToViewport
({
bottom
:
0
,
top
:
-
navVal
.
height
-
navVal
.
top
-
5
-
50
})
.
observe
(
`#
${
uid
}
`
,
({
intersectionRatio
})
=>
{
.
observe
(
`#
${
uid
}
`
,
({
intersectionRatio
})
=>
{
if
(
intersectionRatio
>
0
)
{
if
(
intersectionRatio
>
0
)
{
if
(
isAnimated
)
return
animationQueue
.
push
(()
=>
{
if
(
timer
)
{
clearTimeout
(
timer
)
}
timer
=
setTimeout
(()
=>
{
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
},
{
opacity
:
1
,
translateY
:
-
20
,
scale
:
[
1.5
,
1.5
],
offset
:
0.75
},
{
opacity
:
1
,
translateY
:
-
20
,
scale
:
[
1.5
,
1.5
],
offset
:
0.75
},
{
opacity
:
1
,
translateY
:
0
,
scale
:
[
1
,
1
]
},
{
opacity
:
1
,
translateY
:
0
,
scale
:
[
1
,
1
]
},
],
1000
,
()
=>
{})
],
1000
,
()
=>
{})
},
500
)
if
(
observer
)
{
observer
.
disconnect
()
observer
=
null
}
})
flushQueue
()
}
}
})
})
}
}
...
@@ -75,7 +97,7 @@ const StageTag = (props: StageTagProps) => {
...
@@ -75,7 +97,7 @@ const StageTag = (props: StageTagProps) => {
observer
=
null
observer
=
null
}
}
}
}
},
[
uid
,
ready
,
url
,
page
,
isFocus
,
isAnimated
])
},
[
uid
,
ready
,
url
,
page
,
isFocus
])
if
(
!
ready
)
{
if
(
!
ready
)
{
return
null
return
null
...
...
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