selecto
selecto copied to clipboard
How to drag the selected items?
Environments
- Framework name:vue
- Framework version:3
- Component name: vue3-selecto
- Component version:
- Testable Address(optional):
Description
Hi, I have a problem in my project. I need to select multi items that can be drag and drop to somewhere.but when I try to drag the selected items, selecto will reselect the item which I clicked at and remove the others. How can I prevent the select event when I start drag inside a selected item, and select the item when just click? Hope for reply!
@qinyao86
- use
preventClickEventOnDragoption to true - use
selectFromInsideoption to true - Try calling
.setSelectedTargetsmethod on the your target, item, dom'sclickevent. - Use the Drag API.
I used preventClickEventOnDrag=true and selectFromInside =true, but still not work for me. I used a very complicated method to sovle this: In the onDrag event,determine whether the mouse is on the selected item. If on:
- stop the selecto event(e.stop())
- document.addEventListener("mousedown",onMousedown);
document.addEventListener("mousemove",onMousemove); document.addEventListener("mouseup",onMouseup); - in onMousemove event, I can know the mouse move distance, if distance>=4 : It will trigger the default drag event and no select drag event happen. if distance<4: It means it is a click event, I use setSelectedTargetsByPoints() to select the item by manual.