Independent paper grid size for links

24 views
Skip to first unread message

Alexander Nestorov

unread,
Feb 7, 2021, 6:58:47 AM2/7/21
to JointJS

The constructor of joint.dia.Paper receives gridSize as one of it's parameters. If set, the paper will behave grid-like, letting me place elements only at the intersections of each vertical and horizontal line of the grid (instead of letting me freely position elements whenever I want).

This is exactly what I want for my elements, but not for my links. If I set the grid size option and then start dragging the end of a link around the paper, it will "jump" from "point" to "point" on the paper.

Is there a way I can set the grid size only for elements and not for links?

Roman Bruckner

unread,
Feb 7, 2021, 9:11:38 PM2/7/21
to joi...@googlegroups.com
Hi Alex,

Right, that makes sense. Please feel free to create an issue on our GitHub. `gridSize` option can be defined as a function which would accept a cell view.

For the time being I think you can do the following:

paper.on('cell:pointerdown', function(cellView) {
   paper.options.gridSize = (cellView.model.isLink()) ? 1 : 10;
});

Best,
Roman

--

---
You received this message because you are subscribed to the Google Groups "JointJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jointjs+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jointjs/43b68020-80e5-4356-87b1-236dc17d7536n%40googlegroups.com.


--

Alexander Nestorov

unread,
Feb 8, 2021, 7:36:42 AM2/8/21
to JointJS
Perfect! The workaround is working as expected; exactly what I was looking for.

Best regards!
Reply all
Reply to author
Forward
0 new messages