Make elements not connectable

20 views
Skip to first unread message

che

unread,
May 10, 2022, 8:43:32 PM5/10/22
to JointJS
Hi there,

Here I have two elements. The image one is 'joint.dia.Element.define' and text box is 'joint.shapes.standard.Rectangle'
Capture.JPG

I put the port for Image element but I didn't add any code for text box but it is connectable. Is there any way I can make element not connectable?
So, If I drag link to text box element, it shouldn't hover it.

Here is text box code
````````````````````````````````````````````````````````````````````````````````````````````````````
let inputText = document.getElementById('hmiTextBox').value;
        var rect = new joint.shapes.standard.Rectangle();
        rect.position(100, 30);
        rect.resize(70, 25);
        rect.attr({
            label: {
                text: inputText
            }
        });
        rect.addTo(graph);
````````````````````````````````````````````````````````````````````````````````````````````````````

And image code
````````````````````````````````````````````````````````````````````````````````````````````````````
const r5 = joint.dia.Element.define('example.Sensor', {
            size: {
                width: 120,
                height: 48
            },
            attrs: {
                image: {
                xlinkHref: src,
                width: 'calc(w - 6)',
                height: 'calc(h - 6)'
                }
            },
            label: {
                text: deviceid,
                x: 'calc(0.7*w)',
                y: 'calc(0.5*h)'
            },
            ports: {
                items: [ port ] // add a port in constructor
            }
        }, {
            markup: [{
                tagName: 'image',
                selector: 'image'
            }, {
                tagName: 'items',
                selector: 'ports'
            }]
        });
        // draw elements
        const e1 = new r5();
        e1.position(100, 100);

        graph.addCells([e1]);
````````````````````````````````````````````````````````````````````````````````````````````````````


Many thanks!

Roman Bruckner

unread,
May 11, 2022, 11:17:32 AM5/11/22
to joi...@googlegroups.com
You can set `magnet=false` on the `root` element (`root` is the selector of the wrapping SVGGroupElement of the element view).

el.attr('root/magnet', false);


--

---
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/210f91bd-146f-4eed-b1fb-d270dd358f05n%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages