Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
Z
zh_zcb-ems
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
chen.yiwen
zh_zcb-ems
Commits
3fc0af6e
Commit
3fc0af6e
authored
Sep 01, 2022
by
wu.hui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 滚动数字更改
parent
cde98600
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
23 deletions
+26
-23
stat-bar.css
src/css/stat-bar.css
+5
-5
digital-bg.png
src/images/digital-bg.png
+0
-0
index.js
src/js/index.js
+17
-14
stat-bar.less
src/less/stat-bar.less
+4
-4
No files found.
src/css/stat-bar.css
View file @
3fc0af6e
...
@@ -48,9 +48,9 @@
...
@@ -48,9 +48,9 @@
margin-left
:
10px
;
margin-left
:
10px
;
}
}
.stat-bar
.stat-item
.scroll-num
{
.stat-bar
.stat-item
.scroll-num
{
width
:
var
(
--width
,
47
px
);
width
:
var
(
--width
,
39
px
);
height
:
var
(
--height
,
5
9
px
);
height
:
var
(
--height
,
5
0
px
);
line-height
:
var
(
--height
,
5
9
px
);
line-height
:
var
(
--height
,
5
0
px
);
text-align
:
center
;
text-align
:
center
;
font-size
:
41px
;
font-size
:
41px
;
color
:
#01fff6
;
color
:
#01fff6
;
...
@@ -67,8 +67,8 @@
...
@@ -67,8 +67,8 @@
font-family
:
'Source Han Sans CN'
;
font-family
:
'Source Han Sans CN'
;
}
}
.stat-bar
.animate
{
.stat-bar
.animate
{
-webkit-animation
:
move
1.6s
linear
infinite
,
bounce-in-down
1s
calc
(
var
(
--delay
)
*
1s
)
forwards
;
-webkit-animation
:
move
calc
(
var
(
--speed
)
*
1s
)
linear
infinite
,
bounce-in-down
1s
calc
(
var
(
--delay
)
*
1s
)
forwards
;
animation
:
move
1.6s
linear
infinite
,
bounce-in-down
1s
calc
(
var
(
--delay
)
*
1s
)
forwards
;
animation
:
move
calc
(
var
(
--speed
)
*
1s
)
linear
infinite
,
bounce-in-down
1s
calc
(
var
(
--delay
)
*
1s
)
forwards
;
}
}
.stat-bar
.init
{
.stat-bar
.init
{
-webkit-transform
:
translateY
(
calc
(
var
(
--i
)
*
-9.09%
));
-webkit-transform
:
translateY
(
calc
(
var
(
--i
)
*
-9.09%
));
...
...
src/images/digital-bg.png
View replaced file @
cde98600
View file @
3fc0af6e
2.32 KB
|
W:
|
H:
1.1 KB
|
W:
|
H:
2-up
Swipe
Onion skin
src/js/index.js
View file @
3fc0af6e
...
@@ -219,18 +219,18 @@ const lineChartOption = (xData, yData, interval) => {
...
@@ -219,18 +219,18 @@ const lineChartOption = (xData, yData, interval) => {
}
}
// 创建一组数字
// 创建一组数字
function
createMultiSrollNum
(
box
,
num
String
,
width
,
height
,
delay
)
{
function
createMultiSrollNum
(
box
,
num
Arr
,
width
,
height
,
delays
,
speeds
)
{
box
.
style
.
setProperty
(
'--width'
,
width
+
'px'
)
box
.
style
.
setProperty
(
'--width'
,
width
+
'px'
)
box
.
style
.
setProperty
(
'--height'
,
height
+
'px'
)
box
.
style
.
setProperty
(
'--height'
,
height
+
'px'
)
const
docFrag
=
document
.
createDocumentFragment
()
const
docFrag
=
document
.
createDocumentFragment
()
num
String
.
split
(
''
)
.
forEach
((
num
,
i
)
=>
{
num
Arr
.
forEach
((
num
,
i
)
=>
{
docFrag
.
appendChild
(
createSrollNum
(
num
,
delay
+
i
*
0.2
))
docFrag
.
appendChild
(
createSrollNum
(
num
,
delay
s
[
i
],
speeds
[
i
]
))
})
})
box
.
appendChild
(
docFrag
)
box
.
appendChild
(
docFrag
)
}
}
// 创建单个数字
// 创建单个数字
function
createSrollNum
(
num
,
delay
)
{
function
createSrollNum
(
num
,
delay
,
speed
)
{
const
scrollNumNode
=
document
.
createElement
(
'div'
)
const
scrollNumNode
=
document
.
createElement
(
'div'
)
scrollNumNode
.
className
=
'scroll-num'
scrollNumNode
.
className
=
'scroll-num'
scrollNumNode
.
innerHTML
=
`<ul class="scroll-ul">
scrollNumNode
.
innerHTML
=
`<ul class="scroll-ul">
...
@@ -249,24 +249,26 @@ function createSrollNum(num, delay) {
...
@@ -249,24 +249,26 @@ function createSrollNum(num, delay) {
scrollNumNode
.
style
.
setProperty
(
'--i'
,
num
)
scrollNumNode
.
style
.
setProperty
(
'--i'
,
num
)
scrollNumNode
.
style
.
setProperty
(
'--delay'
,
delay
)
scrollNumNode
.
style
.
setProperty
(
'--delay'
,
delay
)
scrollNumNode
.
style
.
setProperty
(
'--speed'
,
speed
)
const
ulNode
=
scrollNumNode
.
childNodes
[
0
]
const
ulNode
=
scrollNumNode
.
childNodes
[
0
]
ulNode
.
classList
.
add
(
'init'
)
ulNode
.
classList
.
add
(
'init'
)
return
scrollNumNode
return
scrollNumNode
}
}
function
addDigitAnimate
()
{
function
addDigitAnimate
(
delays
,
numArr
)
{
const
scrollUl
=
document
.
getElementsByClassName
(
'scroll-ul'
)
const
scrollUl
=
document
.
getElementsByClassName
(
'scroll-ul'
)
for
(
const
ulNode
of
scrollUl
)
{
for
(
let
i
=
0
;
i
<
scrollUl
.
length
;
i
++
)
{
const
ulNode
=
scrollUl
[
i
]
ulNode
.
classList
.
add
(
'animate'
)
ulNode
.
classList
.
add
(
'animate'
)
if
(
isSafari
||
isWeChat
)
{
if
(
isSafari
||
isWeChat
)
{
let
timer
=
setTimeout
(()
=>
{
let
timer
=
setTimeout
(()
=>
{
ulNode
.
setAttribute
(
ulNode
.
setAttribute
(
'style'
,
'style'
,
'animation: none;transform: translateY('
+
num
*
-
9.09
+
'%)'
'animation: none;transform: translateY('
+
num
Arr
[
i
]
*
-
9.09
+
'%)'
)
)
timer
=
null
timer
=
null
},
delay
*
1000
)
},
delay
s
[
i
]
*
1000
)
}
}
}
}
}
}
...
@@ -388,13 +390,14 @@ window.onload = () => {
...
@@ -388,13 +390,14 @@ window.onload = () => {
)
)
// 数据统计数字滚动
// 数据统计数字滚动
const
width
=
47
const
width
=
39
const
height
=
59
const
height
=
50
const
delay
=
1.4
const
delays
=
[
3
,
4
,
5
,
6
,
7
]
// 滚动多少秒停止,设置一样就一起停
const
speeds
=
[
2
,
2.5
,
3
,
3.5
,
4
]
// 滚动速率,每个数字滚动快慢不一样
const
scrollBox
=
document
.
getElementsByClassName
(
'scroll-box'
)
const
scrollBox
=
document
.
getElementsByClassName
(
'scroll-box'
)
;[
'35345'
,
'83460'
,
'36765'
,
'36465'
].
forEach
((
numStr
,
i
)
=>
{
;[
'35345'
,
'83460'
,
'36765'
,
'36465'
].
forEach
((
numStr
,
i
)
=>
{
createMultiSrollNum
(
scrollBox
[
i
],
numStr
,
width
,
height
,
delay
)
const
numArr
=
numStr
.
split
(
''
)
createMultiSrollNum
(
scrollBox
[
i
],
numArr
,
width
,
height
,
delays
,
speeds
)
addDigitAnimate
(
delays
,
numArr
)
})
})
// addDigitAnimate()
}
}
src/less/stat-bar.less
View file @
3fc0af6e
...
@@ -36,9 +36,9 @@
...
@@ -36,9 +36,9 @@
margin-left: 10px;
margin-left: 10px;
}
}
.scroll-num {
.scroll-num {
width: var(--width,
47
px);
width: var(--width,
39
px);
height: var(--height, 5
9
px);
height: var(--height, 5
0
px);
line-height: var(--height, 5
9
px);
line-height: var(--height, 5
0
px);
text-align: center;
text-align: center;
font-size: 41px;
font-size: 41px;
color: #01fff6;
color: #01fff6;
...
@@ -61,7 +61,7 @@
...
@@ -61,7 +61,7 @@
// }
// }
.animate {
.animate {
animation: move
1.6s
linear infinite,
animation: move
calc(var(--speed) * 1s)
linear infinite,
bounce-in-down 1s calc(var(--delay) * 1s) forwards;
bounce-in-down 1s calc(var(--delay) * 1s) forwards;
}
}
.init {
.init {
...
...
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