jquery:可拖动插件 ->从 html5 视频控件中删除拖动行为?
我正在使用 jquery ui 可拖动插件,并且我有一个带有“预加载控件”的 html 5 视频元素,它的行为有点错误。 如果我
$(".thumb").draggable();
通过单击视频控件来拖动视频,然后再次释放鼠标,视频仍然会粘在鼠标上。
<div class='thumb video'><video width='260' height='200' preload controls>
如果我开始在视频控件上拖动视频,我就没有机会再次发布视频。
知道我该如何解决这个问题吗!我可能应该编写自己的视频控件脚本来解决这个问题。
im working with the jquery ui draggable plugin and i have an html 5 video element with "preload controls" that acts kind of buggy. I
$(".thumb").draggable();
if i drag the video by clicking on the video controls and i'm releasing the mouse again, the video still sticks with the mouse.
<div class='thumb video'><video width='260' height='200' preload controls>
i have no chance to release the video again if i started draggin it at the video controls.
any idea how i could fix this! i probaply should script my own video controls to fix this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这一次很艰难。视频播放器确实坚持鼠标并吃掉那些鼠标松开事件。但是,这是我的解决方法:
我在鼠标悬停期间检查鼠标位置的内部 Y 坐标(可调值),如果它超出范围,我会禁用拖放功能。我看到 mousemove() 事件在粘性时继续触发,因此这看起来像是逻辑的理想访问点:
This one was tough. The video player really did stick to the mouse and eat those mouse up events. However, here's my workaround:
I check the internal Y coordinate of the mouse position during mouse over (adjustable value) and if it's outside of the range, I disable the drag-n-drop feature. I saw that the mousemove() event continued to fire when it was sticky, so that looked like an ideal access point for the logic:
我遇到了同样的问题 - 我需要一个可拖动的视频播放器,在播放时可以拖动,但一旦暂停,它就会折叠回缩略图状态。
正如您发现的,视频播放器对
mouseup
做出反应,而不是对click
事件做出反应。因此,每当我停止拖动视频时,它就会暂停视频,并且我无法取消mouseup
事件。我找到的唯一解决方案是用一个 DIV 覆盖视频,该 DIV 用作 jQuery UI Draggable 的句柄。 Draggable 使用了
mousedown
、mouseup
和mousemove
事件,但我咳嗽了click
事件并暂停了视频。但是,此解决方案不适用于重叠控件 - 否则您将需要自定义控件。
i have had the same problem — i needed a draggable video player, that is draggable while playing, but as soon as it pauses, it collapses back to a thumbnail state.
as you found out the video player reacts on
mouseup
rather thanclick
event. so it paused the video whenever i stopped dragging it, and i couldn't cancel themouseup
event.the only solution i found was to overlay the video with a DIV that works as a handle for jQuery UI Draggable.
mousedown
,mouseup
andmousemove
events were used by Draggable, butclick
event i cought and paused the video.this solution, however, doesn't work with overlayed controls - or you'll need custom ones.