leaflet-rotate 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,7 +26,7 @@ Load Leaflet first, then the plugin. For example, using the published CDN build:
26
26
  ```html
27
27
  <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9/dist/leaflet.css">
28
28
  <script src="https://unpkg.com/leaflet@1.9/dist/leaflet.js"></script>
29
- <script src="https://unpkg.com/leaflet-rotate@0.5.3/dist/leaflet-rotate.js"></script>
29
+ <script src="https://unpkg.com/leaflet-rotate@0.5.4/dist/leaflet-rotate.js"></script>
30
30
  ```
31
31
 
32
32
  Or if you want to test it with [`2.0.0-alpha.1`](https://github.com/Leaflet/Leaflet/releases/tag/v2.0.0-alpha.1):
@@ -35,7 +35,7 @@ Or if you want to test it with [`2.0.0-alpha.1`](https://github.com/Leaflet/Leaf
35
35
  <link rel="stylesheet" href="https://unpkg.com/leaflet@2.0.0-alpha.1/dist/leaflet.css">
36
36
  <script src="https://unpkg.com/leaflet@2.0.0-alpha.1/dist/leaflet-global-src.js"></script>
37
37
  <script>globalThis.L = globalThis.leaflet;</script>
38
- <script src="https://unpkg.com/leaflet-rotate@0.5.3/dist/leaflet-rotate.js"></script>
38
+ <script src="https://unpkg.com/leaflet-rotate@0.5.4/dist/leaflet-rotate.js"></script>
39
39
  ```
40
40
 
41
41
  Now, you can enable rotation in the map options. Bearing and pitch values are in degrees:
@@ -84,11 +84,25 @@ var leafletRotate = (() => {
84
84
  });
85
85
 
86
86
  // src/dom/Draggable.js
87
+ var draggableProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Draggable.prototype));
87
88
  L.Draggable.include({
88
- /** @TODO */
89
- // updateMapBearing(mapBearing) {
90
- // this._mapBearing = mapBearing;
91
- // },
89
+ _onMove(e) {
90
+ const pointer = e.touches ? e.touches[0] : e;
91
+ if (this._enabled && this._moving && (!e.touches || e.touches.length === 1)) {
92
+ const offset = new L.Point(pointer.clientX, pointer.clientY).subtract(this._startPoint);
93
+ if (!offset.x && !offset.y || Math.abs(offset.x) + Math.abs(offset.y) < this.options.clickTolerance) {
94
+ L.DomEvent.preventDefault(e);
95
+ this._newPos = this._startPos.add(new L.Point(
96
+ offset.x / this._parentScale.x,
97
+ offset.y / this._parentScale.y
98
+ ));
99
+ this._lastEvent = e;
100
+ this._updatePosition();
101
+ return;
102
+ }
103
+ }
104
+ return draggableProto._onMove.apply(this, arguments);
105
+ }
92
106
  });
93
107
 
94
108
  // src/geometry/Point.js
@@ -1577,7 +1591,7 @@ var leafletRotate = (() => {
1577
1591
  * @since leaflet-rotate (v0.1.4)
1578
1592
  */
1579
1593
  panInside(latlng, options) {
1580
- if (!this._rotate || !this._pitch && Math.abs(this._bearing).toFixed(1) < 0.1) {
1594
+ if (!this._rotate) {
1581
1595
  return mapProto.panInside.apply(this, arguments);
1582
1596
  }
1583
1597
  options = options || {};
@@ -1758,7 +1772,7 @@ var leafletRotate = (() => {
1758
1772
  const center = this.getSize().divideBy(2), layerCenter = this.containerPointToLayerPoint(center), opposite = layerCenter.multiplyBy(2).subtract(this.project(latlng).subtract(this._pixelOrigin));
1759
1773
  return center.subtract(this.layerPointToContainerPoint(opposite));
1760
1774
  }
1761
- return this.latLngToContainerPoint(latlng)._subtract(this.getSize()._divideBy(2));
1775
+ return this.layerPointToContainerPoint(this.project(latlng).subtract(this._pixelOrigin))._subtract(this.getSize()._divideBy(2));
1762
1776
  },
1763
1777
  /**
1764
1778
  * Return the current position of the rotated pane.
@@ -1788,7 +1802,7 @@ var leafletRotate = (() => {
1788
1802
  if (!this._rotate) {
1789
1803
  return mapProto._getNewPixelOrigin.apply(this, arguments);
1790
1804
  }
1791
- return this.project(center, zoom)._subtract(this.containerPointToLayerPoint(this.getSize()._divideBy(2)))._round();
1805
+ return this.project(center, zoom)._subtract(this.containerPointToLayerPoint(this.getSize()._divideBy(2)));
1792
1806
  },
1793
1807
  /**
1794
1808
  * Calculate the pixel bounds needed to cover the transformed viewport.