mapbox / mapbox/mapbox-gl-js

clickTolerance for draggable markers

Open
#9,636 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Motivation

Clicking without moving the mouse at all is hard. For this reason, tiny pointer movements while down on marker should be treated as clicks not drags. In other words, markers should have a clickTolerance option similar to the map.

I considered posting this as a bug report, but since some design decisions are involved, I made it a feature. Here's a jsfiddle with a minimal example: https://jsfiddle.net/cchudzicki/q0bg7r18/11/

// example fiddle console log:

pointer down
pointer down and moving
marker dragstart
(x12): pointer down and moving
pointer up
marker dragend: pointer moved: 0.800018310546875
map click

Design Alternatives

I see three possibilities:

  1. Use map's clickTolerance as the marker `clickTolerance. Anything below will this will be treated as a click not a drag.
  2. Have separate clickTolerances for each marker and for the map AND use the default marker tolerance as some specific value, e.g., "3px"
  3. Have separate clickTolerances for each marker and for the map AND set the default marker tolerance to match map tolerance.

Design

I believe we should implement Option 2 or 3, though I lean toward 3 because users probably want the same drag tolerance throughout their app.

Mock-Up and Concepts

Just add a clickTolerance option for markers.

Implementation

I am looking into this, but imagine something similar to how the map drag threshold works.

See related discussion: https://github.com/mapbox/mapbox-gl-js/issues/9624

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 by reading the map drag threshold implementation and the related discussion in issue #9624. Define how marker movement below and above the tolerance should be classified, then verify that small movements remain clicks while larger movements trigger marker dragging.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.