ITADN

Fix: allow for empty slots to exist at setup-time (fixing TypeError, Cannot read properties of Undefined)

#79Pull Requestmaxtheman 创建于 2024-10-11
M
maxthemancommented
**ISSUE** Since upgrading from version 0.31, I got these issues from createSwapy, making it unusable. After getting this error, swapy fails to work. <img width="400" alt="Screenshot 2024-10-10 at 3 50 48 PM" src="https://github.com/user-attachments/assets/1f26145b-b334-4568-932a-ca38e61d0e2b"> <img width="871" alt="Screenshot 2024-10-10 at 3 51 07 PM" src="https://github.com/user-attachments/assets/5c97d7d4-a06d-4ab9-9311-7097fd70e882"> **FIX** 1. Moved ScrollContainer to onDrag for dynamic container setting. The cause of the above error is that the current code assumes that every container has an item in it, but I have no items rendered on the screen at the outset, and only an empty slot for dropzones, that I dynamically swap out for full slots later. I also moved the scrollContainer to be activeScrollConteiner, similar to draggedItem in swapyPlugin. This has an added benefit of dynamically picking a scroll container at drag-time, instead of picking one at setup which may change/disappear if the DOM changes outside of swapy. 2. Added data-swapy-no-scroll to allow devs to stop certain slots from triggering scrolling. Similar to the data-text-swapy, I didn't want every slot to trigger UI scrolling. This adds a little more flexibility, rather than everything scrolling, or eveything not scrolling. I tested both of these fixes in my project using swapy and they work well.
合并状态:未合并 关闭于 2024-11-13 6 条评论