From d0391dba3708d3f32bcd94e1881d1b598a0d9ef0 Mon Sep 17 00:00:00 2001
From: zhangshuaibao <15731629597@163.com>
Date: 星期四, 15 四月 2021 17:21:10 +0800
Subject: [PATCH] 修改图表问题

---
 src/components/plugin/PathDrag.js |  234 ++++++++++++++++++++++++++++-----------------------------
 1 files changed, 115 insertions(+), 119 deletions(-)

diff --git a/src/components/plugin/PathDrag.js b/src/components/plugin/PathDrag.js
index c4f2eea..4916866 100644
--- a/src/components/plugin/PathDrag.js
+++ b/src/components/plugin/PathDrag.js
@@ -1,143 +1,139 @@
-'use strict'
-const init = (L) => {
-    /* A Draggable that does not update the element position
-    and takes care of only bubbling to targetted path in Canvas mode. */
-    L.PathDraggable = L.Draggable.extend({
+/* eslint-disable */
+'use strict';
+const L = window.L
+/* A Draggable that does not update the element position
+and takes care of only bubbling to targetted path in Canvas mode. */
+L.PathDraggable = L.Draggable.extend({
 
-        initialize: function(path) {
-            this._path = path
-            this._canvas = (path._map.getRenderer(path) instanceof L.Canvas)
-            let element = this._canvas ? this._path._map.getRenderer(this._path)._container : this._path._path
-            L.Draggable.prototype.initialize.call(this, element, element, true)
-        },
+  initialize: function (path) {
+    this._path = path;
+    this._canvas = (path._map.getRenderer(path) instanceof L.Canvas);
+    var element = this._canvas ? this._path._map.getRenderer(this._path)._container : this._path._path;
+    L.Draggable.prototype.initialize.call(this, element, element, true);
+  },
 
-        _updatePosition: function() {
-            let e = { originalEvent: this._lastEvent }
-            this.fire('drag', e)
-        },
+  _updatePosition: function () {
+    var e = {originalEvent: this._lastEvent};
+    this.fire('drag', e);
+  },
 
-        _onDown: function(e) {
-            let first = e.touches ? e.touches[0] : e
-            this._startPoint = new L.Point(first.clientX, first.clientY)
-            if (this._canvas && !this._path._containsPoint(this._path._map.mouseEventToLayerPoint(first))) {
-                return
-            }
-            L.Draggable.prototype._onDown.call(this, e)
-        }
+  _onDown: function (e) {
+    var first = e.touches ? e.touches[0] : e;
+    this._startPoint = new L.Point(first.clientX, first.clientY);
+    if (this._canvas && !this._path._containsPoint(this._path._map.mouseEventToLayerPoint(first))) { return; }
+    L.Draggable.prototype._onDown.call(this, e);
+  }
 
-    })
+});
 
-    L.Handler.PathDrag = L.Handler.extend({
 
-        initialize: function(path) {
-            this._path = path
-        },
+L.Handler.PathDrag = L.Handler.extend({
 
-        getEvents: function() {
-            return {
-                dragstart: this._onDragStart,
-                drag: this._onDrag,
-                dragend: this._onDragEnd
-            }
-        },
+  initialize: function (path) {
+    this._path = path;
+  },
 
-        addHooks: function() {
-            if (!this._draggable) {
-                this._draggable = new L.PathDraggable(this._path)
-            }
-            this._draggable.on(this.getEvents(), this).enable()
-            L.DomUtil.addClass(this._draggable._element, 'leaflet-path-draggable')
-        },
+  getEvents: function () {
+    return {
+      dragstart: this._onDragStart,
+      drag: this._onDrag,
+      dragend: this._onDragEnd
+    };
+  },
 
-        removeHooks: function() {
-            this._draggable.off(this.getEvents(), this).disable()
-            L.DomUtil.removeClass(this._draggable._element, 'leaflet-path-draggable')
-        },
+  addHooks: function () {
+    if (!this._draggable) { this._draggable = new L.PathDraggable(this._path); }
+    this._draggable.on(this.getEvents(), this).enable();
+    L.DomUtil.addClass(this._draggable._element, 'leaflet-path-draggable');
+  },
 
-        moved: function() {
-            return this._draggable && this._draggable._moved
-        },
+  removeHooks: function () {
+    this._draggable.off(this.getEvents(), this).disable();
+    L.DomUtil.removeClass(this._draggable._element, 'leaflet-path-draggable');
+  },
 
-        _onDragStart: function() {
-            this._startPoint = this._draggable._startPoint
-            this._path
-                .closePopup()
-                .fire('movestart')
-                .fire('dragstart')
-        },
+  moved: function () {
+    return this._draggable && this._draggable._moved;
+  },
 
-        _onDrag: function(e) {
-            let path = this._path
-            let event = (e.originalEvent.touches && e.originalEvent.touches.length === 1 ? e.originalEvent.touches[0] : e.originalEvent)
-            let newPoint = L.point(event.clientX, event.clientY)
-            let latlng = path._map.layerPointToLatLng(newPoint)
+  _onDragStart: function () {
+    this._startPoint = this._draggable._startPoint;
+    this._path
+        .closePopup()
+        .fire('movestart')
+        .fire('dragstart');
+  },
 
-            this._offset = newPoint.subtract(this._startPoint)
-            this._startPoint = newPoint
+  _onDrag: function (e) {
+    var path = this._path,
+        event = (e.originalEvent.touches && e.originalEvent.touches.length === 1 ? e.originalEvent.touches[0] : e.originalEvent),
+        newPoint = L.point(event.clientX, event.clientY),
+        latlng = path._map.layerPointToLatLng(newPoint);
 
-            this._path.eachLatLng(this.updateLatLng, this)
-            path.redraw()
+    this._offset = newPoint.subtract(this._startPoint);
+    this._startPoint = newPoint;
 
-            e.latlng = latlng
-            e.offset = this._offset
-            path.fire('drag', e)
-            e.latlng = this._path.getCenter ? this._path.getCenter() : this._path.getLatLng()
-            path.fire('move', e)
-        },
+    this._path.eachLatLng(this.updateLatLng, this);
+    path.redraw();
 
-        _onDragEnd: function(e) {
-            if (this._path._bounds) this.resetBounds()
-            this._path.fire('moveend')
-                .fire('dragend', e)
-        },
+    e.latlng = latlng;
+    e.offset = this._offset;
+    path.fire('drag', e);
+    e.latlng = this._path.getCenter ? this._path.getCenter() : this._path.getLatLng();
+    path.fire('move', e);
+  },
 
-        latLngToLayerPoint: function(latlng) {
-            // Same as map.latLngToLayerPoint, but without the round().
-            let projectedPoint = this._path._map.project(L.latLng(latlng))
-            return projectedPoint._subtract(this._path._map.getPixelOrigin())
-        },
+  _onDragEnd: function (e) {
+    if (this._path._bounds) this.resetBounds();
+    this._path.fire('moveend')
+        .fire('dragend', e);
+  },
 
-        updateLatLng: function(latlng) {
-            let oldPoint = this.latLngToLayerPoint(latlng)
-            oldPoint._add(this._offset)
-            let newLatLng = this._path._map.layerPointToLatLng(oldPoint)
-            latlng.lat = newLatLng.lat
-            latlng.lng = newLatLng.lng
-        },
+  latLngToLayerPoint: function (latlng) {
+    // Same as map.latLngToLayerPoint, but without the round().
+    var projectedPoint = this._path._map.project(L.latLng(latlng));
+    return projectedPoint._subtract(this._path._map.getPixelOrigin());
+  },
 
-        resetBounds: function() {
-            this._path._bounds = new L.LatLngBounds()
-            this._path.eachLatLng(function(latlng) {
-                this._bounds.extend(latlng)
-            })
-        }
+  updateLatLng: function (latlng) {
+    var oldPoint = this.latLngToLayerPoint(latlng);
+    oldPoint._add(this._offset);
+    var newLatLng = this._path._map.layerPointToLatLng(oldPoint);
+    latlng.lat = newLatLng.lat;
+    latlng.lng = newLatLng.lng;
+  },
 
-    })
+  resetBounds: function () {
+    this._path._bounds = new L.LatLngBounds();
+    this._path.eachLatLng(function (latlng) {
+      this._bounds.extend(latlng);
+    });
+  }
 
-    L.Path.include({
+});
 
-        eachLatLng: function(callback, context) {
-            context = context || this
-            let loop = function(latlngs) {
-                for (let i = 0; i < latlngs.length; i++) {
-                    if (L.Util.isArray(latlngs[i])) loop(latlngs[i])
-                    else callback.call(context, latlngs[i])
-                }
-            }
-            loop(this.getLatLngs ? this.getLatLngs() : [this.getLatLng()])
-        }
+L.Path.include({
 
-    })
+  eachLatLng: function (callback, context) {
+    context = context || this;
+    var loop = function (latlngs) {
+      for (var i = 0; i < latlngs.length; i++) {
+        if (L.Util.isArray(latlngs[i])) loop(latlngs[i]);
+        else callback.call(context, latlngs[i]);
+      }
+    };
+    loop(this.getLatLngs ? this.getLatLngs() : [this.getLatLng()]);
+  }
 
-    L.Path.addInitHook(function() {
-        this.dragging = new L.Handler.PathDrag(this)
-        if (this.options.draggable) {
-            this.once('add', function() {
-                this.dragging.enable()
-            })
-        }
-    })
-}
-export default {
-    init
-}
+});
+
+L.Path.addInitHook(function () {
+
+  this.dragging = new L.Handler.PathDrag(this);
+  if (this.options.draggable) {
+    this.once('add', function () {
+      this.dragging.enable();
+    });
+  }
+
+});

--
Gitblit v1.8.0