@classic-homes/maps-react 0.2.16 → 0.3.1
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/dist/index.cjs +18 -13
- package/dist/index.js +18 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -375,6 +375,11 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
375
375
|
const [mapLoaded, setMapLoaded] = React26__namespace.useState(false);
|
|
376
376
|
const [mapError, setMapError] = React26__namespace.useState(null);
|
|
377
377
|
const [styleVersion, setStyleVersion] = React26__namespace.useState(0);
|
|
378
|
+
const styleVersionRef = React26__namespace.useRef(0);
|
|
379
|
+
const bumpStyleVersion = React26__namespace.useCallback(() => {
|
|
380
|
+
styleVersionRef.current += 1;
|
|
381
|
+
setStyleVersion(styleVersionRef.current);
|
|
382
|
+
}, []);
|
|
378
383
|
const activeStyleOverrideRef = React26__namespace.useRef(
|
|
379
384
|
null
|
|
380
385
|
);
|
|
@@ -383,16 +388,19 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
383
388
|
positioningCoordinatorRef.current = mapsCore.createPositioningCoordinator();
|
|
384
389
|
}
|
|
385
390
|
const positioningCoordinator = positioningCoordinatorRef.current;
|
|
386
|
-
const setMapStyle = React26__namespace.useCallback(
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
391
|
+
const setMapStyle = React26__namespace.useCallback(
|
|
392
|
+
(style) => {
|
|
393
|
+
activeStyleOverrideRef.current = style;
|
|
394
|
+
const map = mapRef.current;
|
|
395
|
+
if (!map) return;
|
|
396
|
+
const versionBefore = styleVersionRef.current;
|
|
390
397
|
map.setStyle(style);
|
|
391
398
|
map.once("idle", () => {
|
|
392
|
-
|
|
399
|
+
if (styleVersionRef.current === versionBefore) bumpStyleVersion();
|
|
393
400
|
});
|
|
394
|
-
}
|
|
395
|
-
|
|
401
|
+
},
|
|
402
|
+
[bumpStyleVersion]
|
|
403
|
+
);
|
|
396
404
|
const prefersReducedMotion = useReducedMotion();
|
|
397
405
|
const { style: themeStyle } = useMapTheme(themePref);
|
|
398
406
|
const onLoadRef = React26__namespace.useRef(onLoad);
|
|
@@ -564,14 +572,11 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
564
572
|
React26__namespace.useEffect(() => {
|
|
565
573
|
const map = mapRef.current;
|
|
566
574
|
if (!map || !mapLoaded) return;
|
|
567
|
-
|
|
568
|
-
setStyleVersion((v) => v + 1);
|
|
569
|
-
};
|
|
570
|
-
map.on("style.load", handleStyleLoad);
|
|
575
|
+
map.on("style.load", bumpStyleVersion);
|
|
571
576
|
return () => {
|
|
572
|
-
map.off("style.load",
|
|
577
|
+
map.off("style.load", bumpStyleVersion);
|
|
573
578
|
};
|
|
574
|
-
}, [mapLoaded]);
|
|
579
|
+
}, [mapLoaded, bumpStyleVersion]);
|
|
575
580
|
const styleInitialized = React26__namespace.useRef(false);
|
|
576
581
|
React26__namespace.useEffect(() => {
|
|
577
582
|
if (!mapRef.current || !mapLoaded) return;
|
package/dist/index.js
CHANGED
|
@@ -351,6 +351,11 @@ var Map2 = React26.forwardRef(
|
|
|
351
351
|
const [mapLoaded, setMapLoaded] = React26.useState(false);
|
|
352
352
|
const [mapError, setMapError] = React26.useState(null);
|
|
353
353
|
const [styleVersion, setStyleVersion] = React26.useState(0);
|
|
354
|
+
const styleVersionRef = React26.useRef(0);
|
|
355
|
+
const bumpStyleVersion = React26.useCallback(() => {
|
|
356
|
+
styleVersionRef.current += 1;
|
|
357
|
+
setStyleVersion(styleVersionRef.current);
|
|
358
|
+
}, []);
|
|
354
359
|
const activeStyleOverrideRef = React26.useRef(
|
|
355
360
|
null
|
|
356
361
|
);
|
|
@@ -359,16 +364,19 @@ var Map2 = React26.forwardRef(
|
|
|
359
364
|
positioningCoordinatorRef.current = createPositioningCoordinator();
|
|
360
365
|
}
|
|
361
366
|
const positioningCoordinator = positioningCoordinatorRef.current;
|
|
362
|
-
const setMapStyle = React26.useCallback(
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
367
|
+
const setMapStyle = React26.useCallback(
|
|
368
|
+
(style) => {
|
|
369
|
+
activeStyleOverrideRef.current = style;
|
|
370
|
+
const map = mapRef.current;
|
|
371
|
+
if (!map) return;
|
|
372
|
+
const versionBefore = styleVersionRef.current;
|
|
366
373
|
map.setStyle(style);
|
|
367
374
|
map.once("idle", () => {
|
|
368
|
-
|
|
375
|
+
if (styleVersionRef.current === versionBefore) bumpStyleVersion();
|
|
369
376
|
});
|
|
370
|
-
}
|
|
371
|
-
|
|
377
|
+
},
|
|
378
|
+
[bumpStyleVersion]
|
|
379
|
+
);
|
|
372
380
|
const prefersReducedMotion = useReducedMotion();
|
|
373
381
|
const { style: themeStyle } = useMapTheme(themePref);
|
|
374
382
|
const onLoadRef = React26.useRef(onLoad);
|
|
@@ -540,14 +548,11 @@ var Map2 = React26.forwardRef(
|
|
|
540
548
|
React26.useEffect(() => {
|
|
541
549
|
const map = mapRef.current;
|
|
542
550
|
if (!map || !mapLoaded) return;
|
|
543
|
-
|
|
544
|
-
setStyleVersion((v) => v + 1);
|
|
545
|
-
};
|
|
546
|
-
map.on("style.load", handleStyleLoad);
|
|
551
|
+
map.on("style.load", bumpStyleVersion);
|
|
547
552
|
return () => {
|
|
548
|
-
map.off("style.load",
|
|
553
|
+
map.off("style.load", bumpStyleVersion);
|
|
549
554
|
};
|
|
550
|
-
}, [mapLoaded]);
|
|
555
|
+
}, [mapLoaded, bumpStyleVersion]);
|
|
551
556
|
const styleInitialized = React26.useRef(false);
|
|
552
557
|
React26.useEffect(() => {
|
|
553
558
|
if (!mapRef.current || !mapLoaded) return;
|