mirror of
https://github.com/Leaflet/Path.Drag.js.git
synced 2025-07-29 12:49:43 +00:00
Use path center as event.latlng for move event
The move event is listened by popup and tooltip when attached to a layer, so we want to keep them centered, not to follow the mouse position while dragging. fix Leaflet/Leaflet.Editable#140
This commit is contained in:
@ -3,8 +3,8 @@
|
||||
<head>
|
||||
<title>Path.Drag.js demo</title>
|
||||
|
||||
<link rel="stylesheet" href="https://npmcdn.com/leaflet@1.0.0-rc.1/dist/leaflet.css" />
|
||||
<script src="https://npmcdn.com/leaflet@1.0.0-rc.1/dist/leaflet.js"></script>
|
||||
<link rel="stylesheet" href="https://npmcdn.com/leaflet@1.2.0/dist/leaflet.css" />
|
||||
<script src="https://npmcdn.com/leaflet@1.2.0/dist/leaflet.js"></script>
|
||||
<script src="../src/Path.Drag.js"></script>
|
||||
<style type="text/css">
|
||||
.my-div-icon {
|
||||
|
@ -3,8 +3,8 @@
|
||||
<head>
|
||||
<title>Path.Drag.js demo</title>
|
||||
|
||||
<link rel="stylesheet" href="https://npmcdn.com/leaflet@1.0.0-rc.1/dist/leaflet.css" />
|
||||
<script src="https://npmcdn.com/leaflet@1.0.0-rc.1/dist/leaflet.js"></script>
|
||||
<link rel="stylesheet" href="https://npmcdn.com/leaflet@1.2.0/dist/leaflet.css" />
|
||||
<script src="https://npmcdn.com/leaflet@1.2.0/dist/leaflet.js"></script>
|
||||
<script src="../src/Path.Drag.js"></script>
|
||||
<style type="text/css">
|
||||
.my-div-icon {
|
||||
@ -36,7 +36,7 @@
|
||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
|
||||
L.polygon([[41.21, 9.42], [41.22, 9.40], [41.23, 9.40]], {draggable: true}).addTo(map);
|
||||
L.polygon([[41.21, 9.42], [41.22, 9.40], [41.23, 9.40]], {draggable: true}).bindTooltip('drag me', {permanent: true, direction: 'top'}).addTo(map);
|
||||
L.polygon([[[41.20, 9.41], [41.20, 9.39], [41.21, 9.41]], [[41.18, 9.42], [41.17, 9.40], [41.19, 9.38]]], {color: 'Tomato',draggable: true}).addTo(map);
|
||||
L.circleMarker([41.20, 9.50], {color: 'Chocolate', radius: 12, draggable: true}).addTo(map);
|
||||
L.polyline([[41.20, 9.36], [41.205, 9.35], [41.19, 9.34]], {draggable: true}).addTo(map);
|
||||
|
@ -3,8 +3,8 @@
|
||||
<head>
|
||||
<title>Path.Drag.js demo</title>
|
||||
|
||||
<link rel="stylesheet" href="https://npmcdn.com/leaflet@1.0.0-rc.1/dist/leaflet.css" />
|
||||
<script src="https://npmcdn.com/leaflet@1.0.0-rc.1/dist/leaflet.js"></script>
|
||||
<link rel="stylesheet" href="https://npmcdn.com/leaflet@1.2.0/dist/leaflet.css" />
|
||||
<script src="https://npmcdn.com/leaflet@1.2.0/dist/leaflet.js"></script>
|
||||
<!-- <script src="../../Leaflet/dist/leaflet-src.js"></script> -->
|
||||
<script src="../src/Path.Drag.js"></script>
|
||||
<style type="text/css">
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "leaflet.path.drag",
|
||||
"version": "0.0.5",
|
||||
"version": "0.0.6",
|
||||
"description": "Allow to drag Leaflet path",
|
||||
"main": "src/Path.Drag.js",
|
||||
"scripts": {
|
||||
@ -25,7 +25,7 @@
|
||||
"homepage": "https://github.com/Leaflet/Path.Drag.js#readme",
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
"leaflet": "^1.0.0-rc.2",
|
||||
"leaflet": "^1.2.0",
|
||||
"mocha": "^2.5.3",
|
||||
"mocha-phantomjs-core": "^1.3.1",
|
||||
"phantomjs-prebuilt": "^2.1.7",
|
||||
|
@ -77,8 +77,9 @@ L.Handler.PathDrag = L.Handler.extend({
|
||||
|
||||
e.latlng = latlng;
|
||||
e.offset = this._offset;
|
||||
path.fire('move', e)
|
||||
.fire('drag', e);
|
||||
path.fire('drag', e);
|
||||
e.latlng = this._path.getCenter ? this._path.getCenter() : this._path.getLatLng();
|
||||
path.fire('move', e);
|
||||
},
|
||||
|
||||
_onDragEnd: function (e) {
|
||||
|
Reference in New Issue
Block a user