当前位置:网站首页>短视频平台搭建,淡入淡出 支持左滑右滑轮播图
短视频平台搭建,淡入淡出 支持左滑右滑轮播图
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>
以上就是短视频平台搭建,淡入淡出 支持左滑右滑轮播图, 更多内容欢迎关注之后的文章
边栏推荐
- Don't worry about form deformation anymore
- 客户端可以连接远程mysql
- Introduction to gaofen-3 satellite (GF-3)
- [cloud native] use of Nacos taskmanager task management
- Layer 3 loop brought by route Summary - solution experiment
- The correct method for Navicat to connect to mysql8.0 (valid for personal testing)
- Reflections on remote sensing image interpretation
- Dynamic planning learning (continuous update)
- What are the software testing methods and technical knowledge points?
- Spark cluster installation
猜你喜欢

MySQL,MVCC详解,快照读在RC、RR下的区别

Huawei cloud AOM version 2.0 release

Three development trends of enterprise application viewed from the third technological revolution

IFLYTEK AI learning machine summer new product launch AI + education depth combination to create a new height of products

How to use SMS to deliver service information to customers? The guide is here!

After inventing anti-virus software, he chose to be a top-notch gangster

ASP.NET 跨页面提交(Button控件页面重定向)

cout 不明确问题

Reading notes on how to connect the network - LAN on the server side (4)

Detailed explanation of MySQL and mvcc and the difference between RC and RR for snapshot reading
随机推荐
铝板AS/NZS 1530.1 不燃性材料的阻燃测试
5-minute quick start pytest testing framework
Reading notes on how to connect the network - LAN on the server side (4)
STM32 and gd32 notes
每日刷题记录 (八)
ASP. Net cross page submission (button control page redirection)
这次跟大家聊聊技术,也聊聊人生
C. Where‘s the Bishop?
文件操作的底层原理(文件描述符与缓冲区)
CLI tool foundation of ros2 robot f1tenth
Introduction to gaofen-3 satellite (GF-3)
Ce CDC Flink peut - il être utilisé pour la synchronisation incrémentale d'Oracle à MySQL?
DevCloud加持下的青软,让教育“智”上云端
Final training simple address book c language
Mysql入库不了表情符号怎么办
小型圖書館項目總結
ASP dynamically creates table table
Aleph farms hired a supervisor of regulatory affairs to prepare for global commercialization in advance
22 years of a doctor in Huawei
掌握这28张图,面试再也不怕被问TCP知识了