From 406c643974ca1cd89d32cdd12e33c87f652e3ae2 Mon Sep 17 00:00:00 2001 From: Hannes Koksch <85571517+hanneskoksch@users.noreply.github.com> Date: Sat, 12 Oct 2024 01:07:59 +0200 Subject: [PATCH] Add non-highlighted attribute Attribute can be used to style non-dragged (so non-highlighted) slots during drag and drop --- src/veloxi-plugin/SwapyPlugin.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/veloxi-plugin/SwapyPlugin.ts b/src/veloxi-plugin/SwapyPlugin.ts index 461887b..3b35615 100644 --- a/src/veloxi-plugin/SwapyPlugin.ts +++ b/src/veloxi-plugin/SwapyPlugin.ts @@ -419,6 +419,17 @@ export const SwapyPlugin: PluginFactory = ( } draggingEvent = event updateDraggingPosition() + + slots.forEach((slot) => { + slot.element.removeAttribute('data-swapy-highlighted') + + if (typeof slot.element.dataset.swapyHighlighted === 'undefined') { + slot.element.dataset.swapyNonHighlighted = ''; + } else { + slot.element.removeAttribute('data-swapy-non-highlighted'); + } + }); + slots.forEach((slot) => { if (!slot.intersects(event.pointerX, event.pointerY)) { if (slot !== draggingSlot) { @@ -474,6 +485,7 @@ export const SwapyPlugin: PluginFactory = ( } else { slots.forEach((slot) => { slot.element.removeAttribute('data-swapy-highlighted') + slot.element.removeAttribute('data-swapy-non-highlighted'); }) draggingItem.position.reset() draggingSlot = null