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

Issue with wrapper divs #51

Open tlrib opened 1 month ago

tlrib commented 1 month ago

Great library!

I have an use case where I would need to use it with an additional wrapper div between the swapy-slot and swapy-item like so:

<div class="section-1" data-swapy-slot="slot1">
  <div id="mydummydiv">
    <div class="content-a" data-swapy-item="item1">
      <!-- Your content for content-a goes here -->
    </div>
  </div>
</div>

When I do it like this, I get this error:

image

It looks to me that this is happening because of this validation that only takes into account the first child:

https://github.com/TahaSh/swapy/blob/d348da360ed1c7d7cb9c277b8b4dcbfe40db93c7/src/instance.ts#L50

Is it possible for this validation to be relaxed?

Thanks!