decidim 0.26.9 → 0.26.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/decidim/version.rb +1 -1
- data/package-lock.json +7 -7
- data/packages/browserslist-config/package.json +1 -1
- data/packages/core/node_modules/leaflet/CHANGELOG.md +2191 -0
- data/packages/core/node_modules/leaflet/LICENSE +26 -0
- data/packages/core/node_modules/leaflet/README.md +55 -0
- data/packages/core/node_modules/leaflet/dist/images/layers-2x.png +0 -0
- data/packages/core/node_modules/leaflet/dist/images/layers.png +0 -0
- data/packages/core/node_modules/leaflet/dist/images/marker-icon-2x.png +0 -0
- data/packages/core/node_modules/leaflet/dist/images/marker-icon.png +0 -0
- data/packages/core/node_modules/leaflet/dist/images/marker-shadow.png +0 -0
- data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js +14419 -0
- data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js.map +1 -0
- data/packages/core/node_modules/leaflet/dist/leaflet-src.js +14512 -0
- data/packages/core/node_modules/leaflet/dist/leaflet-src.js.map +1 -0
- data/packages/core/node_modules/leaflet/dist/leaflet.css +661 -0
- data/packages/core/node_modules/leaflet/dist/leaflet.js +6 -0
- data/packages/core/node_modules/leaflet/dist/leaflet.js.map +1 -0
- data/packages/core/node_modules/leaflet/package.json +149 -0
- data/packages/core/node_modules/leaflet/src/Leaflet.js +24 -0
- data/packages/core/node_modules/leaflet/src/control/Control.Attribution.js +148 -0
- data/packages/core/node_modules/leaflet/src/control/Control.Layers.js +443 -0
- data/packages/core/node_modules/leaflet/src/control/Control.Scale.js +132 -0
- data/packages/core/node_modules/leaflet/src/control/Control.Zoom.js +146 -0
- data/packages/core/node_modules/leaflet/src/control/Control.js +174 -0
- data/packages/core/node_modules/leaflet/src/control/index.js +17 -0
- data/packages/core/node_modules/leaflet/src/core/Browser.js +220 -0
- data/packages/core/node_modules/leaflet/src/core/Class.js +135 -0
- data/packages/core/node_modules/leaflet/src/core/Class.leafdoc +197 -0
- data/packages/core/node_modules/leaflet/src/core/Events.js +344 -0
- data/packages/core/node_modules/leaflet/src/core/Events.leafdoc +143 -0
- data/packages/core/node_modules/leaflet/src/core/Handler.js +57 -0
- data/packages/core/node_modules/leaflet/src/core/Util.js +241 -0
- data/packages/core/node_modules/leaflet/src/core/index.js +15 -0
- data/packages/core/node_modules/leaflet/src/dom/DomEvent.DoubleTap.js +91 -0
- data/packages/core/node_modules/leaflet/src/dom/DomEvent.Pointer.js +97 -0
- data/packages/core/node_modules/leaflet/src/dom/DomEvent.js +315 -0
- data/packages/core/node_modules/leaflet/src/dom/DomUtil.js +349 -0
- data/packages/core/node_modules/leaflet/src/dom/Draggable.js +220 -0
- data/packages/core/node_modules/leaflet/src/dom/PosAnimation.js +113 -0
- data/packages/core/node_modules/leaflet/src/dom/index.js +9 -0
- data/packages/core/node_modules/leaflet/src/geo/LatLng.js +137 -0
- data/packages/core/node_modules/leaflet/src/geo/LatLngBounds.js +251 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3395.js +20 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3857.js +27 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG4326.js +23 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Earth.js +33 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Simple.js +36 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/CRS.js +139 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/index.js +15 -0
- data/packages/core/node_modules/leaflet/src/geo/index.js +7 -0
- data/packages/core/node_modules/leaflet/src/geo/projection/Projection.LonLat.js +28 -0
- data/packages/core/node_modules/leaflet/src/geo/projection/Projection.Mercator.js +49 -0
- data/packages/core/node_modules/leaflet/src/geo/projection/Projection.SphericalMercator.js +44 -0
- data/packages/core/node_modules/leaflet/src/geo/projection/index.js +26 -0
- data/packages/core/node_modules/leaflet/src/geometry/Bounds.js +219 -0
- data/packages/core/node_modules/leaflet/src/geometry/LineUtil.js +306 -0
- data/packages/core/node_modules/leaflet/src/geometry/Point.js +222 -0
- data/packages/core/node_modules/leaflet/src/geometry/PolyUtil.js +129 -0
- data/packages/core/node_modules/leaflet/src/geometry/Transformation.js +79 -0
- data/packages/core/node_modules/leaflet/src/geometry/index.js +8 -0
- data/packages/core/node_modules/leaflet/src/images/layers.svg +1 -0
- data/packages/core/node_modules/leaflet/src/images/logo.svg +1 -0
- data/packages/core/node_modules/leaflet/src/images/marker.svg +1 -0
- data/packages/core/node_modules/leaflet/src/layer/DivOverlay.js +348 -0
- data/packages/core/node_modules/leaflet/src/layer/FeatureGroup.js +94 -0
- data/packages/core/node_modules/leaflet/src/layer/GeoJSON.js +452 -0
- data/packages/core/node_modules/leaflet/src/layer/ImageOverlay.js +270 -0
- data/packages/core/node_modules/leaflet/src/layer/Layer.Interactive.leafdoc +39 -0
- data/packages/core/node_modules/leaflet/src/layer/Layer.js +275 -0
- data/packages/core/node_modules/leaflet/src/layer/LayerGroup.js +159 -0
- data/packages/core/node_modules/leaflet/src/layer/Popup.js +506 -0
- data/packages/core/node_modules/leaflet/src/layer/SVGOverlay.js +50 -0
- data/packages/core/node_modules/leaflet/src/layer/Tooltip.js +444 -0
- data/packages/core/node_modules/leaflet/src/layer/VideoOverlay.js +106 -0
- data/packages/core/node_modules/leaflet/src/layer/index.js +24 -0
- data/packages/core/node_modules/leaflet/src/layer/marker/DivIcon.js +74 -0
- data/packages/core/node_modules/leaflet/src/layer/marker/Icon.Default.js +66 -0
- data/packages/core/node_modules/leaflet/src/layer/marker/Icon.js +165 -0
- data/packages/core/node_modules/leaflet/src/layer/marker/Marker.Drag.js +161 -0
- data/packages/core/node_modules/leaflet/src/layer/marker/Marker.js +419 -0
- data/packages/core/node_modules/leaflet/src/layer/marker/index.js +8 -0
- data/packages/core/node_modules/leaflet/src/layer/tile/GridLayer.js +923 -0
- data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.WMS.js +137 -0
- data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.js +289 -0
- data/packages/core/node_modules/leaflet/src/layer/tile/index.js +6 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Canvas.js +492 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Circle.js +113 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/CircleMarker.js +109 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Path.js +148 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Polygon.js +159 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Polyline.js +307 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Rectangle.js +57 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.getRenderer.js +45 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.js +133 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/SVG.Util.js +39 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/SVG.VML.js +144 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/SVG.js +207 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/index.js +14 -0
- data/packages/core/node_modules/leaflet/src/map/Map.js +1751 -0
- data/packages/core/node_modules/leaflet/src/map/Map.methodOptions.leafdoc +112 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.BoxZoom.js +152 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.DoubleClickZoom.js +55 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.Drag.js +235 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.Keyboard.js +183 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.ScrollWheelZoom.js +91 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.TapHold.js +102 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.TouchZoom.js +130 -0
- data/packages/core/node_modules/leaflet/src/map/index.js +17 -0
- data/packages/core/package.json +1 -1
- data/packages/dev/package.json +1 -1
- data/packages/elections/package.json +1 -1
- data/packages/eslint-config/package.json +1 -1
- data/packages/stylelint-config/package.json +1 -1
- data/packages/webpacker/package.json +1 -1
- metadata +148 -42
@@ -0,0 +1,183 @@
|
|
1
|
+
import {Map} from '../Map';
|
2
|
+
import {Handler} from '../../core/Handler';
|
3
|
+
import {on, off, stop} from '../../dom/DomEvent';
|
4
|
+
import {toPoint} from '../../geometry/Point';
|
5
|
+
|
6
|
+
|
7
|
+
/*
|
8
|
+
* L.Map.Keyboard is handling keyboard interaction with the map, enabled by default.
|
9
|
+
*/
|
10
|
+
|
11
|
+
// @namespace Map
|
12
|
+
// @section Keyboard Navigation Options
|
13
|
+
Map.mergeOptions({
|
14
|
+
// @option keyboard: Boolean = true
|
15
|
+
// Makes the map focusable and allows users to navigate the map with keyboard
|
16
|
+
// arrows and `+`/`-` keys.
|
17
|
+
keyboard: true,
|
18
|
+
|
19
|
+
// @option keyboardPanDelta: Number = 80
|
20
|
+
// Amount of pixels to pan when pressing an arrow key.
|
21
|
+
keyboardPanDelta: 80
|
22
|
+
});
|
23
|
+
|
24
|
+
export var Keyboard = Handler.extend({
|
25
|
+
|
26
|
+
keyCodes: {
|
27
|
+
left: [37],
|
28
|
+
right: [39],
|
29
|
+
down: [40],
|
30
|
+
up: [38],
|
31
|
+
zoomIn: [187, 107, 61, 171],
|
32
|
+
zoomOut: [189, 109, 54, 173]
|
33
|
+
},
|
34
|
+
|
35
|
+
initialize: function (map) {
|
36
|
+
this._map = map;
|
37
|
+
|
38
|
+
this._setPanDelta(map.options.keyboardPanDelta);
|
39
|
+
this._setZoomDelta(map.options.zoomDelta);
|
40
|
+
},
|
41
|
+
|
42
|
+
addHooks: function () {
|
43
|
+
var container = this._map._container;
|
44
|
+
|
45
|
+
// make the container focusable by tabbing
|
46
|
+
if (container.tabIndex <= 0) {
|
47
|
+
container.tabIndex = '0';
|
48
|
+
}
|
49
|
+
|
50
|
+
on(container, {
|
51
|
+
focus: this._onFocus,
|
52
|
+
blur: this._onBlur,
|
53
|
+
mousedown: this._onMouseDown
|
54
|
+
}, this);
|
55
|
+
|
56
|
+
this._map.on({
|
57
|
+
focus: this._addHooks,
|
58
|
+
blur: this._removeHooks
|
59
|
+
}, this);
|
60
|
+
},
|
61
|
+
|
62
|
+
removeHooks: function () {
|
63
|
+
this._removeHooks();
|
64
|
+
|
65
|
+
off(this._map._container, {
|
66
|
+
focus: this._onFocus,
|
67
|
+
blur: this._onBlur,
|
68
|
+
mousedown: this._onMouseDown
|
69
|
+
}, this);
|
70
|
+
|
71
|
+
this._map.off({
|
72
|
+
focus: this._addHooks,
|
73
|
+
blur: this._removeHooks
|
74
|
+
}, this);
|
75
|
+
},
|
76
|
+
|
77
|
+
_onMouseDown: function () {
|
78
|
+
if (this._focused) { return; }
|
79
|
+
|
80
|
+
var body = document.body,
|
81
|
+
docEl = document.documentElement,
|
82
|
+
top = body.scrollTop || docEl.scrollTop,
|
83
|
+
left = body.scrollLeft || docEl.scrollLeft;
|
84
|
+
|
85
|
+
this._map._container.focus();
|
86
|
+
|
87
|
+
window.scrollTo(left, top);
|
88
|
+
},
|
89
|
+
|
90
|
+
_onFocus: function () {
|
91
|
+
this._focused = true;
|
92
|
+
this._map.fire('focus');
|
93
|
+
},
|
94
|
+
|
95
|
+
_onBlur: function () {
|
96
|
+
this._focused = false;
|
97
|
+
this._map.fire('blur');
|
98
|
+
},
|
99
|
+
|
100
|
+
_setPanDelta: function (panDelta) {
|
101
|
+
var keys = this._panKeys = {},
|
102
|
+
codes = this.keyCodes,
|
103
|
+
i, len;
|
104
|
+
|
105
|
+
for (i = 0, len = codes.left.length; i < len; i++) {
|
106
|
+
keys[codes.left[i]] = [-1 * panDelta, 0];
|
107
|
+
}
|
108
|
+
for (i = 0, len = codes.right.length; i < len; i++) {
|
109
|
+
keys[codes.right[i]] = [panDelta, 0];
|
110
|
+
}
|
111
|
+
for (i = 0, len = codes.down.length; i < len; i++) {
|
112
|
+
keys[codes.down[i]] = [0, panDelta];
|
113
|
+
}
|
114
|
+
for (i = 0, len = codes.up.length; i < len; i++) {
|
115
|
+
keys[codes.up[i]] = [0, -1 * panDelta];
|
116
|
+
}
|
117
|
+
},
|
118
|
+
|
119
|
+
_setZoomDelta: function (zoomDelta) {
|
120
|
+
var keys = this._zoomKeys = {},
|
121
|
+
codes = this.keyCodes,
|
122
|
+
i, len;
|
123
|
+
|
124
|
+
for (i = 0, len = codes.zoomIn.length; i < len; i++) {
|
125
|
+
keys[codes.zoomIn[i]] = zoomDelta;
|
126
|
+
}
|
127
|
+
for (i = 0, len = codes.zoomOut.length; i < len; i++) {
|
128
|
+
keys[codes.zoomOut[i]] = -zoomDelta;
|
129
|
+
}
|
130
|
+
},
|
131
|
+
|
132
|
+
_addHooks: function () {
|
133
|
+
on(document, 'keydown', this._onKeyDown, this);
|
134
|
+
},
|
135
|
+
|
136
|
+
_removeHooks: function () {
|
137
|
+
off(document, 'keydown', this._onKeyDown, this);
|
138
|
+
},
|
139
|
+
|
140
|
+
_onKeyDown: function (e) {
|
141
|
+
if (e.altKey || e.ctrlKey || e.metaKey) { return; }
|
142
|
+
|
143
|
+
var key = e.keyCode,
|
144
|
+
map = this._map,
|
145
|
+
offset;
|
146
|
+
|
147
|
+
if (key in this._panKeys) {
|
148
|
+
if (!map._panAnim || !map._panAnim._inProgress) {
|
149
|
+
offset = this._panKeys[key];
|
150
|
+
if (e.shiftKey) {
|
151
|
+
offset = toPoint(offset).multiplyBy(3);
|
152
|
+
}
|
153
|
+
|
154
|
+
if (map.options.maxBounds) {
|
155
|
+
offset = map._limitOffset(toPoint(offset), map.options.maxBounds);
|
156
|
+
}
|
157
|
+
|
158
|
+
if (map.options.worldCopyJump) {
|
159
|
+
var newLatLng = map.wrapLatLng(map.unproject(map.project(map.getCenter()).add(offset)));
|
160
|
+
map.panTo(newLatLng);
|
161
|
+
} else {
|
162
|
+
map.panBy(offset);
|
163
|
+
}
|
164
|
+
}
|
165
|
+
} else if (key in this._zoomKeys) {
|
166
|
+
map.setZoom(map.getZoom() + (e.shiftKey ? 3 : 1) * this._zoomKeys[key]);
|
167
|
+
|
168
|
+
} else if (key === 27 && map._popup && map._popup.options.closeOnEscapeKey) {
|
169
|
+
map.closePopup();
|
170
|
+
|
171
|
+
} else {
|
172
|
+
return;
|
173
|
+
}
|
174
|
+
|
175
|
+
stop(e);
|
176
|
+
}
|
177
|
+
});
|
178
|
+
|
179
|
+
// @section Handlers
|
180
|
+
// @section Handlers
|
181
|
+
// @property keyboard: Handler
|
182
|
+
// Keyboard navigation handler.
|
183
|
+
Map.addInitHook('addHandler', 'keyboard', Keyboard);
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import {Map} from '../Map';
|
2
|
+
import {Handler} from '../../core/Handler';
|
3
|
+
import * as DomEvent from '../../dom/DomEvent';
|
4
|
+
import * as Util from '../../core/Util';
|
5
|
+
|
6
|
+
/*
|
7
|
+
* L.Handler.ScrollWheelZoom is used by L.Map to enable mouse scroll wheel zoom on the map.
|
8
|
+
*/
|
9
|
+
|
10
|
+
// @namespace Map
|
11
|
+
// @section Interaction Options
|
12
|
+
Map.mergeOptions({
|
13
|
+
// @section Mouse wheel options
|
14
|
+
// @option scrollWheelZoom: Boolean|String = true
|
15
|
+
// Whether the map can be zoomed by using the mouse wheel. If passed `'center'`,
|
16
|
+
// it will zoom to the center of the view regardless of where the mouse was.
|
17
|
+
scrollWheelZoom: true,
|
18
|
+
|
19
|
+
// @option wheelDebounceTime: Number = 40
|
20
|
+
// Limits the rate at which a wheel can fire (in milliseconds). By default
|
21
|
+
// user can't zoom via wheel more often than once per 40 ms.
|
22
|
+
wheelDebounceTime: 40,
|
23
|
+
|
24
|
+
// @option wheelPxPerZoomLevel: Number = 60
|
25
|
+
// How many scroll pixels (as reported by [L.DomEvent.getWheelDelta](#domevent-getwheeldelta))
|
26
|
+
// mean a change of one full zoom level. Smaller values will make wheel-zooming
|
27
|
+
// faster (and vice versa).
|
28
|
+
wheelPxPerZoomLevel: 60
|
29
|
+
});
|
30
|
+
|
31
|
+
export var ScrollWheelZoom = Handler.extend({
|
32
|
+
addHooks: function () {
|
33
|
+
DomEvent.on(this._map._container, 'wheel', this._onWheelScroll, this);
|
34
|
+
|
35
|
+
this._delta = 0;
|
36
|
+
},
|
37
|
+
|
38
|
+
removeHooks: function () {
|
39
|
+
DomEvent.off(this._map._container, 'wheel', this._onWheelScroll, this);
|
40
|
+
},
|
41
|
+
|
42
|
+
_onWheelScroll: function (e) {
|
43
|
+
var delta = DomEvent.getWheelDelta(e);
|
44
|
+
|
45
|
+
var debounce = this._map.options.wheelDebounceTime;
|
46
|
+
|
47
|
+
this._delta += delta;
|
48
|
+
this._lastMousePos = this._map.mouseEventToContainerPoint(e);
|
49
|
+
|
50
|
+
if (!this._startTime) {
|
51
|
+
this._startTime = +new Date();
|
52
|
+
}
|
53
|
+
|
54
|
+
var left = Math.max(debounce - (+new Date() - this._startTime), 0);
|
55
|
+
|
56
|
+
clearTimeout(this._timer);
|
57
|
+
this._timer = setTimeout(Util.bind(this._performZoom, this), left);
|
58
|
+
|
59
|
+
DomEvent.stop(e);
|
60
|
+
},
|
61
|
+
|
62
|
+
_performZoom: function () {
|
63
|
+
var map = this._map,
|
64
|
+
zoom = map.getZoom(),
|
65
|
+
snap = this._map.options.zoomSnap || 0;
|
66
|
+
|
67
|
+
map._stop(); // stop panning and fly animations if any
|
68
|
+
|
69
|
+
// map the delta with a sigmoid function to -4..4 range leaning on -1..1
|
70
|
+
var d2 = this._delta / (this._map.options.wheelPxPerZoomLevel * 4),
|
71
|
+
d3 = 4 * Math.log(2 / (1 + Math.exp(-Math.abs(d2)))) / Math.LN2,
|
72
|
+
d4 = snap ? Math.ceil(d3 / snap) * snap : d3,
|
73
|
+
delta = map._limitZoom(zoom + (this._delta > 0 ? d4 : -d4)) - zoom;
|
74
|
+
|
75
|
+
this._delta = 0;
|
76
|
+
this._startTime = null;
|
77
|
+
|
78
|
+
if (!delta) { return; }
|
79
|
+
|
80
|
+
if (map.options.scrollWheelZoom === 'center') {
|
81
|
+
map.setZoom(zoom + delta);
|
82
|
+
} else {
|
83
|
+
map.setZoomAround(this._lastMousePos, zoom + delta);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
});
|
87
|
+
|
88
|
+
// @section Handlers
|
89
|
+
// @property scrollWheelZoom: Handler
|
90
|
+
// Scroll wheel zoom handler.
|
91
|
+
Map.addInitHook('addHandler', 'scrollWheelZoom', ScrollWheelZoom);
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import {Map} from '../Map';
|
2
|
+
import {Handler} from '../../core/Handler';
|
3
|
+
import * as DomEvent from '../../dom/DomEvent';
|
4
|
+
import {Point} from '../../geometry/Point';
|
5
|
+
import * as Util from '../../core/Util';
|
6
|
+
import Browser from '../../core/Browser';
|
7
|
+
|
8
|
+
/*
|
9
|
+
* L.Map.TapHold is used to simulate `contextmenu` event on long hold,
|
10
|
+
* which otherwise is not fired by mobile Safari.
|
11
|
+
*/
|
12
|
+
|
13
|
+
var tapHoldDelay = 600;
|
14
|
+
|
15
|
+
// @namespace Map
|
16
|
+
// @section Interaction Options
|
17
|
+
Map.mergeOptions({
|
18
|
+
// @section Touch interaction options
|
19
|
+
// @option tapHold: Boolean
|
20
|
+
// Enables simulation of `contextmenu` event, default is `true` for mobile Safari.
|
21
|
+
tapHold: Browser.touchNative && Browser.safari && Browser.mobile,
|
22
|
+
|
23
|
+
// @option tapTolerance: Number = 15
|
24
|
+
// The max number of pixels a user can shift his finger during touch
|
25
|
+
// for it to be considered a valid tap.
|
26
|
+
tapTolerance: 15
|
27
|
+
});
|
28
|
+
|
29
|
+
export var TapHold = Handler.extend({
|
30
|
+
addHooks: function () {
|
31
|
+
DomEvent.on(this._map._container, 'touchstart', this._onDown, this);
|
32
|
+
},
|
33
|
+
|
34
|
+
removeHooks: function () {
|
35
|
+
DomEvent.off(this._map._container, 'touchstart', this._onDown, this);
|
36
|
+
},
|
37
|
+
|
38
|
+
_onDown: function (e) {
|
39
|
+
clearTimeout(this._holdTimeout);
|
40
|
+
if (e.touches.length !== 1) { return; }
|
41
|
+
|
42
|
+
var first = e.touches[0];
|
43
|
+
this._startPos = this._newPos = new Point(first.clientX, first.clientY);
|
44
|
+
|
45
|
+
this._holdTimeout = setTimeout(Util.bind(function () {
|
46
|
+
this._cancel();
|
47
|
+
if (!this._isTapValid()) { return; }
|
48
|
+
|
49
|
+
// prevent simulated mouse events https://w3c.github.io/touch-events/#mouse-events
|
50
|
+
DomEvent.on(document, 'touchend', DomEvent.preventDefault);
|
51
|
+
DomEvent.on(document, 'touchend touchcancel', this._cancelClickPrevent);
|
52
|
+
this._simulateEvent('contextmenu', first);
|
53
|
+
}, this), tapHoldDelay);
|
54
|
+
|
55
|
+
DomEvent.on(document, 'touchend touchcancel contextmenu', this._cancel, this);
|
56
|
+
DomEvent.on(document, 'touchmove', this._onMove, this);
|
57
|
+
},
|
58
|
+
|
59
|
+
_cancelClickPrevent: function cancelClickPrevent() {
|
60
|
+
DomEvent.off(document, 'touchend', DomEvent.preventDefault);
|
61
|
+
DomEvent.off(document, 'touchend touchcancel', cancelClickPrevent);
|
62
|
+
},
|
63
|
+
|
64
|
+
_cancel: function () {
|
65
|
+
clearTimeout(this._holdTimeout);
|
66
|
+
DomEvent.off(document, 'touchend touchcancel contextmenu', this._cancel, this);
|
67
|
+
DomEvent.off(document, 'touchmove', this._onMove, this);
|
68
|
+
},
|
69
|
+
|
70
|
+
_onMove: function (e) {
|
71
|
+
var first = e.touches[0];
|
72
|
+
this._newPos = new Point(first.clientX, first.clientY);
|
73
|
+
},
|
74
|
+
|
75
|
+
_isTapValid: function () {
|
76
|
+
return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance;
|
77
|
+
},
|
78
|
+
|
79
|
+
_simulateEvent: function (type, e) {
|
80
|
+
var simulatedEvent = new MouseEvent(type, {
|
81
|
+
bubbles: true,
|
82
|
+
cancelable: true,
|
83
|
+
view: window,
|
84
|
+
// detail: 1,
|
85
|
+
screenX: e.screenX,
|
86
|
+
screenY: e.screenY,
|
87
|
+
clientX: e.clientX,
|
88
|
+
clientY: e.clientY,
|
89
|
+
// button: 2,
|
90
|
+
// buttons: 2
|
91
|
+
});
|
92
|
+
|
93
|
+
simulatedEvent._simulated = true;
|
94
|
+
|
95
|
+
e.target.dispatchEvent(simulatedEvent);
|
96
|
+
}
|
97
|
+
});
|
98
|
+
|
99
|
+
// @section Handlers
|
100
|
+
// @property tapHold: Handler
|
101
|
+
// Long tap handler to simulate `contextmenu` event (useful in mobile Safari).
|
102
|
+
Map.addInitHook('addHandler', 'tapHold', TapHold);
|
@@ -0,0 +1,130 @@
|
|
1
|
+
import {Map} from '../Map';
|
2
|
+
import {Handler} from '../../core/Handler';
|
3
|
+
import * as DomEvent from '../../dom/DomEvent';
|
4
|
+
import * as Util from '../../core/Util';
|
5
|
+
import * as DomUtil from '../../dom/DomUtil';
|
6
|
+
import Browser from '../../core/Browser';
|
7
|
+
|
8
|
+
/*
|
9
|
+
* L.Handler.TouchZoom is used by L.Map to add pinch zoom on supported mobile browsers.
|
10
|
+
*/
|
11
|
+
|
12
|
+
// @namespace Map
|
13
|
+
// @section Interaction Options
|
14
|
+
Map.mergeOptions({
|
15
|
+
// @section Touch interaction options
|
16
|
+
// @option touchZoom: Boolean|String = *
|
17
|
+
// Whether the map can be zoomed by touch-dragging with two fingers. If
|
18
|
+
// passed `'center'`, it will zoom to the center of the view regardless of
|
19
|
+
// where the touch events (fingers) were. Enabled for touch-capable web
|
20
|
+
// browsers.
|
21
|
+
touchZoom: Browser.touch,
|
22
|
+
|
23
|
+
// @option bounceAtZoomLimits: Boolean = true
|
24
|
+
// Set it to false if you don't want the map to zoom beyond min/max zoom
|
25
|
+
// and then bounce back when pinch-zooming.
|
26
|
+
bounceAtZoomLimits: true
|
27
|
+
});
|
28
|
+
|
29
|
+
export var TouchZoom = Handler.extend({
|
30
|
+
addHooks: function () {
|
31
|
+
DomUtil.addClass(this._map._container, 'leaflet-touch-zoom');
|
32
|
+
DomEvent.on(this._map._container, 'touchstart', this._onTouchStart, this);
|
33
|
+
},
|
34
|
+
|
35
|
+
removeHooks: function () {
|
36
|
+
DomUtil.removeClass(this._map._container, 'leaflet-touch-zoom');
|
37
|
+
DomEvent.off(this._map._container, 'touchstart', this._onTouchStart, this);
|
38
|
+
},
|
39
|
+
|
40
|
+
_onTouchStart: function (e) {
|
41
|
+
var map = this._map;
|
42
|
+
if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { return; }
|
43
|
+
|
44
|
+
var p1 = map.mouseEventToContainerPoint(e.touches[0]),
|
45
|
+
p2 = map.mouseEventToContainerPoint(e.touches[1]);
|
46
|
+
|
47
|
+
this._centerPoint = map.getSize()._divideBy(2);
|
48
|
+
this._startLatLng = map.containerPointToLatLng(this._centerPoint);
|
49
|
+
if (map.options.touchZoom !== 'center') {
|
50
|
+
this._pinchStartLatLng = map.containerPointToLatLng(p1.add(p2)._divideBy(2));
|
51
|
+
}
|
52
|
+
|
53
|
+
this._startDist = p1.distanceTo(p2);
|
54
|
+
this._startZoom = map.getZoom();
|
55
|
+
|
56
|
+
this._moved = false;
|
57
|
+
this._zooming = true;
|
58
|
+
|
59
|
+
map._stop();
|
60
|
+
|
61
|
+
DomEvent.on(document, 'touchmove', this._onTouchMove, this);
|
62
|
+
DomEvent.on(document, 'touchend touchcancel', this._onTouchEnd, this);
|
63
|
+
|
64
|
+
DomEvent.preventDefault(e);
|
65
|
+
},
|
66
|
+
|
67
|
+
_onTouchMove: function (e) {
|
68
|
+
if (!e.touches || e.touches.length !== 2 || !this._zooming) { return; }
|
69
|
+
|
70
|
+
var map = this._map,
|
71
|
+
p1 = map.mouseEventToContainerPoint(e.touches[0]),
|
72
|
+
p2 = map.mouseEventToContainerPoint(e.touches[1]),
|
73
|
+
scale = p1.distanceTo(p2) / this._startDist;
|
74
|
+
|
75
|
+
this._zoom = map.getScaleZoom(scale, this._startZoom);
|
76
|
+
|
77
|
+
if (!map.options.bounceAtZoomLimits && (
|
78
|
+
(this._zoom < map.getMinZoom() && scale < 1) ||
|
79
|
+
(this._zoom > map.getMaxZoom() && scale > 1))) {
|
80
|
+
this._zoom = map._limitZoom(this._zoom);
|
81
|
+
}
|
82
|
+
|
83
|
+
if (map.options.touchZoom === 'center') {
|
84
|
+
this._center = this._startLatLng;
|
85
|
+
if (scale === 1) { return; }
|
86
|
+
} else {
|
87
|
+
// Get delta from pinch to center, so centerLatLng is delta applied to initial pinchLatLng
|
88
|
+
var delta = p1._add(p2)._divideBy(2)._subtract(this._centerPoint);
|
89
|
+
if (scale === 1 && delta.x === 0 && delta.y === 0) { return; }
|
90
|
+
this._center = map.unproject(map.project(this._pinchStartLatLng, this._zoom).subtract(delta), this._zoom);
|
91
|
+
}
|
92
|
+
|
93
|
+
if (!this._moved) {
|
94
|
+
map._moveStart(true, false);
|
95
|
+
this._moved = true;
|
96
|
+
}
|
97
|
+
|
98
|
+
Util.cancelAnimFrame(this._animRequest);
|
99
|
+
|
100
|
+
var moveFn = Util.bind(map._move, map, this._center, this._zoom, {pinch: true, round: false}, undefined);
|
101
|
+
this._animRequest = Util.requestAnimFrame(moveFn, this, true);
|
102
|
+
|
103
|
+
DomEvent.preventDefault(e);
|
104
|
+
},
|
105
|
+
|
106
|
+
_onTouchEnd: function () {
|
107
|
+
if (!this._moved || !this._zooming) {
|
108
|
+
this._zooming = false;
|
109
|
+
return;
|
110
|
+
}
|
111
|
+
|
112
|
+
this._zooming = false;
|
113
|
+
Util.cancelAnimFrame(this._animRequest);
|
114
|
+
|
115
|
+
DomEvent.off(document, 'touchmove', this._onTouchMove, this);
|
116
|
+
DomEvent.off(document, 'touchend touchcancel', this._onTouchEnd, this);
|
117
|
+
|
118
|
+
// Pinch updates GridLayers' levels only when zoomSnap is off, so zoomSnap becomes noUpdate.
|
119
|
+
if (this._map.options.zoomAnimation) {
|
120
|
+
this._map._animateZoom(this._center, this._map._limitZoom(this._zoom), true, this._map.options.zoomSnap);
|
121
|
+
} else {
|
122
|
+
this._map._resetView(this._center, this._map._limitZoom(this._zoom));
|
123
|
+
}
|
124
|
+
}
|
125
|
+
});
|
126
|
+
|
127
|
+
// @section Handlers
|
128
|
+
// @property touchZoom: Handler
|
129
|
+
// Touch zoom handler.
|
130
|
+
Map.addInitHook('addHandler', 'touchZoom', TouchZoom);
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import {Map} from './Map';
|
2
|
+
import {BoxZoom} from './handler/Map.BoxZoom';
|
3
|
+
Map.BoxZoom = BoxZoom;
|
4
|
+
import {DoubleClickZoom} from './handler/Map.DoubleClickZoom';
|
5
|
+
Map.DoubleClickZoom = DoubleClickZoom;
|
6
|
+
import {Drag} from './handler/Map.Drag';
|
7
|
+
Map.Drag = Drag;
|
8
|
+
import {Keyboard} from './handler/Map.Keyboard';
|
9
|
+
Map.Keyboard = Keyboard;
|
10
|
+
import {ScrollWheelZoom} from './handler/Map.ScrollWheelZoom';
|
11
|
+
Map.ScrollWheelZoom = ScrollWheelZoom;
|
12
|
+
import {TapHold} from './handler/Map.TapHold';
|
13
|
+
Map.TapHold = TapHold;
|
14
|
+
import {TouchZoom} from './handler/Map.TouchZoom';
|
15
|
+
Map.TouchZoom = TouchZoom;
|
16
|
+
|
17
|
+
export {Map, createMap as map} from './Map';
|
data/packages/core/package.json
CHANGED
data/packages/dev/package.json
CHANGED