当前位置:网站首页>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%);
}
}
边栏推荐
- The cities research center of New York University recruits master of science and postdoctoral students
- [paper reading | deep reading] rolne: improving the quality of network embedding with structural role proximity
- Halcon实例转OpenCvSharp(C# OpenCV)实现--瓶口缺陷检测(附源码)
- [unity] upgraded version · Excel data analysis, automatically create corresponding C classes, automatically create scriptableobject generation classes, and automatically serialize asset files
- MySQL --- 常用函数 - 字符串函数
- The empirical asset pricing package (EAP) can be installed through pypi
- 你不可不知道的Selenium 8种元素定位方法,简单且实用
- 本周 火火火火 的开源项目!
- Lombok makes the pit of ⽤ @data and @builder at the same time
- Application analysis of face recognition
猜你喜欢
[server data recovery] data recovery case of a Dell server crash caused by raid damage
如何设计好接口测试用例?教你几个小技巧,轻松稿定
你不可不知道的Selenium 8种元素定位方法,简单且实用
[paper reading | deep reading] rolne: improving the quality of network embedding with structural role proximity
Lombok makes the pit of ⽤ @data and @builder at the same time
Web3的先锋兵:虚拟人
Unity custom webgl packaging template
6-6 vulnerability exploitation SSH security defense
Compress JS code with terser
The third season of ape table school is about to launch, opening a new vision for developers under the wave of going to sea
随机推荐
实施MES管理系统时,哪些管理点是需要注意的
[leetcode]Search for a Range
[paper reading | deep reading] dngr:deep neural networks for learning graph representations
所谓的消费互联网仅仅只是做行业信息的撮合和对接,并不改变产业本身
3--新唐nuc980 kernel支持jffs2, Jffs2文件系统制作, 内核挂载jffs2, uboot网口设置,uboot支持tftp
[unity] upgraded version · Excel data analysis, automatically create corresponding C classes, automatically create scriptableobject generation classes, and automatically serialize asset files
Argo workflows source code analysis
写作系列之contribution
MySQL --- 常用函数 - 字符串函数
6-6漏洞利用-SSH安全防御
一文读懂Faster RCNN
unity 自定义webgl打包模板
1 -- Xintang nuc980 nuc980 porting uboot, starting from external mx25l
C#/VB.NET 删除Word文檔中的水印
What to do when encountering slow SQL? (next)
Statistics of radar data in nuscenes data set
unity中跟随鼠标浮动的面板,并可以自适应文字内容的大小
差异与阵列和阵列结构和链表的区别
C#/VB. Net to delete watermarks in word documents
Unity custom webgl packaging template