-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/draggable markers #6687
Conversation
I am unsure about the final two tests in Note that I also deleted the equivalent TouchEvent test because TouchEvents don't have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The drag-simulation tests look fine. Yes, it's not actually moving the actual cursor on screen; it's sufficient just to provide the input events that should trigger the marker to move position.
docs/pages/example/drag-a-point.html
Outdated
@@ -1,118 +0,0 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep this example around; it's still useful to show how to implement draggability for symbol layers.
// e.g. when setDraggable is called before addTo | ||
if (this._map) { | ||
if (shouldBeDraggable) { | ||
this._map.on('mousedown', this._addDragHandler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to either fix #4597 or check that this._draggable
state is actually changing, so as not to register duplicate handlers if setDraggable(true)
is called when the marker is already draggable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/ui/marker.js
Outdated
|
||
/** | ||
* Returns the marker's draggable property | ||
* @returns {boolean} `this._draggable` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't reference the private property here.
src/util/evented.js
Outdated
@@ -6,6 +6,7 @@ type Listener = (Object) => any; | |||
type Listeners = { [string]: Array<Listener> }; | |||
|
|||
function _addEventListener(type: string, listener: Listener, listenerList: Listeners) { | |||
_removeEventListener(type, listener, listenerList); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than remove and re-add, make this an affirmative check for the current presence of listener, so that a redundant on
doesn't change the relative order of listeners. E.g. given map.on('click', listenerA); map.on('click', listenerB); map.on('click', listenerA);
, listenerA
should be the first one called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
549c6cd
to
bac1f67
Compare
Launch Checklist
briefly describe the changes in this PR
Adds drag functionality to markers either via a
draggable
option or asetDraggable
methodAdds
dragstart
,drag
anddragend
events on MarkerUpdates JSDocs
Adds new drag-a-marker example (leaves drag-a-point example as is)
Adds tests for dragging a marker
Makes
evented._addEventListener
idempotent to avoid adding the same listener multiple timeswrite tests for all new functionality
document any changes to public APIs
manually test the debug page
Closes #6102
Closes #3087
Closes #4597