How to use inspector to change paper properties?

55 views
Skip to first unread message

heng fan

unread,
May 10, 2022, 3:18:27 AM5/10/22
to JointJS
Hi all,

I have read the inspector doc.

Inspector seem not support to change paper properties.

Inspector plugin creates an editor and viewer of cell model properties.

Custom Fields seems unable to change the paper properties.

Is there any way to solve it ?

Thanks

Roman Bruckner

unread,
May 10, 2022, 3:47:56 AM5/10/22
to joi...@googlegroups.com
Hi,

The inspector can edit properties of a model only. The paper is a view.

You can edit the graph (the model of the paper) with the inspector, but we do not store attributes like zoom, origin on the model (because you can have multiple views of the same graph with a different zoom level).

Here's the trick.

// Create a Backbone Model:
m = new Backbone.Model();
// When a property on the model change update the paper property
m.on('change:x', m => paper.translate(m.get('x')));
// This is how you manually set the origin-x
m.set('x', 6);
// Now you can open the inspector for the `m` model and create e.g `range` input for `x` coordinate,

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/ebedc187-a3fa-4ef0-8d74-7332c6476c1an%40googlegroups.com.


--

heng fan

unread,
May 10, 2022, 4:22:30 AM5/10/22
to JointJS
Thank you very mush, helpful as always!
Reply all
Reply to author
Forward
0 new messages