Implemented comprehensive drag-and-drop functionality for the Action Button Library:
Visual Feedback:
- Reorder hint appears when 2+ buttons are selected: "Drag and drop buttons to reorder them on your Home Screen"
- Drag handle icon with "Drag to reorder" text on each button slot
- Dragging state: source button fades (opacity 0.5, scale 0.95)
- Drop zone highlighting: blue border and background on target slot
Desktop Support (HTML5 Drag API):
-
draggable="true" attribute on filled slots
- Event handlers: dragstart, dragend, dragover, dragleave, drop
- Tracks dragged slot index and button ID during drag operation
Mobile Touch Support:
- Custom touch event handlers: touchstart, touchmove, touchend
- Uses
document.elementFromPoint() to detect target slot
- Requires minimum 20px movement to trigger swap (prevents accidental drags)
- Touch delegation on container for better performance
Reorder Logic:
- Swap mode: If both source and target slots have buttons, they swap positions
- Move mode: If target slot is empty, button moves to new position
- Shows success message: "Button order updated. Click 'Save Selection' to save changes."
CSS Additions:
.selected-slot.filled { cursor: grab; }
.selected-slot.dragging { opacity: 0.5; transform: scale(0.95); }
.selected-slot.drag-over { border-color: var(--primary); background: rgba(59, 130, 246, 0.15); }
.reorder-hint { background: rgba(59, 130, 246, 0.1); border: 1px dashed var(--primary); }
Files Changed:
- public/actionbuttonlibrary.html - Added drag-drop CSS, HTML hint, and JavaScript handlers