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

Add activatorEvent to DragStartEvent #1140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anilanar
Copy link

Fixes #1139.

@changeset-bot
Copy link

changeset-bot bot commented May 26, 2023

🦋 Changeset detected

Latest commit: 545a41c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@dnd-kit/core Minor
@dnd-kit/modifiers Major
@dnd-kit/sortable Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@anilanar anilanar force-pushed the feat/drag-start-event-activator-event branch from 5ff4b1b to 545a41c Compare May 26, 2023 10:49
@nicostombros
Copy link

@clauderic Is this something that can be merged in?

@Annoiiyed
Copy link

@clauderic Sorry to bump this again, but, I think due to #832 and this not being merged, right now it seems next to impossible to get information on the location of a drag start. Would it be possible to merge this? :)

@stnwk
Copy link

stnwk commented Jan 30, 2024

Pretty please?

@joacoespinosa
Copy link

🙏

@CreativeDive
Copy link

You can access the onDragStart event data using this way. Add an custom onMouseDown event to the handle and don't forget to pass the listeners.onMouseDown(e); too:

const ResizeHandle = ({ id, axis, side, onResizeStart, onResize }) => {
    const { attributes, listeners, setNodeRef, transform } = useDraggable({
        id,
    });

    useEffect(() => {
        if (transform) {
            onResize(transform, id);
        }
    }, [transform, onResize, id]);

    const handleMouseDown = (e) => {
        onResizeStart(e, id);
        if (listeners.onMouseDown) {
            listeners.onMouseDown(e);
        }
    };

    return (
        <div
            ref={setNodeRef}
            {...listeners}
            {...attributes}
            onMouseDown={handleMouseDown}
            className={`resize-handle resize-handle-${axis} resize-handle-${side}`}>
            <div className='wphave-handle' />
        </div>
    );
};

@Ethorsen
Copy link

Also need the activatorEvent in dragStart. Will implement a sketchy work-around for now

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

Successfully merging this pull request may close these issues.

Expose activatorEvent for onDragStart
7 participants