当前位置: 首页 > news >正文

网站做的相似网站设计机构文档

网站做的相似,网站设计机构文档,可以做分析图的地图网站,阿里巴巴logo图片介绍: 当数字变化时&#xff0c;只改变变化的数字位&#xff0c;其余的不变&#xff0c;可以递增、递减、骤变、负数也可以&#xff0c;但是样式要根据具体的项目需求去改&#xff1b; 效果1、增加数字&#xff1a; 效果2、减少数字&#xff1a; 使用方法&#xff1a; <te…

介绍:

        当数字变化时,只改变变化的数字位,其余的不变,可以递增、递减、骤变、负数也可以,但是样式要根据具体的项目需求去改;

效果1、增加数字:

效果2、减少数字:

使用方法:

<template><AnimatNumber :data="data" />
</template><script setup>
// 引入动画
import AnimatNumber from "./components/AnimatNumber.vue";const data = ref(0);setInterval(() => {data.value -= 30;
}, 2000);
</script><style lang="scss"></style>

组件代码(vue3):

<template><div class="num-wrap"><div v-for="(item, index) in computedData" :key="index" class="num-item"><div class="num-inner" ref="numInnerRef"><div class="prev">{{ item.newValue }}</div><div class="current">{{ item.oldValue }}</div><div class="next">{{ item.oldValue }}</div></div></div></div>
</template><script setup>
// 数字滚动效果
import { onBeforeUnmount, watch, ref, nextTick } from "vue";const props = defineProps({// 传进来的数据  number、string的number都可以data: {type: [Number, String],default: 999},// 动画持续时间  number、string的number都可以  最低1000msduration: {type: [Number, String],default: 500},// 基本的高度 所有的动画移动距离都是和这个有关的,确保这个值和css的$height一样,否则有问题baseHeight: {type: Number,default: 50}
});const numInnerRef = ref();// raf演示器
const setTimeoutPolyfill = (func, delay) => {let startTime = Date.now();let rafId;function animationFrameCallback() {const currentTime = Date.now();const timeElapsed = currentTime - startTime;if (timeElapsed >= delay) {func();} else {rafId = requestAnimationFrame(animationFrameCallback);}}rafId = requestAnimationFrame(animationFrameCallback);// 返回一个取消函数return () => cancelAnimationFrame(rafId);
};/*
推演公式新          旧1001  ->   10001002  ->   10011003  ->   10021004  ->   10031005  ->   1004
*/const newArr = ref([]);
const oldArr = ref([]);
const computedData = ref(props.data.toString().split("").map((item, index) => ({ index, oldValue: item, newValue: item }))
);
const lock = ref(false);
// 延时器
const timer = ref({timerOne: null,timerTwo: null
});watch(() => props.data,(newVal, oldVal) => {if (`${newVal}`.length !== `${oldVal}`.length) {lock.value = false;}if (!lock.value) {computedData.value = props.data.toString().split("").map((item, index) => ({ index, oldValue: item, newValue: item }));lock.value = true;}newArr.value = newVal.toString().split("").map((item, index) => ({ index, value: item }));oldArr.value = oldVal.toString().split("").map((item, index) => ({ index, value: item }));/*如果newArr的长度大于于oldArr的长度,则需要给oldArr从前面增加newArr.length - oldArr.length的长度的{ index, oldValue: '-', newValue: newValueItem }, 同时更新oldArr没有新增的index*/// 新值和老值差const differLength = newArr.value.length - oldArr.value.length;if (newArr.value.length > oldArr.value.length) {for (let i = 0; i < differLength; i++) {oldArr.value.unshift({ index: i, value: "-" });}// 重新设置indexoldArr.value.forEach((item, index) => (item.index = index));}// 改变的数字的索引集合const indexArr = [];newArr.value.forEach(item => {if (item.value !== oldArr.value[item.index].value) {indexArr.push(item.index);}});nextTick(() => {indexArr.forEach(diffIndex => {numInnerRef.value[diffIndex].children[0].innerHTML =newArr.value[diffIndex].value;numInnerRef.value[diffIndex].children[0].animate([{ top: `${-props.baseHeight}px` }, { top: 0 }],{duration: props.duration,fill: "forwards"});numInnerRef.value[diffIndex].children[1].animate([{ top: "0" }, { top: `${props.baseHeight}px` }],{duration: props.duration,fill: "forwards"});timer.value.timerOne = setTimeoutPolyfill(() => {numInnerRef.value[diffIndex].children[2].innerHTML =oldArr.value[diffIndex].value;timer.value.timerTwo = setTimeoutPolyfill(() => {numInnerRef.value[diffIndex].children[1].innerHTML =newArr.value[diffIndex].value;}, props.duration);numInnerRef.value[diffIndex].children[2].style.top = `${-props.baseHeight}px`;}, props.duration);});});},{ deep: true }
);// 卸载
onBeforeUnmount(() => {timer.value.timerOne && timer.value.timerOne();timer.value.timerTwo && timer.value.timerTwo();
});
</script><style lang="scss" scoped>
$width: 50px;
$height: 50px;
.num-wrap {margin-top: 200px;display: flex;gap: 10px;.num-item {width: $width;height: $height;border: 1px solid #000;border-radius: 8px;font-size: 20px;font-weight: 600;position: relative;overflow: hidden;color: #0dfbff;background: rgba(0, 13, 23, 0.5);.num-inner {position: relative;width: $width;height: $height;}.prev,.current,.next {width: $width;height: $height;text-align: center;line-height: $width;position: absolute;}.prev {top: -$height;}.current {top: 0;}.next {top: $height;}}
}
</style>

http://www.yayakq.cn/news/306270/

相关文章:

  • 佛山市和城乡建设局网站首页saharan wordpress
  • 东平县建设局网站长春网站建设首选网诚传媒
  • 网站建设公司相关资质太原招聘网站开发
  • 重庆医疗网站建设音乐网站开发案例
  • 张店网站建设求职招聘网站建设投标书
  • 温岭市建设局网站邢台365生活网
  • asp网站建设实录搭建网页游戏教程
  • 给一个网站做需求分析中国建设银行快捷付授权网站
  • 怎么做电影网站不违法辽阳企业网站建设服务
  • 个人网站建设方案书模板网站备案证书查询
  • 在服务器上布网站怎么做的集团门户网站建设费用
  • 教育类企业网站建设厅工作证查询网站
  • 企业进行网站建设的方式网站的建设意见
  • 永康住房和城乡建设局网站门户网站建设存在的问题和差距
  • 建设高端网站公司网页制作设计思路和过程描述
  • 优化网站界面的工具南昌中企动力做的网站怎么样
  • 网站模板编辑器wordpress用户聊天
  • 做推文封面的网站织梦可以做哪些类型型网站
  • 怎么自创网站两山开发公司
  • 彩票走势图网站建设对seo的理解
  • 免费建网站平台教什么是伪静态网站
  • 网站做外链好嘛做买衣服的网站有哪些
  • 阿里云买了域名怎么建网站网站系统建设思想如何写
  • 全国火车站等级最新排名做杂志的模板下载网站
  • 网站建设需要学ps吗平台电商运营
  • 无锡商城网站建设长春火车站防疫要求
  • 如何做一张旅游网站网站建设一般用什么编程
  • 环保设备网站建设模板wordpress 加载完毕
  • 辽宁数据网站建设哪家便宜宁波做网站哪家公司好
  • 上海工程建设交易信息网站成功的网站应该具备哪些要素