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

Delay in drag and drop #1609

Open
rahul-dey-ey opened this issue Feb 13, 2025 · 0 comments
Open

Delay in drag and drop #1609

rahul-dey-ey opened this issue Feb 13, 2025 · 0 comments

Comments

@rahul-dey-ey
Copy link

Hi Team,

I am facing delay issue in the drag and drop of a item. I need to modify logic depends on the business requirement. I have attached the following code snap shot.
onMouseDown={() => { clicked = true; }} onMouseMove={(event) => { if (clicked) { var rect = event.currentTarget.getBoundingClientRect(); mousePosition = event.clientX - Math.floor(rect.left); props.onMouseDown(event); localStorage.setItem( "click-position", JSON.stringify({ postion: mousePosition, lengthOfPill: eventMetaData.width, }) );
Here props.onMouseDown function is DnD/toolkit's native mouse down event. This function is only responsible for Drag.

Also I added the Provider Snapshot

<DndContext
collisionDetection={pointerWithin}
onDragStart={(event) => handleDragStart(event, { dispatch })}
onDragEnd={(event) =>
somefunction(event)
}
modifiers={[restrictToWindowEdges]}
sensors={sensors}
>

I used useDraggable and useDropable hook to make the component Draggable and dropable

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

No branches or pull requests

1 participant