当前位置:网站首页>数字滚动带动画
数字滚动带动画
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>
边栏推荐
- UML class diagram
- 【JVM调优实战100例】02——虚拟机栈与本地方法栈调优五例
- R语言使用epiDisplay包的lrtest函数对多个glm模型(logisti回归)执行似然比检验(Likelihood ratio test)对比两个模型的性能是否有差异、广义线性模型的似然比检
- Fastdfs installation
- High frequency interview questions
- Singapore summer tourism strategy: play Singapore Sentosa Island in one day
- What is 9D movie like? (+ common sense of dimension space)
- juypter notebook 修改默认打开文件夹以及默认浏览器
- MySQL advanced learning summary 8: overview of InnoDB data storage structure page, internal structure of page, row format
- 问题包含哪些环节
猜你喜欢

新加坡暑假旅游攻略:一天玩转新加坡圣淘沙岛

徹底搞懂基於Open3D的點雲處理教程!

Talk about the design of red envelope activities in e-commerce system
![[daily question] the next day](/img/8a/18329bd9b4a3a4445c8fbbc1ce562b.png)
[daily question] the next day
![[100 cases of JVM tuning practice] 03 -- four cases of JVM heap tuning](/img/54/8a18cd30e6186528599c0556b1ee3b.png)
[100 cases of JVM tuning practice] 03 -- four cases of JVM heap tuning

医院在线问诊源码 医院视频问诊源码 医院小程序源码

中国信通院《数据安全产品与服务图谱》,美创科技实现四大板块全覆盖

Kubernetes three open interfaces first sight

第一次去曼谷旅游怎么玩?这份省钱攻略请收好

M2dgr: slam data set of multi-source and multi scene ground robot (ICRA 2022)
随机推荐
距离度量 —— 杰卡德距离(Jaccard Distance)
材质UV遮罩的技巧
【测试开发】一文带你了解什么是软件测试
Transformation of thinking consciousness is the key to the success or failure of digital transformation of construction enterprises
FastDFS安装
R语言ggplot2可视化:gganimate包创建动态柱状图动画(gif)、使用transition_states函数在动画中沿给定维度逐步显示柱状图
R language dplyr package Na_ The if function converts the control in the vector value into the missing value Na, and converts the specified content into the missing value Na according to the mapping r
医院在线问诊源码 医院视频问诊源码 医院小程序源码
Redis (7) -- database and expiration key
options should NOT have additional properties
[0701] [论文阅读] Alleviating Data Imbalance Issue with Perturbed Input During Inference
Page title component
R语言使用epiDisplay包的cox.display函数获取cox回归模型汇总统计信息(风险率HR、调整风险率及其置信区间、模型系数的t检验的p值、Wald检验的p值和似然比检验的p值)、汇总统计
How to play when you travel to Bangkok for the first time? Please keep this money saving strategy
故障排查:kubectl报错ValidationError: unknown field \u00a0
UML 类图
日期工具类(不定时更新)
[daily question] first day
M2DGR:多源多场景 地面机器人SLAM数据集(ICRA 2022 )
2022软件工程期末考试 回忆版