uniapp上下滑动事件

 

<view  @longpress="longpressBtn()" @touchend="touchendBtn()">
				<view class="dade_start" @touchstart="start" @touchend="end" @touchmove="move">长按录音</view>
			</view>

 

// 触摸touch事件
		   	start(e){  //@touchstart 触摸开始
		   		this.transition = '.1s';
		   	    this.startData.clientX = e.changedTouches[0].clientX;   //手指按下时的X坐标         
		   	    this.startData.clientY = e.changedTouches[0].clientY;   //手指按下时的Y坐标
		   	},
		   	end(e){  //@touchend触摸结束
		   		this.moveX = 0;  //触摸事件结束恢复原状
		   		this.transition = '.5s';
		   		if(Math.abs(this.touch.clientX-this.startData.clientX) > 100) {  //在事件结束时,判断滑动的距离是否达到出发需要执行事件的要求
		   			console.log('执行查看跳转事件');
		   			// this.touch = {};
		   		} else {
		   			console.log('滑动距离不够,不执行跳转')
		   			// this.touch = {};
		   		}
		   	},
		   	move(event) {  //@touchmove触摸移动
		   		let touch = event.touches[0];  //滑动过程中,手指滑动的坐标信息 返回的是Objcet对象
				// console.log(touch);
		   		this.touch = touch;
		   		let data = touch.clientY - this.startData.clientY;
		   		if(touch.clientY < this.startData.clientY) {  //向上移动
		   			if(data<-50) {
		   				data = -50;
		   			}
					console.log('上')
		   		}
		   		if(touch.clientY > this.startData.clientY) {  //向下移动
		   			if(this.moveY == 0) {
		   				data = 0
		   			} else {
		   				if(data>50) {
		   					data = 50;
		   				}
		   			}
					console.log('下')
		   		}
		   		this.moveY = data;
				console.log(data);
		   	},

 

 

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
uniapp中实现上下滑动效果可以使用swiper和video组件的结合。首先,我们可以在uniapp官网的swiper组件中嵌套一个video组件来实现这个效果。在swiper-item的位置发生改变时,可以通过@transition事件来触发相应的操作,比如判断上滑还是下滑。 在父组件的html中,我们可以使用swiper组件来创建一个轮播图的效果。在swiper-item中,可以通过v-for循环来遍历视频列表并展示相应的视频。 总结来说,可以通过uniapp的swiper和video组件的结合来实现在uniapp中的上下滑动效果。通过设置swiper的相关属性和监听相应的事件来实现滑动操作,并在事件中处理上滑和下滑的逻辑。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [uniapp实现视频上下滑动功能](https://blog.csdn.net/weixin_46319117/article/details/125808944)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [uniapp实现视频上下滑动功能(小程序)以及video组件的暂停和播放](https://blog.csdn.net/weixin_46447120/article/details/121531294)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大得369

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值