mapbox / mapbox/mapbox-gl-js

Make camera methods noops if its parameters leave the camera unchanged

Open
#6,735 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

api :memo: breaking change :warning: needs discussion :speech_balloon:
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.