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

In infiniteviewer, there is an error using the start position of selecto #87

Closed hhbusui closed 2 years ago

hhbusui commented 2 years ago

The components are the latest version

Description

Hello author, in infiniteviewer, there is an error using the start position of selecto。

In addition, I also use the react-grid-layout component

The code is as follows:

       <InfiniteViewer>
          <Selecto
            dragContainer={".react-grid-layout"}
            selectableTargets={[".react-grid-layout .react-grid-item"]}
            onSelect={e => {
              e.added.forEach(el => {
                console.log(el.classList);
                el.classList.add("selected");
              });
              e.removed.forEach(el => {
                console.log(el.classList);

                el.classList.remove("selected");
              });
            }}
            // container={document.querySelector(".container")}
            rootContainer={document.body}
            hitRate={0}
            selectByClick={true}
            selectFromInside={true}
            continueSelect={false}
            continueSelectWithoutDeselect={true}
            toggleContinueSelect={"shift"}
            toggleContinueSelectWithoutDeselect={[["ctrl"], ["meta"]]}
            ratio={0}></Selecto>
          <ReactGridLayout>
            <div>childItem</div>
          </ReactGridLayout>
        </InfiniteViewer>

image

daybrush commented 2 years ago

@h1530687053

The selecto must not be in an Infinite Viewer.


<Selecto />
<InfiniteViewer>
    <ReactGridLayout>
            <div>childItem</div>
          </ReactGridLayout>
</InfiniteViewer>
hhbusui commented 2 years ago

image

thanks for your time and reply, but , I use the way you said to change the code. After the box is selected, the scroll bar will not be triggered. As shown in the above figure.

daybrush commented 2 years ago

@h1530687053

use scrollOptions

scrollOptions={{
        container: // scrollContainer,
        throttleTime: 30,
        threshold: 0,
    }}
hhbusui commented 2 years ago

Thank you, author. I think I found the answer from your edit project.