当前位置:网站首页>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%);
}
}边栏推荐
- S120驱动器基本调试步骤总结
- The panel floating with the mouse in unity can adapt to the size of text content
- QT常见概念-1
- CSDN 夏令营课程 项目分析
- 慧通编程入门课程 - 2A闯关
- Compress JS code with terser
- MES管理系统的应用和好处有哪些
- [leetcode]Search for a Range
- 基于ensp防火墙双击热备二层网络规划与设计
- Introduction to the internal structure of the data directory of PostgreSQL
猜你喜欢

C#/VB.NET 删除Word文档中的水印

Linear list --- circular linked list

Fundamentals of process management

慧通编程入门课程 - 2A闯关

哈希表及完整注释

MySQL --- 常用函数 - 字符串函数
![leetcode:5. Longest palindrome substring [DP + holding the tail of timeout]](/img/62/d4d5428f69fc221063a4f607750995.png)
leetcode:5. Longest palindrome substring [DP + holding the tail of timeout]

The panel floating with the mouse in unity can adapt to the size of text content

Mmdetection3d loads millimeter wave radar data

Compress JS code with terser
随机推荐
This week's hot open source project!
[C # notes] use file stream to copy files
GEE升级,可以实现一件run tasks
C#/VB.NET 删除Word文档中的水印
Difference and the difference between array and array structure and linked list
dotConnect for DB2数据提供者
Unity webgl adaptive web page size
Linear list --- circular linked list
Cloud Mail .NET Edition
Pioneer of Web3: virtual human
STM32 project -- Topic sharing (part)
unity webgl自适应网页尺寸
如何从0到1构建32Core树莓派集群
用全连接+softmax对图片的feature进行分类
[paper reading | deep reading] anrl: attributed network representation learning via deep neural networks
PostgreSQL图形化界面工具之pgAdmin4
Halcon instance to opencvsharp (C openCV) implementation -- bottle mouth defect detection (with source code)
MySQL
数字滚动增加效果
【森城市】GIS数据漫谈(二)