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.07k stars 83 forks source link

How to change rect-selection size when container scroll #55

Open yoole5699 opened 3 years ago

yoole5699 commented 3 years ago

Environments

Description

Is there a way to autoChange rect-selection size when container is dragging and outer container(e.g window) is scolling? Currently,when outer container scrolls, the rect-selection only change pos(size not change)。 selectto-capture

daybrush commented 3 years ago

@yoole5699

You have a few things to change.

  1. container
    
    setScrollOptions({
      container: document.body,
      getScrollPosition: () => [
        document.documentElement.scrollLeft,
        document.documentElement.scrollTop
      ],
    ...
    });
  2. onScroll
onScroll={(e) => {
            document.documentElement.scrollBy(
              e.direction[0] * 10,
              e.direction[1] * 10
            );
          }}

https://codesandbox.io/s/zen-proskuriakova-b3l7y?file=/src/App.tsx:1979-1994

It has been confirmed that we also have getScrollPosition bug. I'll fix it.

yoole5699 commented 3 years ago

@yoole5699

You have a few things to change.

  1. container
setScrollOptions({
      container: document.body,
      getScrollPosition: () => [
        document.documentElement.scrollLeft,
        document.documentElement.scrollTop
      ],
   ...
});
2.  onScroll

```js
onScroll={(e) => {
            document.documentElement.scrollBy(
              e.direction[0] * 10,
              e.direction[1] * 10
            );
          }}

https://codesandbox.io/s/zen-proskuriakova-b3l7y?file=/src/App.tsx:1979-1994

It has been confirmed that we also have getScrollPosition bug. I'll fix it.

hi @daybrush ,thanks for reply! I try the new demo.It seems still not working.When It scrolls, rect-selection size remains unchanged. I hope It can work like marqueeselection

current: error-demo

target: target-demo

ttay24 commented 2 years ago

Hi, I've also run into this issue and I'm wondering if there's any work around now compared to in September? Thanks! This is an awesome library

na2793 commented 2 years ago

I'm also looking forward to hearing an answer on this. This will be very useful.

daybrush commented 2 years ago

@ttay24 @na2793 @yoole5699

How about now? It seems to work well for the current demo (1.14 version)? https://codesandbox.io/s/angry-albattani-2uu9kg?file=/src/App.tsx

na2793 commented 2 years ago

It doesn't seem to work well. Here's a capture of the codesandbox preview.

daybrush commented 2 years ago

@ttay24 @na2793 @yoole5699

selecto's new version is released and see this demo: https://codesandbox.io/s/angry-albattani-2uu9kg?file=/src/App.tsx

And storybook also updated.

https://daybrush.com/selecto/storybook/?path=/story/selecto--select-in-the-scroll-area

Thank you :)

na2793 commented 2 years ago

It works perfectly. I appreciate for your efforts.

ttay24 commented 2 years ago

Can also confirm it's working for me! Thanks!

claudiabdm commented 2 years ago

Hi! I'm facing a similar issue when the scroll container increases its height when more items are added. If don't set a boundContainer, the selection rect won't select the items anymore and if I set it, the selection rect won't increase its height while scrolling. Is there something I might be missing? Thank you!

Here's a codesanbox with an example: https://codesandbox.io/s/confident-sun-etvlcb?file=/src/App.tsx

na2793 commented 2 years ago

@claudiabdm I had the same problem before. Check out the link below. https://daybrush.com/selecto/release/latest/doc/Selecto.html#findSelectableTargets I hope this helps.

claudiabdm commented 2 years ago

@claudiabdm I had the same problem before. Check out the link below. https://daybrush.com/selecto/release/latest/doc/Selecto.html#findSelectableTargets I hope this helps.

That's perfect, thank you! It's working great although when the boundContainer is set the selection rect won't change its height but that might be a different issue.