最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue實(shí)現(xiàn)無(wú)縫滾動(dòng)的示例詳解

 更新時(shí)間:2023年09月06日 08:42:11   作者:Maidangchen  
這篇文章主要為大家詳細(xì)介紹了vue非組件如何實(shí)現(xiàn)列表的無(wú)縫滾動(dòng)效果,文中的示例代碼簡(jiǎn)潔易懂,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下

vue非組件實(shí)現(xiàn)列表的無(wú)縫滾動(dòng)問(wèn)題(小編能力有限,如有更好方法還請(qǐng)大佬指點(diǎn)一二)

*原理:首先循環(huán)兩遍數(shù)組,當(dāng)容器滾去第一個(gè)數(shù)組高度的時(shí)候,第二個(gè)數(shù)組剛好填滿容器,這時(shí)候?qū)L去高度設(shè)置為0則可以實(shí)現(xiàn)無(wú)縫滾動(dòng)。

*簡(jiǎn)易原理圖如下

話不多說(shuō)直接上代碼:

1.采用js的方法實(shí)現(xiàn)

<template>
	<div>
		<div class="box">
			<div v-for="item in 2" class="item-box" :style="{transform:'translate(0,'+scrollTop+'px)'}">
				<div class="item" v-for="i in 9">{{i}}</div>
			</div>
		</div>
	</div>
</template>
<script>
	export default {
		data() {
			return {
				scrollTop: 0,
			}
		},
		onLoad() {
			this.roll()
		},
		methods: {
			roll() {
				if (this.scrollTop == -300) {
					this.scrollTop = 0
				}
				this.scrollTop -= 1;
				setTimeout(() => {
					this.roll()
				}, 10)
			},
		}
	}
</script>
<style>
	.box {
		width: 320px;
		height: 300px;
		background-color: pink;
		overflow: hidden;
	}
	.box .item-box {
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-wrap: wrap;
	}
	.box .item-box .item {
		width: 29%;
		height: 29%;
		margin: 1%;
		background-color: paleturquoise;
		display: flex;
		align-items: center;
		justify-content: center;
		font-weight: 700;
	}
</style>

2.css動(dòng)畫(huà)實(shí)現(xiàn)

<template>
	<div>
		<div class="box">
			<div v-for="item in 2" class="item-box">
				<div class="item" v-for="i in 9">{{i}}</div>
			</div>
		</div>
	</div>
</template>
<script>
	export default {
		data() {
			return {}
		},
		methods: {
		}
	}
</script>
<style>
	.box {
		width: 320px;
		height: 300px;
		background-color: pink;
		overflow: hidden;
	}
	.box .item-box {
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-wrap: wrap;
		animation: roll 5s linear infinite;
	}
	.box .item-box .item {
		width: 29%;
		height: 29%;
		margin: 1%;
		background-color: paleturquoise;
		display: flex;
		align-items: center;
		justify-content: center;
		font-weight: 700;
	}
	@keyframes roll {
		0% {
			transform: translate(0, 0px);
		}
		20% {
			transform: translate(0, -60px);
		}
		40% {
			transform: translate(0, -120px);
		}
		60% {
			transform: translate(0, -180px);
		}
		80% {
			transform: translate(0, -240px);
		}
		100% {
			transform: translate(0, -300px);
		}
	}
</style>

到此這篇關(guān)于vue實(shí)現(xiàn)無(wú)縫滾動(dòng)的示例詳解的文章就介紹到這了,更多相關(guān)vue無(wú)縫滾動(dòng)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

旌德县| 东宁县| 江都市| 大港区| 松溪县| 宁海县| 南澳县| 宁乡县| 桂阳县| 临沂市| 杭锦旗| 密云县| 山西省| 长春市| 金寨县| 祁门县| 汾西县| 永济市| 定州市| 娱乐| 翼城县| 留坝县| 鹤峰县| 邵东县| 通州市| 兰西县| 两当县| 泰顺县| 博白县| 和平区| 平顶山市| 沂源县| 特克斯县| 鞍山市| 邵阳县| 西乌| 天等县| 西青区| 方正县| 茶陵县| 白玉县|