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

What is the intended way to abort a drag operation, conditionally in this library? #118

Open
Azravos opened this issue Sep 23, 2024 · 0 comments

Comments

@Azravos
Copy link

Azravos commented Sep 23, 2024

The only way I've managed to accomplish this is by overriding onPointerDown on the draggable item and then use event.stopPropagation() when the condition is true.

However i quickly noticed that this method had some downsides. I need to play an animation on another element when the condition is true. Which now means that the animation will play as soon as someone clicks on the element and not only when a drag operation starts.

What is the intended way to solve this currently?

Edit example:

const TestComponent = () =>
{

    const someCondition = createMemo<boolean>(() => false);

    const handleDragStart: DragEventHandler = (e) =>
    {
        if(someCondition() == true)
        {
            //something like drag.abort() here or return false or something?
        }
    }

    const handleDragEnd: DragEventHandler = (e) =>
        {
            //.. do stuff
        }

    return (
        <DragDropProvider onDragStart={handleDragStart}
                          onDragEnd={handleDragEnd}>

        </DragDropProvider>
    )
}
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