elm-visualization icon indicating copy to clipboard operation
elm-visualization copied to clipboard

ForceDirectedGraph example: node does not follow mouse on drag.

Open Anton-4 opened this issue 5 years ago • 3 comments

Clicking on a circle results the circle to be displaced with some offset from the mouse. This offset gets larger as the drag coordinates get larger. So at (x:0, y:0) the circle is located at the position of the mouse, for larger coordinates this is no longer the case. This offset getting larger implies the drag coordinates are erroneously multiplied by some factor.

I looked around somewhat but could not find the cause of this bug.

image image image

Anton-4 avatar Jun 08 '20 18:06 Anton-4

Did you get this issue when running the example in isolation (aka outside the examples website?)

This is a problem with responsive SVG scaling. I've been working on solutions but Elm is unfortunately missing some SVG methods to make this straightforward. You can see https://github.com/gampleman/elm-visualization/pull/86 for an example that solves this problem.

gampleman avatar Jun 09 '20 08:06 gampleman

Yes it did happen in isolation.

Alright, I'll see if I can transfer the solution from #86.

Anton-4 avatar Jun 09 '20 08:06 Anton-4

We'll merge #86 soon-ish. I'd like to keep some of the complexity out if possible. I suspect that the simplest solution for this would be just to set the SVG width and height attributes.

gampleman avatar Jun 09 '20 09:06 gampleman

AFAIK this can be closed? I don' think there is a staightforward fix, apart from doing some of the stuff in the example.

gampleman avatar Jul 24 '23 12:07 gampleman