简体   繁体   English

鼠标退出画布时停止Jit拖动

[英]Stop theJit dragging when mouse exits canvas

I am using theJit as SpaceTree to visualize some information (Who'd guessed that...) 我正在使用theJit作为SpaceTree来可视化一些信息(谁猜到了...)

Problem is, when users are panning the graph and dragging the mouse outside of the canvas jit doesn't recognizes it and keeps on dragging . 问题是,当用户平移图形并将鼠标拖到画布jit 之外时,jit无法识别并继续拖动 When the user comes back into the area of the canvas it is still in drag-mode and keeps on panning. 当用户返回到画布区域时,它仍处于拖动模式并继续平移。 This behavior is also observable in their Space-Tree-Example . 在其Space-Tree-Example中也可以观察到此行为

(Just to clarify - I am panning the whole graph; I am not dragging a node to some target location...) (只是要澄清-我正在平移整个图形;我没有将节点拖到某些目标位置...)

I can bind to $('#container').mouseleave() via jQuery , but how to I tell jit to stop dragging? 我可以通过jQuery绑定到$('#container')。mouseleave(),但是如何告诉jit停止拖动呢?

(The mouseOver and mouseLeave handlers provided by jit (jit.Events.*) itself are bound to the individual nodes and thus not really helpful in this case) (jit(jit.Events。*)本身提供的mouseOver和mouseLeave处理程序绑定到各个节点,因此在这种情况下并没有太大帮助)

Anybody got an Idea? 有人有主意吗?

Cheers, 干杯,

Corelgott_ Corelgott_

I finally figured out a way to do it... definitely not the cleanest / nicest way of doing it, but it works at least: 我终于想出了一种方法...绝对不是最干净/最好的方法,但是它至少有效:

When the mouse leaves the the box of the jit canvas I simulate a complete mouse-out event and send it to jit. 当鼠标离开jit画布的框时,我将模拟一个完整的mouse-out事件并将其发送到jit。

By using this code " How to simulate a mouse click using JavaScript? " like this: 通过使用以下代码“ 如何使用JavaScript模拟鼠标单击? ”,如下所示:

    $('#infovis').mouseleave(function(e) {
        simulate($('canvas')[0], 'mouseup')            
    });

it stops when the mouse exists the info-vis-<div> 当鼠标位于info-vis- <div>时它停止

Hopefully that saves somebody some time in the future! 希望将来可以节省一些时间!

Cheers, 干杯,

Corelgott Corelgott

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM