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

Disabled plugins should not bind events #1611

Closed
OkanEsen opened this issue Aug 23, 2019 · 5 comments
Closed

Disabled plugins should not bind events #1611

OkanEsen opened this issue Aug 23, 2019 · 5 comments
Labels

Comments

@OkanEsen
Copy link

OkanEsen commented Aug 23, 2019

Problem:

I'm using the UMD version of SortableJS which has all plugins already bundled. The multidrag plugin is disabled by default, but the events on document are still set, regardless if multiDrag is set to true or false.

Another idea would be to introduce a method inside PluginManager to unmount plugins.

@owen-m1
Copy link
Member

owen-m1 commented Aug 23, 2019

This is so that the plugin can be dynamically enabled even after initialisation. Is there a reason the events should not be set?

If you are not using multiDrag at all I would recommend you use the tree-shakeable modular version

@OkanEsen
Copy link
Author

This is so that the plugin can be dynamically enabled even after initialisation. Is there a reason the events should not be set?

I'm using it on a legacy project in combination with jQuery (https://github.com/SortableJS/jquery-sortablejs) and need to generate dynamic lists with a SortableJS instance attached to it. This is working but creating new instances of SortableJS also creates multiple events on the document node, since it's always reattaching it.

If you are not using multiDrag at all I would recommend you use the tree-shakeable modular version

Unfortunately not possible, since it's a legacy project.

@owen-m1
Copy link
Member

owen-m1 commented Aug 23, 2019

@OkanEsen I just realized that the multiDrag events may not be being removed from the document if a Sortable is destroyed but multiDrag isn't enabled.

Also, you could create a separate folder and just build the modular versions yourself without MultiDrag and it should give you a UMD.

@owen-m1 owen-m1 added the bug label Aug 23, 2019
@OkanEsen
Copy link
Author

OkanEsen commented Aug 24, 2019

@OkanEsen I just realized that the multiDrag events may not be being removed from the document if a Sortable is destroyed but multiDrag isn't enabled.

Yeah, exactly. I noticed that the page was becoming a huge resource hog after destroying and creating several instances of SortableJS which were events bound by the MultiDrag plugin (see attachment below).

2019-08-24_15-13

Also, you could create a separate folder and just build the modular versions yourself without MultiDrag and it should give you a UMD.

I'm going to do this for now, thanks.

@owen-m1
Copy link
Member

owen-m1 commented Sep 2, 2019

I solved the bug so I will close this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants