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

bash 复制代码
<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>
bash 复制代码
<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>
bash 复制代码
<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>
相关推荐
乘风gg2 分钟前
企业级 Prompt 工程实战指南(下):构建可复用 Prompt 架构平台
前端·面试·架构
未来之窗软件服务9 分钟前
服务器运维(三十四)小程序web访问慢ssl优化—东方仙盟
运维·服务器·小程序·仙盟创梦ide·东方仙盟
Kyl2n9 分钟前
【密码口令保存小工具】
javascript·css·css3
全栈小514 分钟前
【小程序】微信小程序slice方法分割无效,单独输出一直为空,这是为什么呢
微信小程序·小程序·数组分割
宇擎智脑科技16 分钟前
AntV G6、X6 与 React Flow 深度对比:核心差异与大模型时代的应用场景分析
前端·人工智能·react.js·前端框架
Light6016 分钟前
心智有效性测试小程序 V1.0 产品白皮书——心智结构量化与系统稳定性评估平台
小程序·apache
山核桃&17°16 分钟前
基于 Vue + Node.js 批处理bat脚本实现多环境一键部署
运维·前端·自动化
AC赳赳老秦17 分钟前
云原生AI趋势:DeepSeek与云3.0架构协同,提升AI部署性能与可移植性
大数据·前端·人工智能·算法·云原生·架构·deepseek
程序哥聊面试23 分钟前
React + TS 初始化新项目报错解决方法
前端·react.js·npm
codeGoogle24 分钟前
2026 年 IM 怎么选?聊聊 4 家主流即时通讯方案的差异
android·前端·后端