Remove marker.dragging when not on the map (#5295)
* Add some tests for #5293 * Fix enabling marker dragging while markers aren't on the map by removing the dragging object when not on the map. This is a change of behavior (.dragging is only defined when a marker is on the map). * Docs for dragging change
This commit is contained in:
parent
d10f3ca317
commit
5603a87c70
@ -108,8 +108,18 @@ describe("Marker", function () {
|
||||
map.removeLayer(marker);
|
||||
// Dragging is still enabled, we should be able to disable it,
|
||||
// even if marker is off the map.
|
||||
marker.dragging.disable();
|
||||
expect(marker.dragging).to.be(undefined);
|
||||
marker.options.draggable = false;
|
||||
map.addLayer(marker);
|
||||
|
||||
map.removeLayer(marker);
|
||||
|
||||
// We should also be able to enable dragging while off the map
|
||||
expect(marker.dragging).to.be(undefined);
|
||||
marker.options.draggable = true;
|
||||
|
||||
map.addLayer(marker);
|
||||
expect(marker.dragging.enabled()).to.be(true);
|
||||
});
|
||||
|
||||
it("changes the icon to another DivIcon", function () {
|
||||
|
@ -17,7 +17,7 @@ import {Draggable} from '../../dom/Draggable';
|
||||
* ```
|
||||
*
|
||||
* @property dragging: Handler
|
||||
* Marker dragging handler (by both mouse and touch).
|
||||
* Marker dragging handler (by both mouse and touch). Only valid when the marker is on the map (Otherwise set [`marker.options.draggable`](#marker-draggable)).
|
||||
*/
|
||||
|
||||
export var MarkerDrag = Handler.extend({
|
||||
|
@ -96,6 +96,7 @@ export var Marker = Layer.extend({
|
||||
this.options.draggable = true;
|
||||
this.dragging.removeHooks();
|
||||
}
|
||||
delete this.dragging;
|
||||
|
||||
if (this._zoomAnimated) {
|
||||
map.off('zoomanim', this._animateZoom, this);
|
||||
|
Loading…
Reference in New Issue
Block a user