Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Before Drop event called AFTER Connection Moved event #89

Open
Legendary4226 opened this issue May 15, 2023 · 5 comments
Open

Before Drop event called AFTER Connection Moved event #89

Legendary4226 opened this issue May 15, 2023 · 5 comments

Comments

@Legendary4226
Copy link

Legendary4226 commented May 15, 2023

Hi 👋,
I need help as explained in the title.
I need to do some checks BEFORE the connection is dropped, for example : "Check if the two elements (source and target) are already connected ?"

How I proceed :
Call instance.getConnections({}, true) between the source and target. Place result in a var.
Check if var.lenght > 0 then a connection between the two elements already exists.

But it can't work because (and I checked) the EVENT_CONNECTION_MOVED is firered BEFORE INTERCEPT_BEFORE_DROP.

I need multiple connections enabled but not multiple between two same endpoints.

Do you have any ideas or did the event fire order needs to be changed ?

Thank's

Edit: I'm using the 6.0.5 version of JSPlumb

@Legendary4226
Copy link
Author

Up ?

@sporritt
Copy link
Member

sporritt commented Jun 7, 2023

does the before drop interceptor not have the information you need in order to determine whether or not the drop should be allowed?

@Legendary4226
Copy link
Author

Legendary4226 commented Jun 7, 2023

Hi,

I've searched a lot and couldn't tell to differentiate if the connection was moved or created.
And I can't tell if the drop should be allowed because the connection is already created! "var.lenght" returns 2 and not 1.

But now I've tried using "maxConnection" when setting up endpoints, but I couldn't find out what event was fired (e.g. to replace the connection or alert the user), and the docs don't say much a lot about max connections.

Am I being clear in my explanations ?

@sporritt
Copy link
Member

sporritt commented Jun 7, 2023

"And I can't tell if the drop should be allowed because the connection is already created! "var.lenght" returns 2 and not 1"

I don't mean to be flippant but can you not just test for var.length < 2 ?

@Legendary4226
Copy link
Author

Legendary4226 commented Jun 8, 2023

No :(
It's not consistent with what I want to do

Is there any way of knowing whether the connection affected by the event already exists or is created by this action ?

@sporritt sporritt transferred this issue from jsplumb/jsplumb Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants