Make camera methods noops if its parameters leave the camera unchanged
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
In `jumpTo`, we currently update `tr.center` and fire `movestart`, `move`, and `moveend`, even if the parameters would leave the transform state unchanged:
https://github.com/mapbox/mapbox-gl-js/blob/1a8e9fec61af6569cb60d074bb07ad7fbc1e9704/src/ui/camera.js#L481-L501
And in `easeTo`, we kick off an animation, even if the target camera options are equivalent to the current transform state.
I propose that in both of these methods, we first check whether the target camera position would be different from the current one, and, if not, then exit early without firing any events (or kicking off a do-nothing animation)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/ui/camera.js at the linked jumpTo and easeTo methods, and trace how each compares camera options with the current transform state. Done means unchanged targets exit without updating the transform, firing camera events, or starting an animation; the issue does not name a test file to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100