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

Don't reuse Map#{moving,zooming} state #6183

Merged
merged 3 commits into from
Feb 17, 2018
Merged

Don't reuse Map#{moving,zooming} state #6183

merged 3 commits into from
Feb 17, 2018

Conversation

jfirebaugh
Copy link
Contributor

Instead, implement isMoving and isZooming using the independent state that the relevant handlers already track.

Fixes #6173.

@anandthakker
Copy link
Contributor

There's at least one place where we're reading the map.zooming, etc. properties directly:

mapbox-gl-js/src/ui/map.js

Lines 1529 to 1530 in 38c7250

rotating: this.rotating,
zooming: this.zooming,

As a way to sweep for those and also since map.{zooming,rotating,moving} should be behind getters anyway, should we rename these to map._{zooming,rotating,moving}?

@jfirebaugh
Copy link
Contributor Author

@anandthakker Ready for second-pass review here.

test('Map#isMoving returns true when drag panning and scroll zooming interleave', (t) => {
const map = createMap();

map.on('dragstart', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a quick comment here that we're expecting the events to come in the order they're listed here?

*/
isZooming(): boolean {
return this._zooming ||
this.scrollZoom.isActive();
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.doubleClickZoom.isActive() also be called here?

Copy link
Contributor Author

@jfirebaugh jfirebaugh Feb 17, 2018

Choose a reason for hiding this comment

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

DoubleClickZoomHandler implements the zoom using zoomTo, which will set _zooming, so it isn't strictly necessary. (In fact I think DoubleClickZoomHandler should probably not have an isActive() method at all. Unlike drag panning/rotating, where there's an interval bookended by down/up events, double-clicking is an instantaneous action.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DoubleClickZoomHandler #isActive() turns out to be used internally, so I'll abandon that idea for now.

Instead, implement isMoving and isZooming using the independent state that the relevant handlers already track.
@jfirebaugh jfirebaugh merged commit ae30a34 into master Feb 17, 2018
@jfirebaugh jfirebaugh deleted the fix-6173 branch February 17, 2018 01:26
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.

3 participants