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 circles, squares, and boxes to be drawn in freehand mode #5970

Merged
merged 1 commit into from
Oct 15, 2016
Merged

Allow circles, squares, and boxes to be drawn in freehand mode #5970

merged 1 commit into from
Oct 15, 2016

Conversation

tschaub
Copy link
Member

@tschaub tschaub commented Oct 14, 2016

This makes it so the draw interaction can be used to draw circles, squares, and boxes in "freehand" mode. For example, to draw a circle you press down, drag, and release. This conforms with the drawing behavior people encounter in other tools.

Copy link
Member

@ahocevar ahocevar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this makes it more intuitive. Thanks!

@tschaub
Copy link
Member Author

tschaub commented Oct 15, 2016

Thanks for the review @ahocevar. I also wanted to make it easy to enable freehand mode without a modifier key. The change in 139c888 makes this possible.

Previously, using ol.events.condition.always would not work because the check for freehand mode in the pointerdown handler would never be reached if there was no modifier key (we first checked ol.events.condition.noModifierKeys). So, the new behavior is to first check if we're in freehand mode and if not only handle down if the main condition is met (no modifier by default).

As a convenience, I added a freehand option to the interaction. This makes it so people don't have to know about and include ol.events.condition.always in their builds.

@tschaub
Copy link
Member Author

tschaub commented Oct 15, 2016

I'm tempted to make it so pointerup ends drawing if in freehand mode (for all shape types). This is how circle drawing now works (as well as box and square in the draw features example). Line and polygon drawing still require clicking the last point to finish.

@tschaub
Copy link
Member Author

tschaub commented Oct 15, 2016

I've removed 139c888 from this branch. I'll open up a separate PR with that change (see #5973). I'll also separately address the issue about finishing in freehand mode.

@tschaub tschaub merged commit 8d68d68 into openlayers:master Oct 15, 2016
@tschaub tschaub deleted the freehand-shape branch October 15, 2016 11:36
@ahocevar
Copy link
Member

I'm tempted to make it so pointerup ends drawing if in freehand mode (for all shape types).

I'd be in favor of this @tschaub

@tschaub
Copy link
Member Author

tschaub commented Oct 15, 2016

I'd be in favor of this @tschaub

I'll create a PR for it.

@tschaub
Copy link
Member Author

tschaub commented Oct 16, 2016

The change in #5975 makes it so drawing starts on pointerdown and ends on pointerup while in freehand mode.

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.

None yet

2 participants