mapbox / mapbox/mapbox-gl-js

`mousemove` that still fires inbetween `mousedown` and `mouseup`

Open
#11,932 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

api :memo: needs discussion :speech_balloon:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

## Motivation

My particular use case is that I'm trying to create a freehand drawing tool ([this existing library](https://github.com/bemky/mapbox-gl-draw-freehand-mode) isn't working).

In this particular freehand drawing tool, I want lines to be drawable using a mouse after `mousedown` event until `mouseup` event triggers.

## Design Alternatives

I realize that at this point, firing `mousemove` listener inbetween `mousedown` and `mouseup` causes a lot of unintended consequences to many users of this library, including probably the inner workings of this library itself

The simplest solution I can think of at the moment is a new type of event like `mousemovedrag` which is like `mousemove` except it fires also in-between `mousedown` and `mouseup` events. (There's probably a better name other than `mousemovedrag`)

## Design

I'm not very familiar with the implementation of this library.

### Mock-Up

`
map.on('mousemovedrag', () => {
console.log('Yey, I also fire inbetween mousedown and mouseup')
})
`

### Concepts

This can be taught in documentations by adding entries of events under mouse events.

We have an existing very similar concept - mousemove.

We probably don't want to deviate too far from that term, maybe `mousemovealways` or `mousemovedrag` or `mousemoveanddrag`

### Implementation

Not familiar with implementation. But I would imagine I would look for the code that checks if the mouse button is being held down when deciding to fire `mousemove`, and add a logic that dispatches `mousemovedrag` similar fashion as `mousemove` (other than the fact that it ignores the whether or not the mouse is being held down)

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 locating the code that decides when mousemove is dispatched and reviewing how existing mouse events are documented. Clarify the event name and exact behavior between mousedown and mouseup, then define completion as the agreed event being implemented consistently and documented for users.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.