当前位置:网站首页>Digital scrolling increases effect
Digital scrolling increases effect
2022-07-07 02:39:00 【Xiao_ Maple】
Effect demonstration
Video demo
Logical thinking
For example, the final number we want to show is 5878390 , Then the first number is from 1 Scroll to 5 stop it , The second number is from 0 Scroll to 5 Scroll to 8 stop it , The third number is from 0 Scroll to 8 Scroll to 7 stop it (9 And then 0), That is to say, each bit from left to right scrolls longer than the previous one , In this way, the number appears in turn from left to right .

Code implementation
Generate the array we need
For each digit, we need to generate the corresponding array .
this.num = '5878390'.split('');
let numArr = [];
this.num.map((item,index) => {
numArr[index] = [];
let i = 0;
// If it's not the first cycle , Add the last generated array
if(index != 0){
numArr[index] = numArr[index].concat(numArr[index - 1]);
// Assign the last value of the array to i
i = numArr[index1].pop();
}
while(i != item){
numArr[index].push(i);
i++;
// The remainder here is for i be equal to 10 Reset to 0
i = i % 10;
}
// Because the judgment is i It's not equal to item, So finally we put item Add in
numArr[index].push(item);
})
this.numArr = numArr; The resulting array should look like this 
html Code
In the code numArr[indexNum].length - 1 and index == 0 ? 0 : 33 It's all about transform: translateY(-100%); Show the content correctly , What you don't understand here can be debugged in the browser css I understand. .
<div class="nums">
<div v-for="(itemNum, indexNum) in num" :key="indexNum">
// Here, different animation times are set by the current subscript , Set the height according to the array length of the current number ,
<div
:style="{ height: numArr[indexNum].length - 1 + '00%', animationDuration: indexNum / 10 + 0.5 + 's' }">
<div v-for="(item, index) in numArr[indexNum]" :key="index"
:style="{ height: index == 0 ? 0 : 33 + 'px' }">
{
{ item }}
</div>
</div>
</div>
</div>css Code
.nums {
font-size: 26px;
font-weight: bold;
color: #FFFFFF;
line-height: 33px;
letter-spacing: 1px;
text-shadow: 0px 1px 6px #159AFF;
display: flex;
>div {
height: 33px;
overflow: hidden;
display: flex;
>div {
display: flex;
flex-direction: column-reverse;
animation: numIncrease 1s linear 1.3s;
animation-fill-mode: forwards;
transform: translateY(-100%);
>div {
height: 33px;
text-align: right;
}
}
}
}
@keyframes numIncrease {
0% {
transform: translateY(-100%);
}
100% {
transform: translateY(0%);
}
}边栏推荐
- Here comes a white paper to uncover the technology behind Clickhouse, a node with 10000 bytes!
- 6-6漏洞利用-SSH安全防御
- 测试优惠券要怎么写测试用例?
- 4 -- Xintang nuc980 mount initramfs NFS file system
- widerperson数据集转化为YOLO格式
- 牛客编程题--必刷101之双指针篇
- CSDN summer camp course project analysis
- Rethinking of investment
- How to build a 32core raspberry pie cluster from 0 to 1
- 【Node学习笔记】chokidar模块实现文件监听
猜你喜欢

Apifox, is your API interface document rolled up like this?

Linear list --- circular linked list

AWS学习笔记(一)

Wireshark installation

Detailed explanation of line segment tree (including tested code implementation)

豆瓣平均 9.x,分布式领域的 5 本神书!

Station B's June ranking list - feigua data up main growth ranking list (BiliBili platform) is released!

This week's hot open source project!

如何从0到1构建32Core树莓派集群

3 -- Xintang nuc980 kernel supports JFFS2, JFFS2 file system production, kernel mount JFFS2, uboot network port settings, and uboot supports TFTP
随机推荐
Linear list --- circular linked list
unity中跟随鼠标浮动的面板,并可以自适应文字内容的大小
如何从0到1构建32Core树莓派集群
Have fun | latest progress of "spacecraft program" activities
The so-called consumer Internet only matches and connects industry information, and does not change the industry itself
KYSL 海康摄像头 8247 h9 isapi测试
写作系列之contribution
Statistics of radar data in nuscenes data set
3 -- Xintang nuc980 kernel supports JFFS2, JFFS2 file system production, kernel mount JFFS2, uboot network port settings, and uboot supports TFTP
Leetcode:minimum_ depth_ of_ binary_ Tree solutions
纽约大学 CITIES 研究中心招聘理学硕士和博士后
所谓的消费互联网仅仅只是做行业信息的撮合和对接,并不改变产业本身
The empirical asset pricing package (EAP) can be installed through pypi
【Node学习笔记】chokidar模块实现文件监听
Ali yunyili: how does yunyuansheng solve the problem of reducing costs and improving efficiency?
本周 火火火火 的开源项目!
企业中台建设新路径——低代码平台
leetcode:5. Longest palindrome substring [DP + holding the tail of timeout]
CSDN 夏令营课程 项目分析
安德鲁斯—-多媒体编程