daybrush / selecto

Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch.
https://daybrush.com/selecto
MIT License
2.04k stars 82 forks source link

Phantom mouse down with selectFromInside #99

Closed adela-almasan closed 2 years ago

adela-almasan commented 2 years ago

Environments

Description

https://user-images.githubusercontent.com/88068998/187331828-2fd3effe-69aa-4ff6-a47c-3194b4787cf2.mov

Hi! I'm using Selecto with selectFromInside disabled and since I disabled the option, it seems to have created a phantom mouse down issue, which can become an annoyance very quickly. I cannot replicate it on none of the sandboxes online and I was wondering if you might have an idea what could be the issue in this case.

^ Attached you can find a screencast of the issue - I'm never holding down the mouse for a proper drag, the elements are just following my mouse.

this.selecto = new Selecto({
   container: this.div,
   rootContainer: this.div,
   selectableTargets: targetElements,
   toggleContinueSelect: 'shift',
   selectFromInside: false,
});
daybrush commented 2 years ago

@adela-almasan

I'll fix it soon. Thank you :)

daybrush commented 2 years ago

@adela-almasan selecto's new version is released. data event property is added.

The dragEnd event occurs earlier than when the moveable.dragStart method is called. If so, block dragStart like this:

.on("selectEnd", e => {
        if (e.isDragStart) {
            e.inputEvent.preventDefault();

            e.data.timer = setTimeout(() => {
                moveable.dragStart(e.inputEvent);
            }, 100);
        }
    }).on("dragEnd", e => {
        clearTimeout(e.data.timer);
    })
adela-almasan commented 2 years ago

@daybrush That's perfect, thank you!

adela-almasan commented 2 years ago

@daybrush After upgrading I'm having some issues with clickTarget in the existing code - selecto.clickTarget(event, div), attached you can find the console output. Would appreciate your input (datas -> data?). Thank you!

Screen Shot 2022-08-31 at 9 29 58 PM

Screen Shot 2022-08-31 at 9 31 27 PM

daybrush commented 2 years ago

@adela-almasan

selecto's new version is released. Check it again.