Blazor.Diagrams icon indicating copy to clipboard operation
Blazor.Diagrams copied to clipboard

Grid snap to center

Open 240026763 opened this issue 2 years ago • 9 comments

  • Added GridSnapToCenter to DiagramOptions
  • In Drag Behavior, check the option to see if the snap point should be the Top Left (GridSnapToCenter = false) or center of the node (GridSnapToCenter = true).

240026763 avatar Sep 15 '22 16:09 240026763

Did you try this in the demos? I'm guessing that this breaks moving link vertices for example. MovableModel was created to represent all things that can be moved, you can't just not use it alltogether

zHaytam avatar Sep 15 '22 19:09 zHaytam

Indeed it breaks moving links and the snap to grid example.

What about adding Size to MovableModel?

240026763 avatar Sep 15 '22 19:09 240026763

Not all movables require a size though, so that's also not the solution we should go for. For now, try to just make your checks as: Diagram.Options.GridSnapToCenter && movable is NodeModel node, so that it would be a specifial case for nodes only for now.

zHaytam avatar Sep 15 '22 19:09 zHaytam

The Vertices example works again but the Snap To Grid example is broken. Checking develop branch though and it is broken there as well for ServerSide Demo.

240026763 avatar Sep 15 '22 20:09 240026763

Fixed the snap to grid demo crash and added a toggle for Snap to Center.

240026763 avatar Sep 15 '22 21:09 240026763

@zHaytam, do you see anything else that this PR needs in order to get merged?

240026763 avatar Sep 16 '22 21:09 240026763

Just a unit test in DragMovablesBehaviorTests please

zHaytam avatar Sep 16 '22 21:09 zHaytam

Unit Test Theory in place

240026763 avatar Sep 19 '22 19:09 240026763

Just checking on this PR. Anything more to add? I'd love to get this out on nuget in the next beta.

240026763 avatar Sep 21 '22 18:09 240026763

Thank you for the PR!

zHaytam avatar Sep 22 '22 13:09 zHaytam