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

Allow draggable.start to cancel a drag #338

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

Conversation

aminer-looker
Copy link

For some uses, the user shouldn't be able to initiate a drag from
just anywhere within the gridster item element or under certain
changable conditions. The current implementation offers no way for
the end user to exert such control over dragging.

This change allows end users to cancel a drag by returning the string
"cancel" from their draggable.start function. Any other return
value will allow the drag to continue.

Other API interfaces would be better (e.g., return true to start
the drag and false to cancel), but any API which requires a
specific to continue the drag would not be backward compatible. This
solution only looks for a specific value, and only invokes the new
functionality in that case.

For some uses, the user shouldn't be able to initiate a drag from
just anywhere within the gridster item element or under certain
changable conditions. The current implementation offers no way for
the end user to exert such control over dragging.

This change allows end users to cancel a drag by returning the string
"cancel" from their `draggable.start` function. Any other return
value will allow the drag to continue.

Other API interfaces would be better (e.g., return `true` to start
the drag and `false` to cancel), but any API which requires a
specific to continue the drag would not be backward compatible. This
solution only looks for a specific value, and only invokes the new
functionality in that case.
@danomatic
Copy link
Member

Nice! Question: why return 'cancel' versus false? Which is more conventional?

@aminer-looker
Copy link
Author

aminer-looker commented Jul 19, 2016

It's been a while since I wrote this, but if I recall correctly, a falsy value was already being interpreted to mean that everything was okay, so I couldn't use that. I needed to return some other value which indicated the callback wanted to cancel the operation, so...

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.

2 participants