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

使用vue-seamless-scroll实现echarts图表大屏滚动,出现空白间隔的解决方案

一、背景介绍

最近的业务开发需求,想要实现echarts图表大屏滚动,小编首先采用vue-seamless-scroll进行实现,结果发现第二屏出现空白间隔,尝试了多种解决方案均不生效,最终选择换一个方案。

二、封装的ScrollList组件

<template><div class="scrollContainer" :id="id" @mouseenter="monseenter" @mouseleave="mouseleave"><slot></slot></div>
</template><script>
export default {name: 'ScrollList',props: {id: String},data() {return {timer: null};},methods: {init() {this.setTimer();// this.$once代表只执行一次。如果组件是在keep-alive中包裹,则需要更换函数// 被keep-alive包裹住的组件有两个生命周期函数:activated和deactivatedthis.$once('hook:beforeDestroy', () => {this.removeTimer();});},removeTimer() {if (this.timer) {clearInterval(this.timer);this.timer = null;}},setTimer() {this.removeTimer();this.timer = setInterval(() => {// pixel height:include el and padding    read onlyconst scrollHeight = document.getElementById(this.id).scrollHeight;// visible area height:include el and padding  read onlyconst clientHeight = document.getElementById(this.id).clientHeight;const heightDifference = scrollHeight - clientHeight;// scroll height:readable and writabledocument.getElementById(this.id).scrollTop++;// when el scroll to topif (document.getElementById(this.id).scrollTop >= heightDifference - 1) {this.removeTimer();// make it go back to original location after one secondsetTimeout(() => {document.getElementById(this.id).scrollTop = 0;this.setTimer();}, 1000);}}, 44);},monseenter() {this.removeTimer();},mouseleave() {this.setTimer();}},mounted() {this.init();}
};
</script><style lang="scss" scoped>
.scrollContainer::-webkit-scrollbar {display: none;
}
.scrollContainer::scrollbar {display: none;
}
.scrollContainer {height: 100%;overflow: scroll;overflow-x: hidden;
}
</style>

三、使用ScrollList组件

<template><div><scrollList :id="'leftList'"><!-- todo 写需要循环滚动的代码 --></scrollList></div>
</template><script>import scrollList from '@/components/scrollList/index'export default {components: {scrollList}}
</script>
http://www.lryc.cn/news/500425.html

相关文章:

  • ios使用UIScrollView和PageControl创建图片轮播
  • 3D 生成重建024-LGM第一个开源的3D生成大模型!
  • linux目录权限
  • 语言模型使用心得
  • ChatGPT客户端安装教程(附下载链接)
  • Electron 基础+传值+引用+安全
  • 手机租赁系统全面解析与开发指南
  • mongoDb的读session和写session权限报错问题
  • Centos在2024年6月30日停止维护后如何换yum源安装组件
  • 阿里云ACP云计算模拟试题(附答案解析)
  • 简单的爬虫脚本编写
  • [MySQL基础](三)SQL--图形化界面+DML
  • 11.23[大数据]
  • C++ 游戏开发进阶:打造更精彩的游戏世界
  • 想在iPad上远程操作安卓手机的APP,怎样实现iPad远程控制安卓?
  • GPS北斗卫星授时服务器功能是什么?应用是什么?
  • 利用Java爬虫获取商品数据的完整指南
  • mysql 迁移达梦数据库出现的 sql 语法问题 以及迁移方案
  • 深入解析css-浮动-学习小结
  • 【机器学习】机器学习的基本分类-无监督学习-K-Means聚类
  • .NET for Android/iOS应用的如何在各自的系统运行
  • 访问django后台,提示CSRF验证失败. 请求被中断403
  • Scala的隐式转换(1)
  • 华为TaurusDB与GaussDB:信创改造的“降本提效”之路
  • Linux网络编程---本地套接字
  • 数据结构之四:堆和二叉树
  • 【论文阅读】国际开源发展经验及其对我国开源创新体系建设的启示
  • redis击穿,穿透,雪崩以及解决方案
  • 时频转换 | Matlab格拉姆角和场Gramian angular summation field一维数据转二维图像方法
  • qt QCryptographicHash详解