mapbox / mapbox/mapbox-gl-js

User triggered zoom* events' originalEvent is undefined until two wheel events are triggered in quick succession

Open
#12,429 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :lady_beetle:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

mapbox-gl-js version: 2.11.0

browser: Firefox, Chrome, Safari, others(?)

Steps to Trigger Behavior
  1. Hover the cursor on the map and scroll the mouse wheel for exactly one step.
Link to Demonstration

https://jsfiddle.net/50kd1ynv/

Expected Behavior

The event's originalEvent property is defined, since the event was triggered by user interaction (DOM event).

Actual Behavior

The event's originalEvent property is undefined, making it seem as though the zoom was triggered programatically.

Additional findings

As long as no wheel events are triggered during a zoom animation, the bug persists. Try scrolling for exactly one step every 1sec, so the zoom animation has time to finish. The originalEvent property remains undefined on subsequent events passed to zoom* event callbacks.

Scrolling the wheel again while a zoom animation is in progress (so, in quick succession) will fix the issue and all further events passed to zoom* event callbacks will have their originalEvent set correctly.

Moving or rotating the map has no effect on this bug, zoom* events still have their originalEvent property undefined if multiple drags and rotations were made by the user beforehand.

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 with the linked JSFiddle and trace the zoom* event path that handles a single wheel event versus a second event during animation. Confirm the behavior across the reported browsers, then verify that user-triggered zoom events consistently expose originalEvent even when the animation has finished.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.