@guardian/interactive-component-library 0.1.0-alpha.46 → 0.1.0-alpha.48
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.
|
@@ -4602,7 +4602,9 @@ class Dispatcher {
|
|
|
4602
4602
|
}
|
|
4603
4603
|
const MapEvent = {
|
|
4604
4604
|
CHANGE: "change",
|
|
4605
|
-
ZOOM: "zoom"
|
|
4605
|
+
ZOOM: "zoom",
|
|
4606
|
+
TRANSITION_START: "transition_start",
|
|
4607
|
+
TRANSITION_END: "transition_end"
|
|
4606
4608
|
};
|
|
4607
4609
|
var noop = { value: () => {
|
|
4608
4610
|
} };
|
|
@@ -5922,10 +5924,8 @@ let Map$2 = class Map2 {
|
|
|
5922
5924
|
this._resizeObserver = new ResizeObserver(() => this._updateSize());
|
|
5923
5925
|
this._resizeObserver.observe(this.target);
|
|
5924
5926
|
this._viewport.addEventListener("touchmove", (event) => {
|
|
5925
|
-
if (event.targetTouches.length < 2) {
|
|
5927
|
+
if (event.targetTouches.length < 2 && this.collaborativeGesturesEnabled) {
|
|
5926
5928
|
this._filterEventCallback(true);
|
|
5927
|
-
} else {
|
|
5928
|
-
event.stopImmediatePropagation();
|
|
5929
5929
|
}
|
|
5930
5930
|
});
|
|
5931
5931
|
}
|
|
@@ -5940,9 +5940,12 @@ let Map$2 = class Map2 {
|
|
|
5940
5940
|
get viewPort() {
|
|
5941
5941
|
return this._viewport;
|
|
5942
5942
|
}
|
|
5943
|
-
get
|
|
5943
|
+
get zoomScale() {
|
|
5944
5944
|
return this.view.transform.k;
|
|
5945
5945
|
}
|
|
5946
|
+
get isTransitioning() {
|
|
5947
|
+
return this._isTransitioning;
|
|
5948
|
+
}
|
|
5946
5949
|
/** PUBLIC METHODS */
|
|
5947
5950
|
onFilterEvent(callback) {
|
|
5948
5951
|
this._filterEventCallback = callback;
|
|
@@ -5983,15 +5986,15 @@ let Map$2 = class Map2 {
|
|
|
5983
5986
|
this.layers.splice(layerIndex, 1);
|
|
5984
5987
|
}
|
|
5985
5988
|
async zoomIn(options) {
|
|
5986
|
-
return this.zoomTo(this.
|
|
5989
|
+
return this.zoomTo(this.zoomScale * 2, options);
|
|
5987
5990
|
}
|
|
5988
5991
|
async zoomOut(options) {
|
|
5989
|
-
return this.zoomTo(this.
|
|
5992
|
+
return this.zoomTo(this.zoomScale * 0.5, options);
|
|
5990
5993
|
}
|
|
5991
|
-
async zoomTo(
|
|
5994
|
+
async zoomTo(zoomScale, options = {
|
|
5992
5995
|
duration: 500
|
|
5993
5996
|
}) {
|
|
5994
|
-
return select(this._viewport).transition().duration(options.duration).call(this._zoomBehaviour.scaleTo,
|
|
5997
|
+
return select(this._viewport).transition().duration(options.duration).call(this._zoomBehaviour.scaleTo, zoomScale).end();
|
|
5995
5998
|
}
|
|
5996
5999
|
zoomToFeature(feature, focalPoint, padding = {
|
|
5997
6000
|
top: 40,
|
|
@@ -6047,6 +6050,7 @@ let Map$2 = class Map2 {
|
|
|
6047
6050
|
const ease = options.ease || ((t) => t);
|
|
6048
6051
|
return new Promise((resolve) => {
|
|
6049
6052
|
this._isTransitioning = true;
|
|
6053
|
+
this.dispatcher.dispatch(MapEvent.TRANSITION_START);
|
|
6050
6054
|
const _timer = timer((elapsed) => {
|
|
6051
6055
|
const t = Math.min(elapsed / options.duration, 1);
|
|
6052
6056
|
callback(ease(t));
|
|
@@ -6054,6 +6058,7 @@ let Map$2 = class Map2 {
|
|
|
6054
6058
|
if (elapsed >= options.duration) {
|
|
6055
6059
|
_timer.stop();
|
|
6056
6060
|
this._isTransitioning = false;
|
|
6061
|
+
this.dispatcher.dispatch(MapEvent.TRANSITION_END);
|
|
6057
6062
|
resolve();
|
|
6058
6063
|
}
|
|
6059
6064
|
});
|
|
@@ -6101,7 +6106,7 @@ let Map$2 = class Map2 {
|
|
|
6101
6106
|
if (event.type === "wheel" && !event[this._zoomBypassKey]) {
|
|
6102
6107
|
return filterEvent(true);
|
|
6103
6108
|
}
|
|
6104
|
-
if ("targetTouches" in event) {
|
|
6109
|
+
if ("targetTouches" in event && this.collaborativeGesturesEnabled) {
|
|
6105
6110
|
if (event.targetTouches.length < 2) {
|
|
6106
6111
|
return false;
|
|
6107
6112
|
}
|
|
@@ -6339,6 +6344,7 @@ const Map$1 = forwardRef(({
|
|
|
6339
6344
|
const [zoomHelpText, setZoomHelpText] = useState("");
|
|
6340
6345
|
const [showHelpText, setShowHelpText] = useState(false);
|
|
6341
6346
|
useEffect(() => {
|
|
6347
|
+
var _a;
|
|
6342
6348
|
const map2 = new Map$2({
|
|
6343
6349
|
view: new View(config.view),
|
|
6344
6350
|
target: targetRef.current
|
|
@@ -6349,7 +6355,12 @@ const Map$1 = forwardRef(({
|
|
|
6349
6355
|
if (ref)
|
|
6350
6356
|
ref.current = map2;
|
|
6351
6357
|
onLoad && onLoad(map2);
|
|
6352
|
-
|
|
6358
|
+
let zoomHelpText2 = "";
|
|
6359
|
+
if (((_a = navigator.userAgentData) == null ? void 0 : _a.mobile) || navigator.userAgent.indexOf("Mobile") !== -1) {
|
|
6360
|
+
zoomHelpText2 = mobileHelpText;
|
|
6361
|
+
} else {
|
|
6362
|
+
zoomHelpText2 = navigator.userAgent.indexOf("Mac") !== -1 ? "Use ⌘ + scroll to zoom" : "Use Ctrl + scroll to zoom";
|
|
6363
|
+
}
|
|
6353
6364
|
setZoomHelpText(zoomHelpText2);
|
|
6354
6365
|
return () => {
|
|
6355
6366
|
map2.destroy();
|