<video> 上的 iPad 触摸事件标签 [英] iPad touch events on &lt;video&gt; tag

查看:44
本文介绍了<video> 上的 iPad 触摸事件标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 iPad 上构建一个 javascript 驱动的画廊,可以显示图像和视频.要浏览图库,您可以向左或向右滑动(类似于 iPad 的照片应用程序).但是,当在 <video> 上滑动时,我的任何触摸事件都不起作用.元素.它似乎接管了我的触摸事件,即使在可能具有更高 z-index 的元素上也是如此.我曾尝试添加一个调用 e.preventDefault() 的 touchmove 处理程序,但这似乎也不起作用.有没有其他人遇到过这个问题并找到了解决方案?

I'm building a javascript-powered gallery on the iPad that can display both images and video. To browse the gallery, you can swipe left or right (similar to the iPad's Photo application). However, none of my touch events work when swiping over a <video> element. It seems to take over my touch events, even on elements that may have a higher z-index. I have tried adding a touchmove handler that calls e.preventDefault(), but that doesn't seem to work either. Has anyone else run into this problem and found a solution for it?

推荐答案

您的触摸事件正在被播放器的默认控件吸收.如果将视频元素的控件设置为 false,则可以完全控制视频元素上的事件.但是这样做意味着您必须实现自己的自定义控件,这并不难.

Your touch events are being absorbed by the default controls of the player. If you set the video element's controls to false you can have full control of the events on the video element. But doing this means you'll have to implement your own custom controls, which isn't very hard.

这篇关于<video> 上的 iPad 触摸事件标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆