Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecto Drag effect not in pointer position #135

Open
MuhammadFadhil10 opened this issue Jun 6, 2023 · 7 comments
Open

Selecto Drag effect not in pointer position #135

MuhammadFadhil10 opened this issue Jun 6, 2023 · 7 comments
Labels
question Further information is requested

Comments

@MuhammadFadhil10
Copy link

Environments

  • Framework name: React.js
  • Framework version: 18.2.0
  • Component name:
  • Component version:
  • Testable Address(optional):

Description

selecto drag effect is far from pointer when the selecto container is scaled?

@daybrush daybrush added the question Further information is requested label Jun 6, 2023
@daybrush
Copy link
Owner

daybrush commented Jun 6, 2023

Could you try setting the rootContainer to no scaled container?

<div class="container" style={{
  transform: "scale(1.5)"
}}>
<Selecto
    rootCotnainer={document.body}

/>
</div>

@MuhammadFadhil10
Copy link
Author

MuhammadFadhil10 commented Jun 6, 2023

Its still same, here's my code:

  • selecto:
<Selecto
            ref={selectoRef}
            boundContainer={true}
            rootContainer={document.body}
            selectableTargets={[".items"]}
            hitRate={0}
            selectByClick={true}
            selectFromInside={false}
            toggleContinueSelect={["shift"]}
            ratio={0}
            onDragStart={(e) => {
              const moveable = moveableRef.current!;
              const target = e.inputEvent.target;
              if (
                moveable.isMoveableElement(target) ||
                targets.some((t) => t === target || t.contains(target))
              ) {
                e.stop();
              }
            }}
            onSelect={(e) => {
              setTargets(e.selected);

              if (!e.added[0]?.dataset) return setActiveId("");

              setActiveId(e.added[0].dataset.id as string);
            }}
            onSelectEnd={(e) => {
              if (e.selected.length === 0) return;

              const moveable = moveableRef.current!;
              if (e.isDragStart) {
                e.inputEvent.preventDefault();

                moveable.waitToChangeTarget().then(() => {
                  moveable.dragStart(e.inputEvent);
                });
              }
            }}
          />
  • selecto scaled container:
    <Stack
     component="section"
     ref={drop}
     className="container"
     sx={{
       width: "100vw",
       minHeight: "100vh",
       // alignSelf: "center",
       position: "relative",
       overflowX: "hidden",
       boxShadow: 5,
       backgroundColor: "white",
       scale: "0.7",
     }}
   >
     <div
       ref={droppableContainerRef}
       style={{ width: "100%", height: "100%" }}
     >
       <MoveableRender ref={droppableContainerRef} />
     </div>
   </Stack>

demo video:

web-edit-google-chrome-2023-06-06-13-28-54_uBumEH4S.mp4

@daybrush
Copy link
Owner

daybrush commented Jun 6, 2023

@MuhammadFadhil10

Could you try using transform: scale(value) instead of the scale property?

@daybrush
Copy link
Owner

daybrush commented Jun 6, 2023

@MuhammadFadhil10

If it doesn't work, is there any codesandbox I can test?

@MuhammadFadhil10
Copy link
Author

@MuhammadFadhil10

Could you try using transform: scale(value) instead of the scale property?

this is work, now the selecto effect back to normal

@hqiaozhang
Copy link

I also encountered the same problem, but using transform: scale (value) install of the scale property? Failed to solve the problem

@daybrush
Copy link
Owner

@hqiaozhang

So did you use rootContainer together?

Transform should not be used outside of the rootContainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants