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

map#isMoving #3068

Closed
wants to merge 8 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions js/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,21 @@ util.extend(Map.prototype, /** @lends Map.prototype */{
return true;
},

/**
* Returns a Boolean indicating whether the map is currently in a "moving" state.
* Returns `false` if zooming, rotating, pitching, and dragging are all inactive.
*
* @returns {boolean} A Boolean indicating whether the map is moving.
*/
isMoving: function() {
if (this.zooming ||
this.rotating ||
this.pitching ||
this.dragPan._active ||
this.dragRotate._active) 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.

Interesting that we need to mix the "interaction handler" layer of abstraction the "camera" layer of abstraction to compute Map#isMoving. Should Map#isMoving return true if the user starts a "drag rotate" interaction but doesn't actually rotate the map? Or if the user starts a "drag pan" interaction but doesn't pan the map?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good questions! I'm not familiar enough with these interactions enough to know the differences. The only way I was able to capture "pan" and "rotate" actions was through those dragPan and dragRotate parameters, though. Are there other places to look for them?

Should Map#isMoving return true if the user starts a "drag rotate" interaction but doesn't actually rotate the map?

I'm not sure - any chance you could provide a case where this happens?

Copy link
Contributor

Choose a reason for hiding this comment

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

The only way I was able to capture "pan" and "rotate" actions was through those dragPan and dragRotate parameters, though. Are there other places to look for them?

We may need to create the place to look for this state by

  • creating map.panning property
  • ensuring that map.rotating and map.rotating works with the dragRotate handler

I'm not sure - any chance you could provide a case where this happens?

Imagine I click and drag the map by 5 pixels, initiating a "drag pan" gesture, put a rock on my mouse button, and go for lunch. Map#isMoving will be true the whole time I'm gone but the map won't be moving. Is that the behaviour we want? I'm not sure. It deserves some discussion.

return false;
},

/**
* Update this map's style and sources, and re-render the map.
*
Expand Down