-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Add the ability to limit Draggables to a single axis #17587
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
Conversation
| /// than in a scroll because the draggable widget, being the more specific | ||
| /// widget, will out-compete the [Scrollable] for vertical gestures. | ||
| /// | ||
| /// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove one extra blank line here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| return velocity; | ||
| } | ||
| return new Velocity( | ||
| pixelsPerSecond: _restrictAxis(velocity.pixelsPerSecond)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put this all on one line or put a comma after the first ) so that the next one ends up on the next line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| Offset _restrictAxis(Offset offset) { | ||
| if (axis == null) { | ||
| return offset; | ||
| } else if (axis == Axis.horizontal) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can omit the else if you have a return in the previous block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
This reverts commit 5159ab3.
This reverts commit 5159ab3.
Part 1 of solving #16763.
This adds a new field to the Draggable API: axis. Behavior covered in the DartDoc, but setting it limits the underlying _DragAvatar's motion to the assigned axis. When axis is null, the behavior is the same as before. As a result, this won't break anything.