decidim 0.26.9 → 0.26.10

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.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/lib/decidim/version.rb +1 -1
  3. data/package-lock.json +7 -7
  4. data/packages/browserslist-config/package.json +1 -1
  5. data/packages/core/node_modules/leaflet/CHANGELOG.md +2191 -0
  6. data/packages/core/node_modules/leaflet/LICENSE +26 -0
  7. data/packages/core/node_modules/leaflet/README.md +55 -0
  8. data/packages/core/node_modules/leaflet/dist/images/layers-2x.png +0 -0
  9. data/packages/core/node_modules/leaflet/dist/images/layers.png +0 -0
  10. data/packages/core/node_modules/leaflet/dist/images/marker-icon-2x.png +0 -0
  11. data/packages/core/node_modules/leaflet/dist/images/marker-icon.png +0 -0
  12. data/packages/core/node_modules/leaflet/dist/images/marker-shadow.png +0 -0
  13. data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js +14419 -0
  14. data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js.map +1 -0
  15. data/packages/core/node_modules/leaflet/dist/leaflet-src.js +14512 -0
  16. data/packages/core/node_modules/leaflet/dist/leaflet-src.js.map +1 -0
  17. data/packages/core/node_modules/leaflet/dist/leaflet.css +661 -0
  18. data/packages/core/node_modules/leaflet/dist/leaflet.js +6 -0
  19. data/packages/core/node_modules/leaflet/dist/leaflet.js.map +1 -0
  20. data/packages/core/node_modules/leaflet/package.json +149 -0
  21. data/packages/core/node_modules/leaflet/src/Leaflet.js +24 -0
  22. data/packages/core/node_modules/leaflet/src/control/Control.Attribution.js +148 -0
  23. data/packages/core/node_modules/leaflet/src/control/Control.Layers.js +443 -0
  24. data/packages/core/node_modules/leaflet/src/control/Control.Scale.js +132 -0
  25. data/packages/core/node_modules/leaflet/src/control/Control.Zoom.js +146 -0
  26. data/packages/core/node_modules/leaflet/src/control/Control.js +174 -0
  27. data/packages/core/node_modules/leaflet/src/control/index.js +17 -0
  28. data/packages/core/node_modules/leaflet/src/core/Browser.js +220 -0
  29. data/packages/core/node_modules/leaflet/src/core/Class.js +135 -0
  30. data/packages/core/node_modules/leaflet/src/core/Class.leafdoc +197 -0
  31. data/packages/core/node_modules/leaflet/src/core/Events.js +344 -0
  32. data/packages/core/node_modules/leaflet/src/core/Events.leafdoc +143 -0
  33. data/packages/core/node_modules/leaflet/src/core/Handler.js +57 -0
  34. data/packages/core/node_modules/leaflet/src/core/Util.js +241 -0
  35. data/packages/core/node_modules/leaflet/src/core/index.js +15 -0
  36. data/packages/core/node_modules/leaflet/src/dom/DomEvent.DoubleTap.js +91 -0
  37. data/packages/core/node_modules/leaflet/src/dom/DomEvent.Pointer.js +97 -0
  38. data/packages/core/node_modules/leaflet/src/dom/DomEvent.js +315 -0
  39. data/packages/core/node_modules/leaflet/src/dom/DomUtil.js +349 -0
  40. data/packages/core/node_modules/leaflet/src/dom/Draggable.js +220 -0
  41. data/packages/core/node_modules/leaflet/src/dom/PosAnimation.js +113 -0
  42. data/packages/core/node_modules/leaflet/src/dom/index.js +9 -0
  43. data/packages/core/node_modules/leaflet/src/geo/LatLng.js +137 -0
  44. data/packages/core/node_modules/leaflet/src/geo/LatLngBounds.js +251 -0
  45. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3395.js +20 -0
  46. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3857.js +27 -0
  47. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG4326.js +23 -0
  48. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Earth.js +33 -0
  49. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Simple.js +36 -0
  50. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.js +139 -0
  51. data/packages/core/node_modules/leaflet/src/geo/crs/index.js +15 -0
  52. data/packages/core/node_modules/leaflet/src/geo/index.js +7 -0
  53. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.LonLat.js +28 -0
  54. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.Mercator.js +49 -0
  55. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.SphericalMercator.js +44 -0
  56. data/packages/core/node_modules/leaflet/src/geo/projection/index.js +26 -0
  57. data/packages/core/node_modules/leaflet/src/geometry/Bounds.js +219 -0
  58. data/packages/core/node_modules/leaflet/src/geometry/LineUtil.js +306 -0
  59. data/packages/core/node_modules/leaflet/src/geometry/Point.js +222 -0
  60. data/packages/core/node_modules/leaflet/src/geometry/PolyUtil.js +129 -0
  61. data/packages/core/node_modules/leaflet/src/geometry/Transformation.js +79 -0
  62. data/packages/core/node_modules/leaflet/src/geometry/index.js +8 -0
  63. data/packages/core/node_modules/leaflet/src/images/layers.svg +1 -0
  64. data/packages/core/node_modules/leaflet/src/images/logo.svg +1 -0
  65. data/packages/core/node_modules/leaflet/src/images/marker.svg +1 -0
  66. data/packages/core/node_modules/leaflet/src/layer/DivOverlay.js +348 -0
  67. data/packages/core/node_modules/leaflet/src/layer/FeatureGroup.js +94 -0
  68. data/packages/core/node_modules/leaflet/src/layer/GeoJSON.js +452 -0
  69. data/packages/core/node_modules/leaflet/src/layer/ImageOverlay.js +270 -0
  70. data/packages/core/node_modules/leaflet/src/layer/Layer.Interactive.leafdoc +39 -0
  71. data/packages/core/node_modules/leaflet/src/layer/Layer.js +275 -0
  72. data/packages/core/node_modules/leaflet/src/layer/LayerGroup.js +159 -0
  73. data/packages/core/node_modules/leaflet/src/layer/Popup.js +506 -0
  74. data/packages/core/node_modules/leaflet/src/layer/SVGOverlay.js +50 -0
  75. data/packages/core/node_modules/leaflet/src/layer/Tooltip.js +444 -0
  76. data/packages/core/node_modules/leaflet/src/layer/VideoOverlay.js +106 -0
  77. data/packages/core/node_modules/leaflet/src/layer/index.js +24 -0
  78. data/packages/core/node_modules/leaflet/src/layer/marker/DivIcon.js +74 -0
  79. data/packages/core/node_modules/leaflet/src/layer/marker/Icon.Default.js +66 -0
  80. data/packages/core/node_modules/leaflet/src/layer/marker/Icon.js +165 -0
  81. data/packages/core/node_modules/leaflet/src/layer/marker/Marker.Drag.js +161 -0
  82. data/packages/core/node_modules/leaflet/src/layer/marker/Marker.js +419 -0
  83. data/packages/core/node_modules/leaflet/src/layer/marker/index.js +8 -0
  84. data/packages/core/node_modules/leaflet/src/layer/tile/GridLayer.js +923 -0
  85. data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.WMS.js +137 -0
  86. data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.js +289 -0
  87. data/packages/core/node_modules/leaflet/src/layer/tile/index.js +6 -0
  88. data/packages/core/node_modules/leaflet/src/layer/vector/Canvas.js +492 -0
  89. data/packages/core/node_modules/leaflet/src/layer/vector/Circle.js +113 -0
  90. data/packages/core/node_modules/leaflet/src/layer/vector/CircleMarker.js +109 -0
  91. data/packages/core/node_modules/leaflet/src/layer/vector/Path.js +148 -0
  92. data/packages/core/node_modules/leaflet/src/layer/vector/Polygon.js +159 -0
  93. data/packages/core/node_modules/leaflet/src/layer/vector/Polyline.js +307 -0
  94. data/packages/core/node_modules/leaflet/src/layer/vector/Rectangle.js +57 -0
  95. data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.getRenderer.js +45 -0
  96. data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.js +133 -0
  97. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.Util.js +39 -0
  98. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.VML.js +144 -0
  99. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.js +207 -0
  100. data/packages/core/node_modules/leaflet/src/layer/vector/index.js +14 -0
  101. data/packages/core/node_modules/leaflet/src/map/Map.js +1751 -0
  102. data/packages/core/node_modules/leaflet/src/map/Map.methodOptions.leafdoc +112 -0
  103. data/packages/core/node_modules/leaflet/src/map/handler/Map.BoxZoom.js +152 -0
  104. data/packages/core/node_modules/leaflet/src/map/handler/Map.DoubleClickZoom.js +55 -0
  105. data/packages/core/node_modules/leaflet/src/map/handler/Map.Drag.js +235 -0
  106. data/packages/core/node_modules/leaflet/src/map/handler/Map.Keyboard.js +183 -0
  107. data/packages/core/node_modules/leaflet/src/map/handler/Map.ScrollWheelZoom.js +91 -0
  108. data/packages/core/node_modules/leaflet/src/map/handler/Map.TapHold.js +102 -0
  109. data/packages/core/node_modules/leaflet/src/map/handler/Map.TouchZoom.js +130 -0
  110. data/packages/core/node_modules/leaflet/src/map/index.js +17 -0
  111. data/packages/core/package.json +1 -1
  112. data/packages/dev/package.json +1 -1
  113. data/packages/elections/package.json +1 -1
  114. data/packages/eslint-config/package.json +1 -1
  115. data/packages/stylelint-config/package.json +1 -1
  116. data/packages/webpacker/package.json +1 -1
  117. metadata +148 -42
@@ -0,0 +1,112 @@
1
+
2
+ This file documents the common options passed to several map methods.
3
+
4
+
5
+ @miniclass Locate options (Map)
6
+ @aka locate options
7
+ @section
8
+
9
+ Some of the geolocation methods for `Map` take in an `options` parameter. This
10
+ is a plain javascript object with the following optional components:
11
+
12
+ @option watch: Boolean = false
13
+ If `true`, starts continuous watching of location changes (instead of detecting it
14
+ once) using W3C `watchPosition` method. You can later stop watching using
15
+ `map.stopLocate()` method.
16
+
17
+
18
+ @option setView: Boolean = false
19
+ If `true`, automatically sets the map view to the user location with respect to
20
+ detection accuracy, or to world view if geolocation failed.
21
+
22
+ @option maxZoom: Number = Infinity
23
+ The maximum zoom for automatic view setting when using `setView` option.
24
+
25
+ @option timeout: Number = 10000
26
+ Number of milliseconds to wait for a response from geolocation before firing a
27
+ `locationerror` event.
28
+
29
+ @option maximumAge: Number = 0
30
+ Maximum age of detected location. If less than this amount of milliseconds
31
+ passed since last geolocation response, `locate` will return a cached location.
32
+
33
+ @option enableHighAccuracy: Boolean = false
34
+ Enables high accuracy, see [description in the W3C spec](https://w3c.github.io/geolocation-api/#enablehighaccuracy-member).
35
+
36
+
37
+
38
+ @miniclass Zoom options (Map)
39
+ @aka zoom options
40
+ @section
41
+
42
+ Some of the `Map` methods which modify the zoom level take in an `options`
43
+ parameter. This is a plain javascript object with the following optional
44
+ components:
45
+
46
+
47
+ @option animate: Boolean
48
+ If not specified, zoom animation will happen if the zoom origin is inside the
49
+ current view. If `true`, the map will attempt animating zoom disregarding where
50
+ zoom origin is. Setting `false` will make it always reset the view completely
51
+ without animation.
52
+
53
+
54
+
55
+
56
+ @miniclass Pan options (Map)
57
+ @aka pan options
58
+ @section
59
+
60
+ Some of the `Map` methods which modify the center of the map take in an `options`
61
+ parameter. This is a plain javascript object with the following optional
62
+ components:
63
+
64
+ @option animate: Boolean
65
+ If `true`, panning will always be animated if possible. If `false`, it will
66
+ not animate panning, either resetting the map view if panning more than a
67
+ screen away, or just setting a new offset for the map pane (except for `panBy`
68
+ which always does the latter).
69
+
70
+ @option duration: Number = 0.25
71
+ Duration of animated panning, in seconds.
72
+
73
+ @option easeLinearity: Number = 0.25
74
+ The curvature factor of panning animation easing (third parameter of the
75
+ [Cubic Bezier curve](https://cubic-bezier.com/)). 1.0 means linear animation,
76
+ and the smaller this number, the more bowed the curve.
77
+
78
+ @option noMoveStart: Boolean = false
79
+ If `true`, panning won't fire `movestart` event on start (used internally for
80
+ panning inertia).
81
+
82
+
83
+ @miniclass Zoom/pan options (Map)
84
+ @aka zoom/pan options
85
+ @inherits Zoom options
86
+ @inherits Pan options
87
+
88
+
89
+ @miniclass Padding options (Map)
90
+ @aka padding options
91
+ @option paddingTopLeft: Point = [0, 0]
92
+ Sets the amount of padding in the top left corner of a map container that
93
+ shouldn't be accounted for when setting the view to fit bounds. Useful if you
94
+ have some control overlays on the map like a sidebar and you don't want them
95
+ to obscure objects you're zooming to.
96
+
97
+ @option paddingBottomRight: Point = [0, 0]
98
+ The same for the bottom right corner of the map.
99
+
100
+ @option padding: Point = [0, 0]
101
+ Equivalent of setting both top left and bottom right padding to the same value.
102
+
103
+
104
+ @miniclass FitBounds options (Map)
105
+ @aka fitBounds options
106
+ @inherits Zoom/pan options
107
+ @inherits Padding options
108
+
109
+ @option maxZoom: Number = null
110
+ The maximum possible zoom to use.
111
+
112
+
@@ -0,0 +1,152 @@
1
+ import {Map} from '../Map';
2
+ import {Handler} from '../../core/Handler';
3
+ import * as Util from '../../core/Util';
4
+ import * as DomUtil from '../../dom/DomUtil';
5
+ import * as DomEvent from '../../dom/DomEvent';
6
+ import {LatLngBounds} from '../../geo/LatLngBounds';
7
+ import {Bounds} from '../../geometry/Bounds';
8
+
9
+ /*
10
+ * L.Handler.BoxZoom is used to add shift-drag zoom interaction to the map
11
+ * (zoom to a selected bounding box), enabled by default.
12
+ */
13
+
14
+ // @namespace Map
15
+ // @section Interaction Options
16
+ Map.mergeOptions({
17
+ // @option boxZoom: Boolean = true
18
+ // Whether the map can be zoomed to a rectangular area specified by
19
+ // dragging the mouse while pressing the shift key.
20
+ boxZoom: true
21
+ });
22
+
23
+ export var BoxZoom = Handler.extend({
24
+ initialize: function (map) {
25
+ this._map = map;
26
+ this._container = map._container;
27
+ this._pane = map._panes.overlayPane;
28
+ this._resetStateTimeout = 0;
29
+ map.on('unload', this._destroy, this);
30
+ },
31
+
32
+ addHooks: function () {
33
+ DomEvent.on(this._container, 'mousedown', this._onMouseDown, this);
34
+ },
35
+
36
+ removeHooks: function () {
37
+ DomEvent.off(this._container, 'mousedown', this._onMouseDown, this);
38
+ },
39
+
40
+ moved: function () {
41
+ return this._moved;
42
+ },
43
+
44
+ _destroy: function () {
45
+ DomUtil.remove(this._pane);
46
+ delete this._pane;
47
+ },
48
+
49
+ _resetState: function () {
50
+ this._resetStateTimeout = 0;
51
+ this._moved = false;
52
+ },
53
+
54
+ _clearDeferredResetState: function () {
55
+ if (this._resetStateTimeout !== 0) {
56
+ clearTimeout(this._resetStateTimeout);
57
+ this._resetStateTimeout = 0;
58
+ }
59
+ },
60
+
61
+ _onMouseDown: function (e) {
62
+ if (!e.shiftKey || ((e.which !== 1) && (e.button !== 1))) { return false; }
63
+
64
+ // Clear the deferred resetState if it hasn't executed yet, otherwise it
65
+ // will interrupt the interaction and orphan a box element in the container.
66
+ this._clearDeferredResetState();
67
+ this._resetState();
68
+
69
+ DomUtil.disableTextSelection();
70
+ DomUtil.disableImageDrag();
71
+
72
+ this._startPoint = this._map.mouseEventToContainerPoint(e);
73
+
74
+ DomEvent.on(document, {
75
+ contextmenu: DomEvent.stop,
76
+ mousemove: this._onMouseMove,
77
+ mouseup: this._onMouseUp,
78
+ keydown: this._onKeyDown
79
+ }, this);
80
+ },
81
+
82
+ _onMouseMove: function (e) {
83
+ if (!this._moved) {
84
+ this._moved = true;
85
+
86
+ this._box = DomUtil.create('div', 'leaflet-zoom-box', this._container);
87
+ DomUtil.addClass(this._container, 'leaflet-crosshair');
88
+
89
+ this._map.fire('boxzoomstart');
90
+ }
91
+
92
+ this._point = this._map.mouseEventToContainerPoint(e);
93
+
94
+ var bounds = new Bounds(this._point, this._startPoint),
95
+ size = bounds.getSize();
96
+
97
+ DomUtil.setPosition(this._box, bounds.min);
98
+
99
+ this._box.style.width = size.x + 'px';
100
+ this._box.style.height = size.y + 'px';
101
+ },
102
+
103
+ _finish: function () {
104
+ if (this._moved) {
105
+ DomUtil.remove(this._box);
106
+ DomUtil.removeClass(this._container, 'leaflet-crosshair');
107
+ }
108
+
109
+ DomUtil.enableTextSelection();
110
+ DomUtil.enableImageDrag();
111
+
112
+ DomEvent.off(document, {
113
+ contextmenu: DomEvent.stop,
114
+ mousemove: this._onMouseMove,
115
+ mouseup: this._onMouseUp,
116
+ keydown: this._onKeyDown
117
+ }, this);
118
+ },
119
+
120
+ _onMouseUp: function (e) {
121
+ if ((e.which !== 1) && (e.button !== 1)) { return; }
122
+
123
+ this._finish();
124
+
125
+ if (!this._moved) { return; }
126
+ // Postpone to next JS tick so internal click event handling
127
+ // still see it as "moved".
128
+ this._clearDeferredResetState();
129
+ this._resetStateTimeout = setTimeout(Util.bind(this._resetState, this), 0);
130
+
131
+ var bounds = new LatLngBounds(
132
+ this._map.containerPointToLatLng(this._startPoint),
133
+ this._map.containerPointToLatLng(this._point));
134
+
135
+ this._map
136
+ .fitBounds(bounds)
137
+ .fire('boxzoomend', {boxZoomBounds: bounds});
138
+ },
139
+
140
+ _onKeyDown: function (e) {
141
+ if (e.keyCode === 27) {
142
+ this._finish();
143
+ this._clearDeferredResetState();
144
+ this._resetState();
145
+ }
146
+ }
147
+ });
148
+
149
+ // @section Handlers
150
+ // @property boxZoom: Handler
151
+ // Box (shift-drag with mouse) zoom handler.
152
+ Map.addInitHook('addHandler', 'boxZoom', BoxZoom);
@@ -0,0 +1,55 @@
1
+ import {Map} from '../Map';
2
+ import {Handler} from '../../core/Handler';
3
+
4
+ /*
5
+ * L.Handler.DoubleClickZoom is used to handle double-click zoom on the map, enabled by default.
6
+ */
7
+
8
+ // @namespace Map
9
+ // @section Interaction Options
10
+
11
+ Map.mergeOptions({
12
+ // @option doubleClickZoom: Boolean|String = true
13
+ // Whether the map can be zoomed in by double clicking on it and
14
+ // zoomed out by double clicking while holding shift. If passed
15
+ // `'center'`, double-click zoom will zoom to the center of the
16
+ // view regardless of where the mouse was.
17
+ doubleClickZoom: true
18
+ });
19
+
20
+ export var DoubleClickZoom = Handler.extend({
21
+ addHooks: function () {
22
+ this._map.on('dblclick', this._onDoubleClick, this);
23
+ },
24
+
25
+ removeHooks: function () {
26
+ this._map.off('dblclick', this._onDoubleClick, this);
27
+ },
28
+
29
+ _onDoubleClick: function (e) {
30
+ var map = this._map,
31
+ oldZoom = map.getZoom(),
32
+ delta = map.options.zoomDelta,
33
+ zoom = e.originalEvent.shiftKey ? oldZoom - delta : oldZoom + delta;
34
+
35
+ if (map.options.doubleClickZoom === 'center') {
36
+ map.setZoom(zoom);
37
+ } else {
38
+ map.setZoomAround(e.containerPoint, zoom);
39
+ }
40
+ }
41
+ });
42
+
43
+ // @section Handlers
44
+ //
45
+ // Map properties include interaction handlers that allow you to control
46
+ // interaction behavior in runtime, enabling or disabling certain features such
47
+ // as dragging or touch zoom (see `Handler` methods). For example:
48
+ //
49
+ // ```js
50
+ // map.doubleClickZoom.disable();
51
+ // ```
52
+ //
53
+ // @property doubleClickZoom: Handler
54
+ // Double click zoom handler.
55
+ Map.addInitHook('addHandler', 'doubleClickZoom', DoubleClickZoom);
@@ -0,0 +1,235 @@
1
+ import {Map} from '../Map';
2
+ import {Handler} from '../../core/Handler';
3
+ import {Draggable} from '../../dom/Draggable';
4
+ import * as Util from '../../core/Util';
5
+ import * as DomUtil from '../../dom/DomUtil';
6
+ import {toLatLngBounds as latLngBounds} from '../../geo/LatLngBounds';
7
+ import {toBounds} from '../../geometry/Bounds';
8
+
9
+ /*
10
+ * L.Handler.MapDrag is used to make the map draggable (with panning inertia), enabled by default.
11
+ */
12
+
13
+ // @namespace Map
14
+ // @section Interaction Options
15
+ Map.mergeOptions({
16
+ // @option dragging: Boolean = true
17
+ // Whether the map is draggable with mouse/touch or not.
18
+ dragging: true,
19
+
20
+ // @section Panning Inertia Options
21
+ // @option inertia: Boolean = *
22
+ // If enabled, panning of the map will have an inertia effect where
23
+ // the map builds momentum while dragging and continues moving in
24
+ // the same direction for some time. Feels especially nice on touch
25
+ // devices. Enabled by default.
26
+ inertia: true,
27
+
28
+ // @option inertiaDeceleration: Number = 3000
29
+ // The rate with which the inertial movement slows down, in pixels/second².
30
+ inertiaDeceleration: 3400, // px/s^2
31
+
32
+ // @option inertiaMaxSpeed: Number = Infinity
33
+ // Max speed of the inertial movement, in pixels/second.
34
+ inertiaMaxSpeed: Infinity, // px/s
35
+
36
+ // @option easeLinearity: Number = 0.2
37
+ easeLinearity: 0.2,
38
+
39
+ // TODO refactor, move to CRS
40
+ // @option worldCopyJump: Boolean = false
41
+ // With this option enabled, the map tracks when you pan to another "copy"
42
+ // of the world and seamlessly jumps to the original one so that all overlays
43
+ // like markers and vector layers are still visible.
44
+ worldCopyJump: false,
45
+
46
+ // @option maxBoundsViscosity: Number = 0.0
47
+ // If `maxBounds` is set, this option will control how solid the bounds
48
+ // are when dragging the map around. The default value of `0.0` allows the
49
+ // user to drag outside the bounds at normal speed, higher values will
50
+ // slow down map dragging outside bounds, and `1.0` makes the bounds fully
51
+ // solid, preventing the user from dragging outside the bounds.
52
+ maxBoundsViscosity: 0.0
53
+ });
54
+
55
+ export var Drag = Handler.extend({
56
+ addHooks: function () {
57
+ if (!this._draggable) {
58
+ var map = this._map;
59
+
60
+ this._draggable = new Draggable(map._mapPane, map._container);
61
+
62
+ this._draggable.on({
63
+ dragstart: this._onDragStart,
64
+ drag: this._onDrag,
65
+ dragend: this._onDragEnd
66
+ }, this);
67
+
68
+ this._draggable.on('predrag', this._onPreDragLimit, this);
69
+ if (map.options.worldCopyJump) {
70
+ this._draggable.on('predrag', this._onPreDragWrap, this);
71
+ map.on('zoomend', this._onZoomEnd, this);
72
+
73
+ map.whenReady(this._onZoomEnd, this);
74
+ }
75
+ }
76
+ DomUtil.addClass(this._map._container, 'leaflet-grab leaflet-touch-drag');
77
+ this._draggable.enable();
78
+ this._positions = [];
79
+ this._times = [];
80
+ },
81
+
82
+ removeHooks: function () {
83
+ DomUtil.removeClass(this._map._container, 'leaflet-grab');
84
+ DomUtil.removeClass(this._map._container, 'leaflet-touch-drag');
85
+ this._draggable.disable();
86
+ },
87
+
88
+ moved: function () {
89
+ return this._draggable && this._draggable._moved;
90
+ },
91
+
92
+ moving: function () {
93
+ return this._draggable && this._draggable._moving;
94
+ },
95
+
96
+ _onDragStart: function () {
97
+ var map = this._map;
98
+
99
+ map._stop();
100
+ if (this._map.options.maxBounds && this._map.options.maxBoundsViscosity) {
101
+ var bounds = latLngBounds(this._map.options.maxBounds);
102
+
103
+ this._offsetLimit = toBounds(
104
+ this._map.latLngToContainerPoint(bounds.getNorthWest()).multiplyBy(-1),
105
+ this._map.latLngToContainerPoint(bounds.getSouthEast()).multiplyBy(-1)
106
+ .add(this._map.getSize()));
107
+
108
+ this._viscosity = Math.min(1.0, Math.max(0.0, this._map.options.maxBoundsViscosity));
109
+ } else {
110
+ this._offsetLimit = null;
111
+ }
112
+
113
+ map
114
+ .fire('movestart')
115
+ .fire('dragstart');
116
+
117
+ if (map.options.inertia) {
118
+ this._positions = [];
119
+ this._times = [];
120
+ }
121
+ },
122
+
123
+ _onDrag: function (e) {
124
+ if (this._map.options.inertia) {
125
+ var time = this._lastTime = +new Date(),
126
+ pos = this._lastPos = this._draggable._absPos || this._draggable._newPos;
127
+
128
+ this._positions.push(pos);
129
+ this._times.push(time);
130
+
131
+ this._prunePositions(time);
132
+ }
133
+
134
+ this._map
135
+ .fire('move', e)
136
+ .fire('drag', e);
137
+ },
138
+
139
+ _prunePositions: function (time) {
140
+ while (this._positions.length > 1 && time - this._times[0] > 50) {
141
+ this._positions.shift();
142
+ this._times.shift();
143
+ }
144
+ },
145
+
146
+ _onZoomEnd: function () {
147
+ var pxCenter = this._map.getSize().divideBy(2),
148
+ pxWorldCenter = this._map.latLngToLayerPoint([0, 0]);
149
+
150
+ this._initialWorldOffset = pxWorldCenter.subtract(pxCenter).x;
151
+ this._worldWidth = this._map.getPixelWorldBounds().getSize().x;
152
+ },
153
+
154
+ _viscousLimit: function (value, threshold) {
155
+ return value - (value - threshold) * this._viscosity;
156
+ },
157
+
158
+ _onPreDragLimit: function () {
159
+ if (!this._viscosity || !this._offsetLimit) { return; }
160
+
161
+ var offset = this._draggable._newPos.subtract(this._draggable._startPos);
162
+
163
+ var limit = this._offsetLimit;
164
+ if (offset.x < limit.min.x) { offset.x = this._viscousLimit(offset.x, limit.min.x); }
165
+ if (offset.y < limit.min.y) { offset.y = this._viscousLimit(offset.y, limit.min.y); }
166
+ if (offset.x > limit.max.x) { offset.x = this._viscousLimit(offset.x, limit.max.x); }
167
+ if (offset.y > limit.max.y) { offset.y = this._viscousLimit(offset.y, limit.max.y); }
168
+
169
+ this._draggable._newPos = this._draggable._startPos.add(offset);
170
+ },
171
+
172
+ _onPreDragWrap: function () {
173
+ // TODO refactor to be able to adjust map pane position after zoom
174
+ var worldWidth = this._worldWidth,
175
+ halfWidth = Math.round(worldWidth / 2),
176
+ dx = this._initialWorldOffset,
177
+ x = this._draggable._newPos.x,
178
+ newX1 = (x - halfWidth + dx) % worldWidth + halfWidth - dx,
179
+ newX2 = (x + halfWidth + dx) % worldWidth - halfWidth - dx,
180
+ newX = Math.abs(newX1 + dx) < Math.abs(newX2 + dx) ? newX1 : newX2;
181
+
182
+ this._draggable._absPos = this._draggable._newPos.clone();
183
+ this._draggable._newPos.x = newX;
184
+ },
185
+
186
+ _onDragEnd: function (e) {
187
+ var map = this._map,
188
+ options = map.options,
189
+
190
+ noInertia = !options.inertia || e.noInertia || this._times.length < 2;
191
+
192
+ map.fire('dragend', e);
193
+
194
+ if (noInertia) {
195
+ map.fire('moveend');
196
+
197
+ } else {
198
+ this._prunePositions(+new Date());
199
+
200
+ var direction = this._lastPos.subtract(this._positions[0]),
201
+ duration = (this._lastTime - this._times[0]) / 1000,
202
+ ease = options.easeLinearity,
203
+
204
+ speedVector = direction.multiplyBy(ease / duration),
205
+ speed = speedVector.distanceTo([0, 0]),
206
+
207
+ limitedSpeed = Math.min(options.inertiaMaxSpeed, speed),
208
+ limitedSpeedVector = speedVector.multiplyBy(limitedSpeed / speed),
209
+
210
+ decelerationDuration = limitedSpeed / (options.inertiaDeceleration * ease),
211
+ offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round();
212
+
213
+ if (!offset.x && !offset.y) {
214
+ map.fire('moveend');
215
+
216
+ } else {
217
+ offset = map._limitOffset(offset, map.options.maxBounds);
218
+
219
+ Util.requestAnimFrame(function () {
220
+ map.panBy(offset, {
221
+ duration: decelerationDuration,
222
+ easeLinearity: ease,
223
+ noMoveStart: true,
224
+ animate: true
225
+ });
226
+ });
227
+ }
228
+ }
229
+ }
230
+ });
231
+
232
+ // @section Handlers
233
+ // @property dragging: Handler
234
+ // Map dragging handler (by both mouse and touch).
235
+ Map.addInitHook('addHandler', 'dragging', Drag);