Skip to content

How can I prevent dragging of elements selected by a port when validateMagnet is false? #2877

Answered by Geliogabalus
james-ep01 asked this question in Q&A
Discussion options

You must be logged in to vote

With this demo in mind you can specify validateMagnet callback as follows:

  validateMagnet: function (cellView, magnet, evt) {
    // Note that this is the default behavior. It is shown for reference purposes.
    // Disable linking interaction for magnets marked as passive
    if (magnet.getAttribute("magnet") === "passive") {
      cellView.preventDefaultInteraction(evt);
      alert("message");
      return false;
    }

    return true;
  },

preventDefaultInteraction() shows to the paper that it should not trigger interactivity when this event is fired.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@james-ep01
Comment options

Answer selected by Geliogabalus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants