使用Javascript / jQuery的/ CSS。如何在目标div之外维护拖动事件?

时间:2022-12-02 17:09:21

I am implementing a scrollbar using jQuery/Javascript/CSS. The usual. Everything is going according to plan except for the following use case:

我正在使用jQuery / Javascript / CSS实现滚动条。通常。除了以下用例之外,一切都按计划进行:

The user mouses down in the scrollbar div hosting mousedown/mousemove/mouseup event handlers. The user initiates a drag gesture - mousemove starts firing - that soon moves the cursor outside the bounds of the scrollbar div and onto the surrounding div real estate on the web page. The moment this happens, mousemove - as expected - stops firing events.

用户将鼠标停留在托管mousedown / mousemove / mouseup事件处理程序的滚动条div中。用户启动拖动手势 - mousemove开始触发 - 很快将光标移动到滚动条div的边界之外,并移动到网页上的周围div房地产上。一旦发生这种情况,mousemove-正如预期的那样 - 停止触发事件。

How do I continue to have mousemove fire events without resorting to just attaching a mousemove handler to the root div? How do I maintain scrollbar dragger translation even though the cursor has wandered off the scrollbar?

如何在不诉诸于将mousemove处理程序附加到根div的情况下继续使用mousemove fire事件?即使光标从滚动条上移开,如何保持滚动条拖动器转换?

Thanks,
Doug

1 个解决方案

#1


0  

Instead of using onmousemove on the element, use it on the document.

而不是在元素上使用onmousemove,在文档上使用它。

#1


0  

Instead of using onmousemove on the element, use it on the document.

而不是在元素上使用onmousemove,在文档上使用它。