maplair 4.0.0-alpha.2 → 4.1.0
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/CHANGELOG.md +140 -38
- package/LICENSE +1 -1
- package/README.md +10 -9
- package/dist/esm/Maplair.js +14 -14
- package/dist/esm/control/AttributionControl.js +24 -14
- package/dist/esm/control/AttributionControl.js.map +1 -1
- package/dist/esm/control/ButtonControl.js +9 -11
- package/dist/esm/control/ButtonControl.js.map +1 -1
- package/dist/esm/control/ContextMenu.js +1 -3
- package/dist/esm/control/ContextMenu.js.map +1 -1
- package/dist/esm/control/Control.js +9 -16
- package/dist/esm/control/Control.js.map +1 -1
- package/dist/esm/control/FullscreenControl.js +5 -7
- package/dist/esm/control/FullscreenControl.js.map +1 -1
- package/dist/esm/control/LayersControl.js +144 -35
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/LegendControl.js +7 -9
- package/dist/esm/control/LegendControl.js.map +1 -1
- package/dist/esm/control/MiniMapControl.js +14 -16
- package/dist/esm/control/MiniMapControl.js.map +1 -1
- package/dist/esm/control/RotateControl.js +1 -3
- package/dist/esm/control/RotateControl.js.map +1 -1
- package/dist/esm/control/ScaleControl.js +7 -9
- package/dist/esm/control/ScaleControl.js.map +1 -1
- package/dist/esm/control/SearchControl.js +100 -18
- package/dist/esm/control/SearchControl.js.map +1 -1
- package/dist/esm/control/SideBySideControl.js +1 -3
- package/dist/esm/control/SideBySideControl.js.map +1 -1
- package/dist/esm/control/TextControl.js +5 -7
- package/dist/esm/control/TextControl.js.map +1 -1
- package/dist/esm/control/TimeControl.js +408 -0
- package/dist/esm/control/TimeControl.js.map +1 -0
- package/dist/esm/control/ZoomControl.js +5 -7
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Class.js +28 -37
- package/dist/esm/core/Class.js.map +1 -1
- package/dist/esm/core/Events.js +21 -8
- package/dist/esm/core/Events.js.map +1 -1
- package/dist/esm/core/Handler.js +13 -11
- package/dist/esm/core/Handler.js.map +1 -1
- package/dist/esm/core/Util.js +13 -1
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.DoubleTap.js +25 -22
- package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
- package/dist/esm/dom/DomEvent.PointerEvents.js +2 -16
- package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
- package/dist/esm/dom/DomEvent.js +8 -42
- package/dist/esm/dom/DomEvent.js.map +1 -1
- package/dist/esm/dom/DomUtil.js +14 -68
- package/dist/esm/dom/DomUtil.js.map +1 -1
- package/dist/esm/dom/Draggable.js +17 -18
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/dom/PosAnimation.js +3 -25
- package/dist/esm/dom/PosAnimation.js.map +1 -1
- package/dist/esm/geo/LatLng.js +34 -6
- package/dist/esm/geo/LatLng.js.map +1 -1
- package/dist/esm/geo/LatLngBounds.js +19 -7
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geo/crs/CRS.js +4 -3
- package/dist/esm/geo/crs/CRS.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3395.js +1 -1
- package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3857.js +1 -1
- package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
- package/dist/esm/geo/crs/EPSG4326.js +1 -1
- package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
- package/dist/esm/geo/crs/EarthCRS.js +2 -2
- package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
- package/dist/esm/geo/crs/SimpleCRS.js +1 -1
- package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
- package/dist/esm/geo/projection/Projection.LonLat.js +3 -3
- package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -1
- package/dist/esm/geo/projection/Projection.Mercator.js +3 -3
- package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -1
- package/dist/esm/geo/projection/Projection.SphericalMercator.js +3 -3
- package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -1
- package/dist/esm/geometry/Bounds.js +19 -7
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/LineUtil.js +36 -30
- package/dist/esm/geometry/LineUtil.js.map +1 -1
- package/dist/esm/geometry/Point.js +23 -5
- package/dist/esm/geometry/Point.js.map +1 -1
- package/dist/esm/geometry/PolyUtil.js +9 -28
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/layer/BlanketOverlay.js +6 -8
- package/dist/esm/layer/BlanketOverlay.js.map +1 -1
- package/dist/esm/layer/DivOverlay.js +15 -20
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/GeoJSON.js +9 -145
- package/dist/esm/layer/GeoJSON.js.map +1 -1
- package/dist/esm/layer/GeoJSONUtil.js +75 -0
- package/dist/esm/layer/GeoJSONUtil.js.map +1 -0
- package/dist/esm/layer/HeatLayer.js +15 -17
- package/dist/esm/layer/HeatLayer.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +20 -26
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +8 -10
- package/dist/esm/layer/Layer.js.map +1 -1
- package/dist/esm/layer/LayerGroup.js +51 -0
- package/dist/esm/layer/LayerGroup.js.map +1 -1
- package/dist/esm/layer/Popup.js +27 -43
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/SVGOverlay.js +2 -5
- package/dist/esm/layer/SVGOverlay.js.map +1 -1
- package/dist/esm/layer/Tooltip.js +15 -17
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/VideoOverlay.js +12 -15
- package/dist/esm/layer/VideoOverlay.js.map +1 -1
- package/dist/esm/layer/marker/DefaultIcon.js +15 -48
- package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +8 -10
- package/dist/esm/layer/marker/DivIcon.js.map +1 -1
- package/dist/esm/layer/marker/Icon.js +9 -12
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Move.js +2 -3
- package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +63 -35
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/marker/MarkerClusterGroup.js +302 -0
- package/dist/esm/layer/marker/MarkerClusterGroup.js.map +1 -0
- package/dist/esm/layer/marker/SvgIcon.js +6 -8
- package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
- package/dist/esm/layer/tile/GridLayer.js +86 -98
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +28 -36
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +28 -23
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +1 -3
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +2 -2
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +17 -7
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.DashAnimation.js +2 -3
- package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -1
- package/dist/esm/layer/vector/Path.js +27 -20
- package/dist/esm/layer/vector/Path.js.map +1 -1
- package/dist/esm/layer/vector/Polygon.js +20 -4
- package/dist/esm/layer/vector/Polygon.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.Decorations.js +2 -2
- package/dist/esm/layer/vector/Polyline.js +24 -8
- package/dist/esm/layer/vector/Polyline.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.getRenderer.js +14 -13
- package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
- package/dist/esm/layer/vector/SVG.js +5 -5
- package/dist/esm/layer/vector/SVG.js.map +1 -1
- package/dist/esm/map/Map.Rotation.js +15 -11
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +135 -129
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/handler/BoxZoomHandler.js +5 -7
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DisplaceHandler.js +6 -8
- package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
- package/dist/esm/map/handler/DragHandler.js +20 -20
- package/dist/esm/map/handler/DragHandler.js.map +1 -1
- package/dist/esm/map/handler/KeyboardHandler.js +37 -37
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +12 -3
- package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +3 -4
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapHoldHandler.js +12 -5
- package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/maplair-global-src.js +6326 -5625
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +3 -3
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +9010 -8290
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +148 -98
- package/dist/maplair.js +3 -3
- package/dist/maplair.js.map +1 -1
- package/i18n/cs.json +6 -0
- package/i18n/de.json +6 -0
- package/i18n/en.json +6 -0
- package/i18n/es.json +6 -0
- package/i18n/fr.json +6 -0
- package/i18n/hu.json +6 -0
- package/i18n/it.json +6 -0
- package/i18n/rm.json +6 -0
- package/i18n/sk.json +6 -0
- package/i18n/sl.json +6 -0
- package/package.json +12 -14
- package/src/control/AttributionControl.js +25 -18
- package/src/control/ButtonControl.js +9 -11
- package/src/control/ContextMenu.js +3 -5
- package/src/control/Control.js +9 -19
- package/src/control/FullscreenControl.js +5 -7
- package/src/control/LayersControl.js +159 -36
- package/src/control/LegendControl.js +7 -9
- package/src/control/MiniMapControl.js +9 -11
- package/src/control/RotateControl.js +3 -5
- package/src/control/ScaleControl.js +7 -9
- package/src/control/SearchControl.js +104 -21
- package/src/control/SideBySideControl.js +3 -5
- package/src/control/TextControl.js +5 -7
- package/src/control/TimeControl.js +471 -0
- package/src/control/ZoomControl.js +5 -7
- package/src/control/index.js +1 -0
- package/src/core/Class.js +35 -34
- package/src/core/Events.js +22 -3
- package/src/core/Handler.js +14 -12
- package/src/core/Util.js +19 -1
- package/src/core/index.js +0 -1
- package/src/dom/DomEvent.DoubleTap.js +18 -10
- package/src/dom/DomEvent.PointerEvents.js +3 -26
- package/src/dom/DomEvent.js +8 -66
- package/src/dom/DomUtil.js +22 -78
- package/src/dom/Draggable.js +27 -22
- package/src/dom/PosAnimation.js +3 -25
- package/src/dom/index.js +0 -1
- package/src/geo/LatLng.js +40 -4
- package/src/geo/LatLngBounds.js +20 -7
- package/src/geo/crs/CRS.js +4 -3
- package/src/geo/crs/EPSG3395.js +1 -1
- package/src/geo/crs/EPSG3857.js +1 -1
- package/src/geo/crs/EPSG4326.js +1 -1
- package/src/geo/crs/EarthCRS.js +2 -8
- package/src/geo/crs/SimpleCRS.js +1 -1
- package/src/geo/projection/Projection.LonLat.js +3 -3
- package/src/geo/projection/Projection.Mercator.js +3 -3
- package/src/geo/projection/Projection.SphericalMercator.js +3 -3
- package/src/geometry/Bounds.js +20 -7
- package/src/geometry/LineUtil.js +47 -48
- package/src/geometry/Point.js +24 -5
- package/src/geometry/PolyUtil.js +15 -44
- package/src/layer/BlanketOverlay.js +6 -10
- package/src/layer/DivOverlay.js +15 -26
- package/src/layer/GeoJSON.js +7 -205
- package/src/layer/GeoJSONUtil.js +85 -0
- package/src/layer/HeatLayer.js +9 -11
- package/src/layer/ImageOverlay.js +19 -30
- package/src/layer/Layer.js +8 -10
- package/src/layer/LayerGroup.js +71 -0
- package/src/layer/Popup.js +31 -46
- package/src/layer/SVGOverlay.js +1 -5
- package/src/layer/Tooltip.js +15 -19
- package/src/layer/VideoOverlay.js +12 -15
- package/src/layer/marker/DefaultIcon.js +15 -61
- package/src/layer/marker/DivIcon.js +10 -12
- package/src/layer/marker/Icon.js +9 -12
- package/src/layer/marker/Marker.Drag.js +1 -1
- package/src/layer/marker/Marker.Move.js +2 -3
- package/src/layer/marker/Marker.js +83 -41
- package/src/layer/marker/MarkerClusterGroup.js +370 -0
- package/src/layer/marker/SvgIcon.js +7 -9
- package/src/layer/marker/index.js +1 -0
- package/src/layer/tile/GridLayer.js +104 -134
- package/src/layer/tile/TileLayer.js +35 -43
- package/src/layer/tile/WMSTileLayer.js +26 -24
- package/src/layer/vector/Canvas.js +3 -5
- package/src/layer/vector/Circle.js +5 -2
- package/src/layer/vector/CircleMarker.js +17 -6
- package/src/layer/vector/Path.DashAnimation.js +1 -2
- package/src/layer/vector/Path.js +30 -21
- package/src/layer/vector/Polygon.js +28 -5
- package/src/layer/vector/Polyline.js +26 -7
- package/src/layer/vector/Renderer.getRenderer.js +17 -17
- package/src/layer/vector/SVG.js +5 -5
- package/src/map/Map.Rotation.js +19 -11
- package/src/map/Map.js +163 -154
- package/src/map/handler/BoxZoomHandler.js +9 -8
- package/src/map/handler/DisplaceHandler.js +6 -8
- package/src/map/handler/DragHandler.js +26 -29
- package/src/map/handler/KeyboardHandler.js +44 -50
- package/src/map/handler/PinchZoomHandler.js +16 -5
- package/src/map/handler/ScrollWheelZoomHandler.js +6 -4
- package/src/map/handler/TapHoldHandler.js +15 -4
- package/src/map/index.js +1 -1
- package/src/maplair.css +148 -98
- package/dist/esm/core/Browser.js +0 -100
- package/dist/esm/core/Browser.js.map +0 -1
- package/dist/images/layers.svg +0 -1
- package/dist/images/marker-icon.svg +0 -1
- package/dist/images/marker-shadow.svg +0 -1
- package/src/core/Browser.js +0 -110
- package/src/images/layers.svg +0 -1
- package/src/images/marker-icon.svg +0 -1
- package/src/images/marker-shadow.svg +0 -1
package/src/core/Handler.js
CHANGED
|
@@ -54,16 +54,18 @@ export class Handler extends Class {
|
|
|
54
54
|
enabled() {
|
|
55
55
|
return !!this._enabled;
|
|
56
56
|
}
|
|
57
|
-
}
|
|
58
57
|
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Adds a new handler of this class to the given map with the given name, which is
|
|
60
|
+
* then available as the property of the map with this name.
|
|
61
|
+
* @template {typeof Handler} T
|
|
62
|
+
* @this {T}
|
|
63
|
+
* @param {MaplairMap} map
|
|
64
|
+
* @param {string} name
|
|
65
|
+
* @returns {T}
|
|
66
|
+
*/
|
|
67
|
+
static addTo(map, name) {
|
|
68
|
+
map.addHandler(name, this);
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/core/Util.js
CHANGED
|
@@ -113,7 +113,8 @@ export function splitWords(str) {
|
|
|
113
113
|
*/
|
|
114
114
|
export function setOptions(obj, options) {
|
|
115
115
|
if (!Object.hasOwn(obj, 'options')) {
|
|
116
|
-
|
|
116
|
+
const defaults = getDefaultOptions(obj.constructor) ?? obj.options;
|
|
117
|
+
obj.options = defaults ? Object.create(defaults) : {};
|
|
117
118
|
}
|
|
118
119
|
for (const i in options) {
|
|
119
120
|
if (Object.hasOwn(options, i)) {
|
|
@@ -123,6 +124,23 @@ export function setOptions(obj, options) {
|
|
|
123
124
|
return obj.options;
|
|
124
125
|
}
|
|
125
126
|
|
|
127
|
+
const chainedDefaults = new WeakMap(); // class -> the defaultOptions object it was chained with
|
|
128
|
+
|
|
129
|
+
// Links the `defaultOptions` of each class in the chain to its parent's, so defaults are inherited and stay live.
|
|
130
|
+
// Done on first use because a static field can't do it in its initializer and stay tree-shakeable.
|
|
131
|
+
function getDefaultOptions(cls) {
|
|
132
|
+
const defaults = cls?.defaultOptions;
|
|
133
|
+
if (defaults && chainedDefaults.get(cls) !== defaults) {
|
|
134
|
+
for (let c = cls; c.defaultOptions; c = Object.getPrototypeOf(c)) {
|
|
135
|
+
if (Object.hasOwn(c, 'defaultOptions')) {
|
|
136
|
+
Object.setPrototypeOf(c.defaultOptions, Object.getPrototypeOf(c).defaultOptions ?? Object.prototype);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
chainedDefaults.set(cls, defaults);
|
|
140
|
+
}
|
|
141
|
+
return defaults;
|
|
142
|
+
}
|
|
143
|
+
|
|
126
144
|
const templateRe = /\{ *([\w_ -]+) *\}/g;
|
|
127
145
|
|
|
128
146
|
/**
|
package/src/core/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as DomEvent from './DomEvent.js';
|
|
2
|
-
|
|
3
1
|
/*
|
|
4
2
|
* Extends the event handling code with double tap support for mobile browsers.
|
|
5
3
|
*
|
|
@@ -8,7 +6,7 @@ import * as DomEvent from './DomEvent.js';
|
|
|
8
6
|
*/
|
|
9
7
|
|
|
10
8
|
function makeDblclick(ev) {
|
|
11
|
-
|
|
9
|
+
const init = {
|
|
12
10
|
// EventInit
|
|
13
11
|
bubbles: ev.bubbles,
|
|
14
12
|
cancelable: ev.cancelable,
|
|
@@ -37,7 +35,7 @@ function makeDblclick(ev) {
|
|
|
37
35
|
// The `click` event received should be a PointerEvent - but some
|
|
38
36
|
// Firefox versions still use MouseEvent.
|
|
39
37
|
if (ev instanceof PointerEvent) {
|
|
40
|
-
|
|
38
|
+
newEvent = new PointerEvent('dblclick', {
|
|
41
39
|
...init,
|
|
42
40
|
pointerId: ev.pointerId,
|
|
43
41
|
width: ev.width,
|
|
@@ -49,8 +47,7 @@ function makeDblclick(ev) {
|
|
|
49
47
|
twist: ev.twist,
|
|
50
48
|
pointerType: ev.pointerType,
|
|
51
49
|
isPrimary: ev.isPrimary,
|
|
52
|
-
};
|
|
53
|
-
newEvent = new PointerEvent('dblclick', init);
|
|
50
|
+
});
|
|
54
51
|
} else {
|
|
55
52
|
newEvent = new MouseEvent('dblclick', init);
|
|
56
53
|
}
|
|
@@ -75,14 +72,22 @@ export function addDoubleTapListener(obj, handler) {
|
|
|
75
72
|
// It seems that in all such cases `detail` property of `click` event is always `1`.
|
|
76
73
|
// So here we rely on that fact to avoid excessive 'dblclick' simulation when not needed.
|
|
77
74
|
let last = 0,
|
|
78
|
-
detail
|
|
75
|
+
detail,
|
|
76
|
+
pointerType;
|
|
77
|
+
|
|
78
|
+
// iOS Safari reports `pointerType: 'mouse'` on clicks from touch (WebKit bug 282988), so we take it from the
|
|
79
|
+
// pointerdown instead; capturing so that it's seen even if a child (e.g. a control) stops its propagation.
|
|
80
|
+
function onPointerDown(ev) {
|
|
81
|
+
pointerType = ev.pointerType;
|
|
82
|
+
}
|
|
83
|
+
|
|
79
84
|
function simDblclick(ev) {
|
|
80
85
|
if (ev.detail !== 1) {
|
|
81
86
|
detail = ev.detail; // keep in sync to avoid false dblclick in some cases
|
|
82
87
|
return;
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
if (
|
|
90
|
+
if (pointerType === 'mouse' ||
|
|
86
91
|
(ev.sourceCapabilities && !ev.sourceCapabilities.firesTouchEvents)) {
|
|
87
92
|
|
|
88
93
|
return;
|
|
@@ -93,8 +98,8 @@ export function addDoubleTapListener(obj, handler) {
|
|
|
93
98
|
// This ignores clicks on elements which are a label with a 'for'
|
|
94
99
|
// attribute (or children of such a label), but not children of
|
|
95
100
|
// a <input>.
|
|
96
|
-
const path =
|
|
97
|
-
if (path.some(el => el instanceof HTMLLabelElement && el.
|
|
101
|
+
const path = ev.composedPath();
|
|
102
|
+
if (path.some(el => el instanceof HTMLLabelElement && el.htmlFor) &&
|
|
98
103
|
!path.some(el => (
|
|
99
104
|
el instanceof HTMLInputElement ||
|
|
100
105
|
el instanceof HTMLSelectElement
|
|
@@ -115,10 +120,12 @@ export function addDoubleTapListener(obj, handler) {
|
|
|
115
120
|
last = now;
|
|
116
121
|
}
|
|
117
122
|
|
|
123
|
+
obj.addEventListener('pointerdown', onPointerDown, true);
|
|
118
124
|
obj.addEventListener('click', simDblclick);
|
|
119
125
|
|
|
120
126
|
return {
|
|
121
127
|
dblclick: handler,
|
|
128
|
+
onPointerDown,
|
|
122
129
|
simDblclick
|
|
123
130
|
};
|
|
124
131
|
}
|
|
@@ -131,5 +138,6 @@ export function addDoubleTapListener(obj, handler) {
|
|
|
131
138
|
*/
|
|
132
139
|
export function removeDoubleTapListener(obj, handlers) {
|
|
133
140
|
obj.removeEventListener('dblclick', handlers.dblclick);
|
|
141
|
+
obj.removeEventListener('pointerdown', handlers.onPointerDown, true);
|
|
134
142
|
obj.removeEventListener('click', handlers.simDblclick);
|
|
135
143
|
}
|
|
@@ -30,12 +30,9 @@ function disablePointerDetection(el) {
|
|
|
30
30
|
el.removeEventListener('pointercancel', _onDelete, {capture: true});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
//
|
|
34
|
-
// synthetic events. The prosthetic-hand library does handle pointer capture,
|
|
35
|
-
// but others don't.
|
|
36
|
-
// If this becomers an issue, replace with `e.isTrusted && e.target.setPointerCapture()`
|
|
33
|
+
// capturing throws for synthetic pointers the browser doesn't know about, so only capture real ones
|
|
37
34
|
function _onSet(e) {
|
|
38
|
-
e.target.setPointerCapture(e.pointerId);
|
|
35
|
+
if (e.isTrusted) { e.target.setPointerCapture(e.pointerId); }
|
|
39
36
|
activePointers.set(e.pointerId, e);
|
|
40
37
|
}
|
|
41
38
|
|
|
@@ -45,7 +42,6 @@ function _onUpdate(e) {
|
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
// NOTE: idem as _onSet.
|
|
49
45
|
function _onDelete(e) {
|
|
50
46
|
// released already if the document has nested maps (e.g. an overview map)
|
|
51
47
|
if (e.target.hasPointerCapture(e.pointerId)) {
|
|
@@ -63,28 +59,9 @@ function getPointers() {
|
|
|
63
59
|
return [...activePointers.values()];
|
|
64
60
|
}
|
|
65
61
|
|
|
66
|
-
/**
|
|
67
|
-
* Clears the detected pointers on the document.
|
|
68
|
-
* Note: This function should be not necessary to call, as the pointers are
|
|
69
|
-
* automatically cleared with `pointerup`, `pointercancel` and `pointerout` events.
|
|
70
|
-
* @group Pointer detection
|
|
71
|
-
* @returns {void}
|
|
72
|
-
*/
|
|
73
|
-
function cleanupPointers() {
|
|
74
|
-
for (const e of activePointers.values()) {
|
|
75
|
-
try {
|
|
76
|
-
e.target.releasePointerCapture(e.pointerId);
|
|
77
|
-
} catch {
|
|
78
|
-
// target may already be detached; capture was on a dead node
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
activePointers.clear();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
62
|
export {
|
|
85
63
|
enablePointerDetection,
|
|
86
64
|
disablePointerDetection,
|
|
87
|
-
getPointers
|
|
88
|
-
cleanupPointers
|
|
65
|
+
getPointers
|
|
89
66
|
};
|
|
90
67
|
|
package/src/dom/DomEvent.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {Point} from '../geometry/Point.js';
|
|
2
2
|
import * as Util from '../core/Util.js';
|
|
3
|
-
import Browser from '../core/Browser.js';
|
|
4
3
|
import {addDoubleTapListener, removeDoubleTapListener} from './DomEvent.DoubleTap.js';
|
|
5
4
|
import {getScale} from './DomUtil.js';
|
|
6
5
|
|
|
@@ -93,12 +92,6 @@ function batchRemove(obj, filterFn) {
|
|
|
93
92
|
}
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
const pointerSubst = {
|
|
97
|
-
pointerenter: 'pointerover',
|
|
98
|
-
pointerleave: 'pointerout',
|
|
99
|
-
wheel: typeof window === 'undefined' ? false : !('onwheel' in window) && 'mousewheel'
|
|
100
|
-
};
|
|
101
|
-
|
|
102
95
|
function addOne(obj, type, fn, context) {
|
|
103
96
|
const id = type + Util.stamp(fn) + (context ? `_${Util.stamp(context)}` : '');
|
|
104
97
|
|
|
@@ -108,29 +101,10 @@ function addOne(obj, type, fn, context) {
|
|
|
108
101
|
return fn.call(context || obj, e);
|
|
109
102
|
};
|
|
110
103
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (Browser.touch && (type === 'dblclick')) {
|
|
104
|
+
if (type === 'dblclick') {
|
|
114
105
|
handler = addDoubleTapListener(obj, handler);
|
|
115
|
-
|
|
116
|
-
} else if ('addEventListener' in obj) {
|
|
117
|
-
|
|
118
|
-
if (type === 'wheel' || type === 'mousewheel') {
|
|
119
|
-
obj.addEventListener(pointerSubst[type] || type, handler, {passive: false});
|
|
120
|
-
} else if (type === 'pointerenter' || type === 'pointerleave') {
|
|
121
|
-
handler = function (e) {
|
|
122
|
-
if (isExternalTarget(obj, e)) {
|
|
123
|
-
originalHandler(e);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
obj.addEventListener(pointerSubst[type], handler, false);
|
|
127
|
-
|
|
128
|
-
} else {
|
|
129
|
-
obj.addEventListener(type, originalHandler, false);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
106
|
} else {
|
|
133
|
-
obj.
|
|
107
|
+
obj.addEventListener(type, handler, type === 'wheel' ? {passive: false} : false);
|
|
134
108
|
}
|
|
135
109
|
|
|
136
110
|
obj[eventsKey] ??= {};
|
|
@@ -143,15 +117,10 @@ function removeOne(obj, type, fn, context, id) {
|
|
|
143
117
|
|
|
144
118
|
if (!handler) { return this; }
|
|
145
119
|
|
|
146
|
-
if (
|
|
120
|
+
if (type === 'dblclick') {
|
|
147
121
|
removeDoubleTapListener(obj, handler);
|
|
148
|
-
|
|
149
|
-
} else if ('removeEventListener' in obj) {
|
|
150
|
-
|
|
151
|
-
obj.removeEventListener(pointerSubst[type] || type, handler, false);
|
|
152
|
-
|
|
153
122
|
} else {
|
|
154
|
-
obj.
|
|
123
|
+
obj.removeEventListener(type, handler, false);
|
|
155
124
|
}
|
|
156
125
|
|
|
157
126
|
obj[eventsKey][id] = null;
|
|
@@ -230,17 +199,6 @@ export function stop(e) {
|
|
|
230
199
|
return this;
|
|
231
200
|
}
|
|
232
201
|
|
|
233
|
-
/**
|
|
234
|
-
* Returns an array containing the `HTMLElement`s that the given DOM event
|
|
235
|
-
* should propagate to (if not stopped).
|
|
236
|
-
* @param {Event} ev
|
|
237
|
-
* @returns {EventTarget[]}
|
|
238
|
-
*/
|
|
239
|
-
export function getPropagationPath(ev) {
|
|
240
|
-
return ev.composedPath();
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
202
|
/**
|
|
245
203
|
* Gets normalized pointer position from a DOM event relative to the
|
|
246
204
|
* `container` (border excluded) or to the whole page if not specified.
|
|
@@ -269,12 +227,8 @@ export function getPointerPosition(e, container) {
|
|
|
269
227
|
* @returns {number}
|
|
270
228
|
*/
|
|
271
229
|
export function getWheelPxFactor() {
|
|
272
|
-
// We need double the scroll pixels (see #7403 and #4538)
|
|
273
|
-
|
|
274
|
-
const ratio = window.devicePixelRatio;
|
|
275
|
-
return Browser.linux && Browser.chrome ? ratio :
|
|
276
|
-
Browser.mac ? ratio * 3 :
|
|
277
|
-
ratio > 0 ? 2 * ratio : 1;
|
|
230
|
+
// We need double the scroll pixels (see #7403 and #4538)
|
|
231
|
+
return window.devicePixelRatio * 2;
|
|
278
232
|
}
|
|
279
233
|
|
|
280
234
|
/**
|
|
@@ -295,24 +249,12 @@ export function getWheelDelta(e) {
|
|
|
295
249
|
|
|
296
250
|
/**
|
|
297
251
|
* Checks if the pointer really left/entered the element `el` (for
|
|
298
|
-
* `
|
|
252
|
+
* `pointerover`/`pointerout`).
|
|
299
253
|
* @internal
|
|
300
254
|
* @param {Node} el
|
|
301
255
|
* @param {MouseEvent} e
|
|
302
256
|
* @returns {boolean}
|
|
303
257
|
*/
|
|
304
258
|
export function isExternalTarget(el, e) {
|
|
305
|
-
|
|
306
|
-
let related = e.relatedTarget;
|
|
307
|
-
|
|
308
|
-
if (!related) { return true; }
|
|
309
|
-
|
|
310
|
-
try {
|
|
311
|
-
while (related && (related !== el)) {
|
|
312
|
-
related = related.parentNode;
|
|
313
|
-
}
|
|
314
|
-
} catch (err) {
|
|
315
|
-
return false;
|
|
316
|
-
}
|
|
317
|
-
return (related !== el);
|
|
259
|
+
return !el.contains(e.relatedTarget);
|
|
318
260
|
}
|
package/src/dom/DomUtil.js
CHANGED
|
@@ -43,7 +43,13 @@ export function create(tagName, className, container) {
|
|
|
43
43
|
*/
|
|
44
44
|
export function toFront(el) {
|
|
45
45
|
const parent = el.parentNode;
|
|
46
|
-
if (parent
|
|
46
|
+
if (!parent || parent.lastChild === el) { return; }
|
|
47
|
+
|
|
48
|
+
// re-inserting a hovered node (e.g. bringToFront in a pointerover handler) makes Chromium 144+ fire a repeated
|
|
49
|
+
// pointerover and lose the next pointerout (#10129), so move the nodes after it instead
|
|
50
|
+
if (el.matches(':hover')) {
|
|
51
|
+
while (el.nextSibling) { parent.insertBefore(el.nextSibling, el); }
|
|
52
|
+
} else {
|
|
47
53
|
parent.appendChild(el);
|
|
48
54
|
}
|
|
49
55
|
}
|
|
@@ -55,7 +61,11 @@ export function toFront(el) {
|
|
|
55
61
|
*/
|
|
56
62
|
export function toBack(el) {
|
|
57
63
|
const parent = el.parentNode;
|
|
58
|
-
if (parent
|
|
64
|
+
if (!parent || parent.firstChild === el) { return; }
|
|
65
|
+
|
|
66
|
+
if (el.matches(':hover')) { // see toFront
|
|
67
|
+
while (el.previousSibling) { parent.insertBefore(el.previousSibling, el.nextSibling); }
|
|
68
|
+
} else {
|
|
59
69
|
parent.insertBefore(el, parent.firstChild);
|
|
60
70
|
}
|
|
61
71
|
}
|
|
@@ -82,16 +92,21 @@ export function setTransform(el, offset, scale) {
|
|
|
82
92
|
const positions = new WeakMap();
|
|
83
93
|
|
|
84
94
|
/**
|
|
85
|
-
* Sets the position of `el` to coordinates specified by `point
|
|
86
|
-
*
|
|
87
|
-
*
|
|
95
|
+
* Sets the position of `el` to coordinates specified by `point` using a CSS translate
|
|
96
|
+
* (used by Maplair internally to position its layers). With `flat`, the translate is 2D,
|
|
97
|
+
* so `el` is painted into its parent's compositor layer instead of getting a layer of its own.
|
|
88
98
|
* @param {HTMLElement|SVGElement} el
|
|
89
99
|
* @param {Point} point
|
|
100
|
+
* @param {boolean} [flat]
|
|
90
101
|
* @returns {void}
|
|
91
102
|
*/
|
|
92
|
-
export function setPosition(el, point) {
|
|
103
|
+
export function setPosition(el, point, flat) {
|
|
93
104
|
positions.set(el, point);
|
|
94
|
-
|
|
105
|
+
if (flat) {
|
|
106
|
+
el.style.transform = `translate(${point.x}px, ${point.y}px)`;
|
|
107
|
+
} else {
|
|
108
|
+
setTransform(el, point);
|
|
109
|
+
}
|
|
95
110
|
}
|
|
96
111
|
|
|
97
112
|
/**
|
|
@@ -105,42 +120,6 @@ export function getPosition(el) {
|
|
|
105
120
|
return positions.get(el) ?? new Point(0, 0);
|
|
106
121
|
}
|
|
107
122
|
|
|
108
|
-
const documentStyle = typeof document === 'undefined' ? {} : document.documentElement.style;
|
|
109
|
-
// Safari still needs a vendor prefix, we need to detect with property name is supported.
|
|
110
|
-
const userSelectProp = ['userSelect', 'WebkitUserSelect'].find(prop => prop in documentStyle);
|
|
111
|
-
let prevUserSelect;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Prevents the user from selecting text in the document. Used internally
|
|
115
|
-
* by Maplair to override the behaviour of any click-and-drag interaction on
|
|
116
|
-
* the map. Affects drag interactions on the whole document.
|
|
117
|
-
* @returns {void}
|
|
118
|
-
*/
|
|
119
|
-
export function disableTextSelection() {
|
|
120
|
-
const value = documentStyle[userSelectProp];
|
|
121
|
-
|
|
122
|
-
if (value === 'none') {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
prevUserSelect = value;
|
|
127
|
-
documentStyle[userSelectProp] = 'none';
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Cancels the effects of a previous
|
|
132
|
-
* [`DomUtil.disableTextSelection`](#domutil-disabletextselection).
|
|
133
|
-
* @returns {void}
|
|
134
|
-
*/
|
|
135
|
-
export function enableTextSelection() {
|
|
136
|
-
if (typeof prevUserSelect === 'undefined') {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
documentStyle[userSelectProp] = prevUserSelect;
|
|
141
|
-
prevUserSelect = undefined;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
123
|
/**
|
|
145
124
|
* Prevents the user from generating `dragstart` DOM events, usually generated when
|
|
146
125
|
* the user drags an image.
|
|
@@ -159,41 +138,6 @@ export function enableImageDrag() {
|
|
|
159
138
|
DomEvent.off(window, 'dragstart', DomEvent.preventDefault);
|
|
160
139
|
}
|
|
161
140
|
|
|
162
|
-
let _outlineElement, _outlineStyle;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Makes the [outline](https://developer.mozilla.org/docs/Web/CSS/outline)
|
|
166
|
-
* of the element `element` invisible. Used internally by Maplair to prevent
|
|
167
|
-
* focusable elements from displaying an outline when the user performs a
|
|
168
|
-
* drag interaction on them.
|
|
169
|
-
* @param {HTMLElement} element
|
|
170
|
-
* @returns {void}
|
|
171
|
-
*/
|
|
172
|
-
export function preventOutline(element) {
|
|
173
|
-
while (element.tabIndex === -1) {
|
|
174
|
-
element = element.parentNode;
|
|
175
|
-
}
|
|
176
|
-
if (!element.style) { return; }
|
|
177
|
-
restoreOutline();
|
|
178
|
-
_outlineElement = element;
|
|
179
|
-
_outlineStyle = element.style.outlineStyle;
|
|
180
|
-
element.style.outlineStyle = 'none';
|
|
181
|
-
DomEvent.on(window, 'keydown', restoreOutline);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Cancels the effects of a previous
|
|
186
|
-
* [`DomUtil.preventOutline`](#domutil-preventoutline).
|
|
187
|
-
* @returns {void}
|
|
188
|
-
*/
|
|
189
|
-
export function restoreOutline() {
|
|
190
|
-
if (!_outlineElement) { return; }
|
|
191
|
-
_outlineElement.style.outlineStyle = _outlineStyle;
|
|
192
|
-
_outlineElement = undefined;
|
|
193
|
-
_outlineStyle = undefined;
|
|
194
|
-
DomEvent.off(window, 'keydown', restoreOutline);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
141
|
/**
|
|
198
142
|
* Finds the closest parent node which size (width and height) is not null.
|
|
199
143
|
* @param {HTMLElement} element
|
package/src/dom/Draggable.js
CHANGED
|
@@ -41,27 +41,26 @@ import * as PointerEvents from './DomEvent.PointerEvents.js';
|
|
|
41
41
|
*/
|
|
42
42
|
export class Draggable extends Evented {
|
|
43
43
|
|
|
44
|
-
static {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
}
|
|
44
|
+
static defaultOptions = {
|
|
45
|
+
clickTolerance: 3
|
|
46
|
+
};
|
|
49
47
|
|
|
50
48
|
/**
|
|
51
49
|
* Creates a `Draggable` object for moving `element` when you start dragging the
|
|
52
50
|
* `dragStartTarget` element (equals `element` itself by default).
|
|
53
51
|
* @param {HTMLElement} element
|
|
54
52
|
* @param {HTMLElement} [dragStartTarget]
|
|
55
|
-
* @param {boolean} [preventOutline]
|
|
56
53
|
* @param {DraggableOptions} [options]
|
|
57
54
|
*/
|
|
58
|
-
constructor(element, dragStartTarget,
|
|
55
|
+
constructor(element, dragStartTarget, options) {
|
|
56
|
+
if (typeof options === 'boolean') {
|
|
57
|
+
throw new Error('Draggable: the preventOutline argument is removed in Maplair. Pass options as the third argument.');
|
|
58
|
+
}
|
|
59
59
|
super();
|
|
60
60
|
Util.setOptions(this, options);
|
|
61
61
|
|
|
62
62
|
this._element = element;
|
|
63
63
|
this._dragStartTarget = dragStartTarget ?? element;
|
|
64
|
-
this._preventOutline = preventOutline;
|
|
65
64
|
|
|
66
65
|
this.callInitHooks(Draggable);
|
|
67
66
|
}
|
|
@@ -113,12 +112,7 @@ export class Draggable extends Evented {
|
|
|
113
112
|
if (Draggable._dragging || e.shiftKey || (e.button !== 0 && e.pointerType !== 'touch')) { return; }
|
|
114
113
|
Draggable._dragging = this; // Prevent dragging multiple objects at once.
|
|
115
114
|
|
|
116
|
-
if (this._preventOutline) {
|
|
117
|
-
DomUtil.preventOutline(this._element);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
115
|
DomUtil.disableImageDrag();
|
|
121
|
-
DomUtil.disableTextSelection();
|
|
122
116
|
|
|
123
117
|
if (this._moving) { return; }
|
|
124
118
|
|
|
@@ -133,7 +127,7 @@ export class Draggable extends Evented {
|
|
|
133
127
|
this._parentScale = DomUtil.getScale(sizedParent);
|
|
134
128
|
|
|
135
129
|
DomEvent.on(this._dragStartTarget, 'pointermove', this._onMove, this);
|
|
136
|
-
DomEvent.on(this._dragStartTarget, 'pointerup pointercancel', this._onUp, this);
|
|
130
|
+
DomEvent.on(this._dragStartTarget, 'pointerup pointercancel lostpointercapture', this._onUp, this);
|
|
137
131
|
}
|
|
138
132
|
|
|
139
133
|
_onMove(e) {
|
|
@@ -144,8 +138,9 @@ export class Draggable extends Evented {
|
|
|
144
138
|
|
|
145
139
|
const offset = new Point(e.clientX, e.clientY)._subtract(this._startPoint);
|
|
146
140
|
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
// once the drag has started, the pointer must be followed even when it comes back near the start point
|
|
142
|
+
const dist = Math.abs(offset.x) + Math.abs(offset.y);
|
|
143
|
+
if (!this._moved && (!dist || dist < this.options.clickTolerance)) { return; }
|
|
149
144
|
|
|
150
145
|
// We assume that the parent container's position, border and scale do not change for the duration of the drag.
|
|
151
146
|
// Therefore there is no need to account for the position and border (they are eliminated by the subtraction)
|
|
@@ -162,9 +157,11 @@ export class Draggable extends Evented {
|
|
|
162
157
|
|
|
163
158
|
this._moved = true;
|
|
164
159
|
|
|
165
|
-
|
|
160
|
+
// on the map container rather than the body, so that toggling it doesn't restyle the whole page
|
|
161
|
+
this._draggingContainer = this._element.closest('.maplair-container') ?? this._element;
|
|
162
|
+
this._draggingContainer.classList.add('maplair-dragging');
|
|
166
163
|
|
|
167
|
-
this._lastTarget = e.target
|
|
164
|
+
this._lastTarget = e.target;
|
|
168
165
|
this._lastTarget.classList.add('maplair-drag-target');
|
|
169
166
|
}
|
|
170
167
|
|
|
@@ -179,12 +176,20 @@ export class Draggable extends Evented {
|
|
|
179
176
|
const e = {originalEvent: this._lastEvent};
|
|
180
177
|
|
|
181
178
|
this.fire('predrag', e);
|
|
179
|
+
|
|
180
|
+
// pointer events can have fractional coordinates; snap them to device pixels, since an edge in the middle of
|
|
181
|
+
// one is drawn partly transparent on both sides and shows a seam between tiles
|
|
182
|
+
const dpr = window.devicePixelRatio;
|
|
183
|
+
this._newPos = this._newPos.multiplyBy(dpr)._round()._divideBy(dpr);
|
|
182
184
|
DomUtil.setPosition(this._element, this._newPos);
|
|
183
185
|
|
|
184
186
|
this.fire('drag', e);
|
|
185
187
|
}
|
|
186
188
|
|
|
187
|
-
_onUp() {
|
|
189
|
+
_onUp(e) {
|
|
190
|
+
// releasing the button outside the window may fire no pointerup, only a lostpointercapture with no buttons;
|
|
191
|
+
// capture lost while the button is still held (e.g. the pressed element was removed) shouldn't end the drag
|
|
192
|
+
if (e.type === 'lostpointercapture' && e.buttons) { return; }
|
|
188
193
|
this.finishDrag();
|
|
189
194
|
}
|
|
190
195
|
|
|
@@ -195,7 +200,8 @@ export class Draggable extends Evented {
|
|
|
195
200
|
* @returns {void}
|
|
196
201
|
*/
|
|
197
202
|
finishDrag(noInertia) {
|
|
198
|
-
this.
|
|
203
|
+
this._draggingContainer?.classList.remove('maplair-dragging');
|
|
204
|
+
this._draggingContainer = null;
|
|
199
205
|
|
|
200
206
|
if (this._lastTarget) {
|
|
201
207
|
this._lastTarget.classList.remove('maplair-drag-target');
|
|
@@ -203,10 +209,9 @@ export class Draggable extends Evented {
|
|
|
203
209
|
}
|
|
204
210
|
|
|
205
211
|
DomEvent.off(this._dragStartTarget, 'pointermove', this._onMove, this);
|
|
206
|
-
DomEvent.off(this._dragStartTarget, 'pointerup pointercancel', this._onUp, this);
|
|
212
|
+
DomEvent.off(this._dragStartTarget, 'pointerup pointercancel lostpointercapture', this._onUp, this);
|
|
207
213
|
|
|
208
214
|
DomUtil.enableImageDrag();
|
|
209
|
-
DomUtil.enableTextSelection();
|
|
210
215
|
|
|
211
216
|
const fireDragend = this._moved && this._moving;
|
|
212
217
|
|
package/src/dom/PosAnimation.js
CHANGED
|
@@ -4,31 +4,9 @@ import * as DomUtil from '../dom/DomUtil.js';
|
|
|
4
4
|
/** @import {MaplairEvent} from '../core/Events.js' */
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```js
|
|
12
|
-
* const myPositionMarker = new Marker([48.864716, 2.294694]).addTo(map);
|
|
13
|
-
*
|
|
14
|
-
* myPositionMarker.on("click", function() {
|
|
15
|
-
* const pos = map.latLngToLayerPoint(myPositionMarker.getLatLng());
|
|
16
|
-
* pos.y -= 25;
|
|
17
|
-
* const fx = new PosAnimation();
|
|
18
|
-
*
|
|
19
|
-
* fx.once('end',function() {
|
|
20
|
-
* pos.y += 25;
|
|
21
|
-
* fx.run(myPositionMarker._icon, pos, 0.8);
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* fx.run(myPositionMarker._icon, pos, 0.3);
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @fires start {MaplairEvent} Fired when the animation starts.
|
|
30
|
-
* @fires step {MaplairEvent} Fired continuously during the animation.
|
|
31
|
-
* @fires end {MaplairEvent} Fired when the animation ends.
|
|
7
|
+
* Runs the map's pan animations: moves an element to a new position on an ease-out
|
|
8
|
+
* curve, firing `start`, `step` and `end`.
|
|
9
|
+
* @internal
|
|
32
10
|
*/
|
|
33
11
|
export class PosAnimation extends Evented {
|
|
34
12
|
/**
|
package/src/dom/index.js
CHANGED