欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 金融 > 小程序css实现容器内 数据滚动 无缝衔接 点击暂停

小程序css实现容器内 数据滚动 无缝衔接 点击暂停

2025/5/5 21:34:16 来源:https://blog.csdn.net/weixin_44601930/article/details/147248707  浏览:    关键词:小程序css实现容器内 数据滚动 无缝衔接 点击暂停
<view class="gundongBox"><!-- 滚动展示信息的模块 --><image class="imgWid" :src="imgurl+'gundong.png'" mode="widthFix"></image><view class="gundongView"><view class="container"><view class="scroll-container":style="{ animationPlayState: autoScroll ? 'running' : 'paused',animationDuration:list.length>0?list.length +'s':0+'s' }" @touchstart="pauseScroll"@touchend="resumeScroll"><view v-for="(item, index) in list" :key="index" class="item">{{ item }}</view><!-- 复制一份实现无缝循环 --><view v-for="(item, index) in list" :key="'copy-'+index" class="item">{{ item }}</view></view></view></view></view>
<script>export default {components: {},data() {return {list: ["a", "b", "c"],autoScroll: true,resumeTimer: null}},onLoad(options) {// console.log("接收的参数",options)},methods: {pauseScroll() {this.autoScroll = false;clearTimeout(this.resumeTimer);},resumeScroll() {this.resumeTimer = setTimeout(() => {this.autoScroll = true;}, 2000);}}}
</script>
<style>
.gundongView {height: 500rpx;overflow: hidden;}
.container {display: flex;flex-direction: column;align-items: center;}.scroll-container {/* height: 300px; */width: 80%;overflow: hidden;position: relative;border: 1px solid #eee;animation: scroll 20s linear infinite; /* 默认执行20s */}@keyframes scroll {0% {transform: translateY(0);}100% {transform: translateY(-50%);}}.item {padding: 20rpx;border-bottom: 1px solid #f0f0f0;}
</style>

在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词