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

How to stop dragging element on ESC? #259

Closed
hyzhak opened this issue Aug 15, 2015 · 8 comments
Closed

How to stop dragging element on ESC? #259

hyzhak opened this issue Aug 15, 2015 · 8 comments

Comments

@hyzhak
Copy link
Contributor

hyzhak commented Aug 15, 2015

I need to stop dragging element and return it to default state on ESC keypress. I'm using interact.stop() but it has bug #258 and even with this fix it doesn't trigger dragend event. So I need to trigger it manually. Is it ok? Maybe there other more convenient way to cancel/stop dragging on-a-fly?

@taye
Copy link
Owner

taye commented Aug 18, 2015

I've merged #258.

Manually creating and triggering a blur event on the window is probably the best way.

@hyzhak
Copy link
Contributor Author

hyzhak commented Aug 18, 2015

@taye thanks :). Why don't you think that interact.js should have such function?

@taye
Copy link
Owner

taye commented Aug 19, 2015

I think it should have it and I'm working on this in #231 but it will take some time.

@hyzhak
Copy link
Contributor Author

hyzhak commented Aug 19, 2015

@taye great, wish you good luck

@salzhrani
Copy link

@taye now that #231 is merged, is such functionality available ?

@taye taye closed this as completed in df963b0 Nov 5, 2015
@taye
Copy link
Owner

taye commented Aug 10, 2016

@hyzhak @salzhrani In the latest unstable build you can use event.interaction.stop() to stop a drag, resize or gesture.

@spierala
Copy link

spierala commented Apr 4, 2019

Hi @taye , when would you call event.interaction.stop() ? If you are dragging and then stop moving the mouse, then there is no event that I could use...
ESC should cancel the drag also if there is no mouse movement.

@mila76
Copy link

mila76 commented Sep 2, 2019

like @spierala i can get how to implement this..
i do a document event on keypress but interactions is not present and in some cases element.target is not the element currently drag but body (even if i currently moving a draggable)

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

5 participants