小程序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>
相关推荐
郭邯6 小时前
一次「字符洁癖」引发的思考:我用 AI 写了个全角半角转换工具
前端
想要成为糕糕手6 小时前
🚀 在浏览器里跑 DeepSeek-R1?WebGPU 端侧推理实战(五)—— 中断、重置、缓存与流式生成
前端·react.js·llm
GuWenyue6 小时前
后端接口又双叒没写好?3 步搭建前端 Mock,从此告别"傻等后端"
前端·mocha
海兰6 小时前
【数据采集】开源的 Web 数据采集与处理Firecrawl(一)
前端·开源
vivo互联网技术6 小时前
从一键检测到 AI 修复:我们如何把无障碍检查做进研发流程
前端·人工智能
liuxiaocheng6 小时前
聊聊 Vercel AI SDK 的流式协议:前后端到底是怎么"边想边说"的
前端·后端
胡萝卜术6 小时前
在浏览器中跑 DeepSeek-R1:WebGPU 推理全流程深度解析
前端·javascript·面试
windliang6 小时前
Claude Code 源码分析(十):MCP 外部工具如何进入下一轮 Agent 调用
前端·算法·面试
Yan_chen6666 小时前
CTFHub XSS反射型实战攻略
前端·网络安全·漏洞·xss·ctfhub web前置技能
单词记忆方法研究7 小时前
探索上海背单词小程序品牌:高效学习工具的优化之路
大数据·学习·小程序