TahaSh / swapy

✨ A framework-agnostic tool that converts any layout into a drag-to-swap one with just a few lines of code https://swapy.tahazsh.com/
MIT License
5.86k stars 114 forks source link

Enable API throw an error #1

Closed diervo closed 2 months ago

diervo commented 3 months ago

I tried to debug it, but locally is minified and I just didn't have much time to dig into your plugin lifecycle.

version: 0.0.5

The following code:

this.swapy = createSwapy(propertiesContainer);
this.swapy.enable(true);

Throws:

Error: You can't call getPlugin for Swapy with key: undefined because it does not exist in your app
diervo commented 3 months ago

After some debugging seems to be due to the fact that Im instantiating Swapy inside a Shadow

TahaSh commented 3 months ago

@diervo Thank you for reporting this issue. Unfortunately, Veloxi (which was used to create Swapy) only works directly on the DOM and can't be used with the shadow DOM. The only case I can think of where it might work with web components is if you are using item content as components. For example:

<div data-swapy-slot="1">
  <div data-swapy-item="a">
     <my-component></my-component>
  </div>
</div>

But that might not be what you want. Sorry! 😞