jquery:可拖动插件 ->从 html5 视频控件中删除拖动行为?

发布于 2024-09-04 16:21:18 字数 363 浏览 4 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

手心的海 2024-09-11 16:21:18

这一次很艰难。视频播放器确实坚持鼠标并吃掉那些鼠标松开事件。但是,这是我的解决方法:

我在鼠标悬停期间检查鼠标位置的内部 Y 坐标(可调值),如果它超出范围,我会禁用拖放功能。我看到 mousemove() 事件在粘性时继续触发,因此这看起来像是逻辑的理想访问点:

$(function () {

    $('.thumb')
        .draggable()
        .mousemove(function (e) {
            var yAxis = e.pageY - this.offsetTop;
            $(this).draggable("option", "disabled", (yAxis > 150) ? true : false);
        });

});

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:

$(function () {

    $('.thumb')
        .draggable()
        .mousemove(function (e) {
            var yAxis = e.pageY - this.offsetTop;
            $(this).draggable("option", "disabled", (yAxis > 150) ? true : false);
        });

});
岛徒 2024-09-11 16:21:18

我遇到了同样的问题 - 我需要一个可拖动的视频播放器,在播放时可以拖动,但一旦暂停,它就会折叠回缩略图状态。

正如您发现的,视频播放器对 mouseup 做出反应,而不是对 click 事件做出反应。因此,每当我停止拖动视频时,它就会暂停视频,并且我无法取消 mouseup 事件。

我找到的唯一解决方案是用一个 DIV 覆盖视频,该 DIV 用作 jQuery UI Draggable 的句柄。 Draggable 使用了 mousedownmouseupmousemove 事件,但我咳嗽了 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 than click event. so it paused the video whenever i stopped dragging it, and i couldn't cancel the mouseup 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 and mousemove events were used by Draggable, but click event i cought and paused the video.

this solution, however, doesn't work with overlayed controls - or you'll need custom ones.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文