Mobius1 / Selectable

Touch enabled selectable plugin inspired by the jQuery UI widget.
MIT License
144 stars 21 forks source link

Can sequential selection be improved? #32

Closed mkucej closed 4 years ago

mkucej commented 4 years ago

Thank you for this great library. We use it to allow users to select text and add highlights to PDFs in a web browser. The issue is that when a user starts the lasso outside of the first element, all previous elements are added to the selection. This can be reproduced in your demo page for 'lassoSelect` option. We work around the issue like this:

let selectable = new Selectable({
    lassoSelect: 'sequential'
});

selectable.on('start', function (e, item) {
    if(typeof item === 'object') {
        // User started the lasso inside an item. Allow selecting.
        This.selectable.off('end');
        This.selectable.on('end', method);
    } else {
        // User started the lasso outside an item. Disallow selecting.
        This.selectable.off('end');
    }
});

Just thought I would let you know of this.

Mobius1 commented 4 years ago

I can't seem to reproduce this. What browser are you using?

mkucej commented 4 years ago

Thanks for the quick answer. I should have been more clear. Try it like this:

  1. Place the cursor in the white space between square 14 and 15.
  2. Drag the cursor to the right and down to select.

You will see that all squares were selected starting from the 1st, although the user probably wanted to start from square 15. The problem occurs in all browsers I tried — FF, Chrome, Edge.

Mobius1 commented 4 years ago

That did it. I'll have a look what's going on and get a fix out.

Mobius1 commented 4 years ago

This should be fixed in the latest release.

mkucej commented 4 years ago

Works well. Thanks!