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

fix boxZoom bug #4528

Merged
merged 2 commits into from
Apr 18, 2017
Merged

fix boxZoom bug #4528

merged 2 commits into from
Apr 18, 2017

Conversation

mollymerp
Copy link
Contributor

fix #2237 where disabling then re-enabling the boxZoomHandler would result in a bug where the drag handler would be erroneously active after a boxZoom triggered mouseup event

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

// if boxZoom is disabled and then re-enabled, the drag_pan event listener for mousedown will fire before
// the boxZoom event listener, so map.boxZoom.isActive() will return false resulting in an erroneous
// drag on mousemove once the boxZoom is released, so we need this additional check.
if (map.boxZoom && e.shiftKey && e.button === 0) return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this check also include max.boxZoom.isActive()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the reason for this check is because map.boxZoom.isActive() returns false if BoxZoomHandler is disabled / re-enabled, so, no 🙃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I need to re-word this comment to make that more clear. its due to the firing order of event listeners attached to the keydown event.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh dear 🤦‍♂️. I swear I really did read that comment , but then got turned upside-down thinking about event logic...

What made me ask was thinking about something like:

  • mousdown: start dragpan
  • press (and hold) shift
  • mouseup: i think the expectation would be to stop panning, but this check would prevent that from happening (if I'm reading it right?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right this is no bueno! thanks for catching. I'll rethink how to handle this 💭

Copy link
Member

@mourner mourner left a comment

Choose a reason for hiding this comment

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

This is ready now, right? @mollymerp

@mollymerp
Copy link
Contributor Author

Yep! Thanks @mourner

@mollymerp mollymerp merged commit af9bcad into master Apr 18, 2017
@mollymerp mollymerp deleted the box-zoom-fix branch April 18, 2017 16:58
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.

Disabling and enabling the box zoom interaction messes it up
3 participants