当前位置:网站首页>短视频平台搭建,淡入淡出 支持左滑右滑轮播图
短视频平台搭建,淡入淡出 支持左滑右滑轮播图
2022-06-29 21:58:00 【云豹网络科技】
短视频平台搭建,淡入淡出 支持左滑右滑轮播图
<template>
<view class="grapSwiper">
<view class="banner" @touchstart="touchStart" @touchend="touchEnd">
<image v-for="(value,index) in swiperList" :key="index" class="pic" :src="value.imagePath" :animation="num==index?showpic:hidepic"/>
<view class="snipper">
<view class="sniItem" v-for="(item,ind) in swiperList" :key="ind" :class="num==ind?'activeItem':''"></view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'grapSwiper',
data () {
return {
touchStartX: 0, // 触屏起始点x
touchStartY: 0, // 触屏起始点y
swiperList:[
{
imagePath:'https://pla.o-banks.cn/attach/mgrImg/20220110/1641806731686.png'
},
{
imagePath:'https://pla.o-banks.cn/attach/mgrImg/20210923/1632361307137.png'
},
{
imagePath:'https://pla.o-banks.cn/attach/mgrImg/20210916/1631775560384.png'
}
],
setTime:null,
num:0,
timeCount:5000,
showpic:null,
hidepic:null
}
},
created () {
},
mounted(){
this.initSwiper();
},
methods:{
initSwiper(){
const animation = uni.createAnimation({
}) //创建一个动画实例
this.setTime = setInterval(() => {
this.num++
if(this.num >this.swiperList.length-1){
this.num = 0
}
//淡入
animation.opacity(1).step({
duration:300}) //描述动画
this.showpic = animation.export()
//淡出
animation.opacity(0).step({
duration:300})
this.hidepic=animation.export()
}, this.timeCount);
},
touchStart(e) {
this.touchStartX = e.touches[0].clientX;
this.touchStartY = e.touches[0].clientY;
},
touchEnd(e) {
let deltaX = e.changedTouches[0].clientX - this.touchStartX;
let deltaY = e.changedTouches[0].clientY - this.touchStartY;
if (Math.abs(deltaX) > 50 && Math.abs(deltaX) > Math.abs(deltaY)) {
// 左滑右滑时重新初始化定时器
clearInterval(this.setTime)
this.initSwiper();
if (deltaX >= 0) {
this.num--
if(this.num <0){
this.num = this.swiperList.length-1
}
} else {
this.num++
if(this.num >this.swiperList.length-1){
this.num = 0
}
}
} else {
console.log("可能是误触!")
}
},
},
destroyed(){
clearInterval(this.setTime)
}
}
</script>
<style lang="scss" scoped>
.grapSwiper{
.banner{
width: 750rpx;
height: 640rpx;
position: relative;
.pic{
width: 750rpx;
height: 640rpx;
position: absolute;
}
.snipper{
position: absolute;
width: 100%;
height: 2rpx;
top: 210rpx;
left: 0;
display: flex;
align-items: center;
justify-content: center;
.sniItem{
width: 15rpx;
height: 2rpx;
background: #FFFFFF;
opacity: 0.4;
border-radius: 5rpx;
margin-right: 6rpx;
}
.activeItem{
width: 25rpx;
background: #FFFFFF;
opacity: 1;
}
}
}
}
</style>
以上就是短视频平台搭建,淡入淡出 支持左滑右滑轮播图, 更多内容欢迎关注之后的文章
边栏推荐
- Hardware development notes (VIII): basic process of hardware development, making a USB to RS232 module (VII): creating a basic dip component (crystal oscillator) package and associating the principle
- Is it reliable to open an account on the compass with your mobile phone? Is there any hidden danger in this way
- How to use filters in jfinal to monitor Druid for SQL execution?
- 软件快速交付真的需要以安全为代价吗?
- Data mining review
- 彩涂钢板密封板申请BS 476-3如何备样?
- 2022 openvino DevCon unveils secrets! Intel and many partners deepen the construction of developer ecology and release the innovation potential of AI industry
- Deep learning remote sensing data set
- 期末实训 简单通讯录 c语言
- Go learning (IV. interface oriented)
猜你喜欢

Structure the fifth operation of the actual camp module

铝板AS/NZS 1530.1 不燃性材料的阻燃测试

Divide the bonus pool of 10million + million yuan, and empower developers in the 2022 shengteng AI innovation competition

Golang operation NSQ distributed message queue

数论-整除分块

Huawei cloud AOM version 2.0 release

The logic behind the three whys encountered in technical communication

这次跟大家聊聊技术,也聊聊人生

CLI tool foundation of ros2 robot f1tenth

Hardware development notes (VIII): basic process of hardware development, making a USB to RS232 module (VII): creating a basic dip component (crystal oscillator) package and associating the principle
随机推荐
Detailed description of gaussdb (DWS) complex and diverse resource load management methods
Taro2.* applet configuration sharing wechat circle of friends
5-minute quick start pytest testing framework
每日刷题记录 (八)
CSDN failed to replicate problem
Weibo comments on high availability and high performance computing architecture
2022 openvino DevCon unveils secrets! Intel and many partners deepen the construction of developer ecology and release the innovation potential of AI industry
Taro applet enables wxml code compression
如果我在珠海,到哪里开户比较好?究竟网上开户是否安全么?
Data mining review
泰山OFFICE技术讲座:一行中所有元素高度相同
In the shop project, implement a menu (add, delete, modify and query)
华为7年经验的软件测试总监,给所有想转行学软件测试的同学的几个建议
架构实战营毕业总结
The database of the server cannot be connected [the service has been started, the firewall has been closed, the port has been opened, and the netlent port is not connected]
Autodesk Revit 2023 software installation package download and installation tutorial
A. Beat The Odds
Houdini graphic notes: VAT (3.0) import ue4/5 setup wizard [official document translation]
Analysis of typical remote sensing tasks
Cloud native database query optimization - statistics and row count estimation