当前位置:网站首页>数字滚动带动画
数字滚动带动画
2022-07-02 17:54:00 【a٩(๑ʊ始于ʃʃʃ繁华ʊ๑)۶a】
数字滚动的前提是这个数字是实时变化的
父组件
<Num width="19px" height="45px" color="#11ffc5" :val="numCount" />
this.interval = setInterval(() => {
this.numCount = +this.numCount + Math.floor(Math.random() * 5);
}, 5000);
beforeDestroy() {
clearInterval(this.interval);
},
父组件
<template>
<div class="count-flop" :key="compKey" :style="{ height: height }">
<div
:class="item != '.' ? 'count-flop-box' : 'count-flop-point'"
v-for="(item, index) in value"
:key="index"
:style="{ width: width, color: color }"
>
<div
v-if="item != '.'"
class="count-flop-content"
:class="['rolling_' + item]"
>
<div v-for="(item2, index2) in numberList" :key="index2">
{
{
item2 }}
</div>
</div>
<div v-else class="count-flop-content">.</div>
</div>
<div v-if="suffix" class="count-flop-unit">{
{
suffix }}</div>
</div>
</template>
<script>
export default {
data() {
return {
value: [],
numberList: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
compKey: 0,
};
},
props: ["val", "suffix", "width", "height", "color"],
watch: {
val() {
this.value = this.val.toString().split("");
this.compKey += 1;
},
},
created() {
this.value = this.val.toString().split("");
},
};
</script>
<style scoped>
.count-flop {
display: inline-block;
/* font-size: 0; */
/* 可更改 */
}
.count-flop > div {
position: relative;
display: inline-block;
overflow: hidden;
height: 100%;
}
.count-flop-box {
/* 可更改 */
width: 18px;
border-radius: 6px;
/* font-size: 32px; */
}
.count-flop-point {
/* 可更改 */
margin-right: 5px;
width: 10px;
}
.count-flop-content {
font-family: MicrosoftYaHei-Bold;
text-align: center;
position: absolute;
left: 0;
top: 0;
width: 100%;
animation-fill-mode: forwards !important;
}
.rolling_0 {
animation: rolling_0 2.1s ease;
}
@keyframes rolling_0 {
from {
transform: translateY(-90%);
}
to {
transform: translateY(0);
}
}
.rolling_1 {
animation: rolling_1 3s ease;
}
@keyframes rolling_1 {
from {
transform: translateY(0);
}
to {
transform: translateY(-10%);
}
}
.rolling_2 {
animation: rolling_2 2.1s ease;
}
@keyframes rolling_2 {
from {
transform: translateY(0);
}
to {
transform: translateY(-20%);
}
}
.rolling_3 {
animation: rolling_3 3s ease;
}
@keyframes rolling_3 {
from {
transform: translateY(0);
}
to {
transform: translateY(-30%);
}
}
.rolling_4 {
animation: rolling_4 2.1s ease;
}
@keyframes rolling_4 {
from {
transform: translateY(0);
}
to {
transform: translateY(-40%);
}
}
.rolling_5 {
animation: rolling_5 3s ease;
}
@keyframes rolling_5 {
from {
transform: translateY(0);
}
to {
transform: translateY(-50%);
}
}
.rolling_6 {
animation: rolling_6 2.1s ease;
}
@keyframes rolling_6 {
from {
transform: translateY(0);
}
to {
transform: translateY(-60%);
}
}
.rolling_7 {
animation: rolling_7 3.1s ease;
}
@keyframes rolling_7 {
from {
transform: translateY(0);
}
to {
transform: translateY(-70%);
}
}
.rolling_8 {
animation: rolling_8 2.1s ease;
}
@keyframes rolling_8 {
from {
transform: translateY(0);
}
to {
transform: translateY(-80%);
}
}
.rolling_9 {
animation: rolling_9 3.6s ease;
}
@keyframes rolling_9 {
from {
transform: translateY(0);
}
to {
transform: translateY(-90%);
}
}
</style>
边栏推荐
- Excel如何进行隔行复制粘贴
- How to copy and paste interlaced in Excel
- Exness in-depth good article: dynamic series - Case Analysis of gold liquidity (V)
- 论文导读 | 关于将预训练语言模型作为知识库的分析与批评
- ORA-01455: converting column overflows integer datatype
- M2DGR:多源多场景 地面机器人SLAM数据集(ICRA 2022 )
- 学生抖音宣传母校被吐槽“招生减章”,网友:哈哈哈哈哈哈
- C的内存管理
- 【每日一题】第一天
- 《病人家属,请来一下》读书笔记
猜你喜欢

Mysql高级篇学习总结8:InnoDB数据存储结构页的概述、页的内部结构、行格式

【JVM调优实战100例】02——虚拟机栈与本地方法栈调优五例

彻底搞懂基于Open3D的点云处理教程!

Installation of thingsboard, an open source IOT platform

Excel查找一列中的相同值,删除该行或替换为空值

Obligatoire pour les débutants, cliquez sur deux boutons pour passer à un contenu différent

ICDE 2023|TKDE Poster Session(CFP)

Hospital online inquiry source code hospital video inquiry source code hospital applet source code

High frequency interview questions
![27: Chapter 3: develop Passport Service: 10: [registration / login] interface: after the registration / login is OK, save the user session information (uid, utoken) to redis and cookies; (one main poi](/img/b9/2066a13b160252114c2881007094f8.png)
27: Chapter 3: develop Passport Service: 10: [registration / login] interface: after the registration / login is OK, save the user session information (uid, utoken) to redis and cookies; (one main poi
随机推荐
Imitation Jingdong magnifying glass effect (pink teacher version)
Progress-进度条
How to play when you travel to Bangkok for the first time? Please keep this money saving strategy
How to clean up discarded PVs and their corresponding folders
论文导读 | 关于将预训练语言模型作为知识库的分析与批评
【每日一题】第二天
日期工具类(不定时更新)
[0701] [论文阅读] Alleviating Data Imbalance Issue with Perturbed Input During Inference
"Patient's family, please come here" reading notes
Troubleshooting: kubectl reports an error validationerror: unknown field \u00a0
[test development] takes you to know what software testing is
学生抖音宣传母校被吐槽“招生减章”,网友:哈哈哈哈哈哈
【JVM调优实战100例】02——虚拟机栈与本地方法栈调优五例
Learn the knowledge points of eight part essay ~ ~ 1
R language uses the lsnofunction function function of epidisplay package to list all objects in the current space, except user-defined function objects
Industrial software lecture - core technology analysis of 3D CAD design software - the second lecture of the Forum
R language ggplot2 visualization: gganimate package creates dynamic histogram animation (GIF) and uses transition_ The States function displays a histogram step by step along a given dimension in the
深度学习数学基础
The difference between SLC, MLC, TLC and QLC NAND SSD: which is better?
二进制操作