怎么解决,松开鼠标之后,还能拖动图的问题

我的红色框是图的外面,黑色框是图里面的内容,当我按住鼠标在黑色框部分移动是没有问题的,但是当我将鼠标移出黑色框范围,进入红色框之后,松开鼠标,再移回黑色框部分,就会出现,鼠标已经松开了,但是你的图还是能够跟随鼠标移动,这个怎么解决

So if I understand you correctly, you are saying that dragging a node within the diagram with the black border works well.

But when dragging a node from there up to the area with the red border, then releasing the mouse button in that area, and finally moving the mouse back down to the diagram with the black border, the node continues to be dragged around in the diagram. This happens even though no mouse button is being held down.

So my first question is: what is in the area with the red border? Is that another DIV with another GoJS Diagram?

My second question is: are you using go-debug.js and checking the console output for any warnings or errors? Certainly if there are any errors you will need to fix them before you can make progress on other things.

首先很感谢你阅读我的问题,并且也是正确理解了我的问题,其次就是红色框区域是iframe外面的内容,它是一个导航,并不是带有gojs图的div。我的gojs图是画在iframe里面的,就是黑色框部分,控制台也没有发生任何错误或者告警

Almost always it’s an unhandled error that causes the behavior that you are seeing.

GoJS doesn’t implement drag-and-drop between a Diagram and some other HTML element. You could implement that using HTML drag-and-drop, such as in: HTML Drag and Drop, and external Clipboard pasting

Is there a way to reproduce the problem in any of the GoJS samples? I’m unable to do so. But it’s late so I’ll look into this tomorrow.

谢谢,我会尝试着修改

That’s interesting – no mouse events in an iframe get delivered to the original element. Yet mouse events continue to be delivered even when the mouse is completely outside the browser window.

We’ll need to consider what the right behavior should be. I’m not sure how much control we have, though, so we might not be able to make any changes.

In GoJS, we capture events during some operations. This lets you drag a node even outside the browser and the event still works.

But you cannot capture over other iFrames, possibly for browser security reasons. Instead, if you have an iFrame, you need to make it send events back to the main window.

Here is an example of how to do that. Try dragging a node over the iFrame:

https://codepen.io/simonsarris/pen/KovwJa?editors=1010

谢谢西蒙的回答,很好的解决了我的问题