@record-evolution/widget-mapbox 1.4.20 → 1.4.21

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "REWidget widget-mapbox",
4
4
  "license": "MIT",
5
5
  "author": "widget-mapbox",
6
- "version": "1.4.20",
6
+ "version": "1.4.21",
7
7
  "type": "module",
8
8
  "main": "dist/widget-mapbox.js",
9
9
  "types": "dist/src/widget-mapbox.d.ts",
@@ -30,17 +30,24 @@ export class WidgetMapbox extends LitElement {
30
30
  private mapLoaded: boolean = false
31
31
  private resizeObserver: ResizeObserver
32
32
  private mapStyle?: string
33
+ private customDebounce?: any
33
34
  private imageList: string[] = []
34
35
  constructor() {
35
36
  super()
36
37
  this.resizeObserver = new ResizeObserver(() => {
37
- this.map?.resize()
38
- this.fitBounds()
38
+ this.updateMap()
39
39
  })
40
40
  mapboxgl.accessToken =
41
41
  'pk.eyJ1IjoibWFya29wZSIsImEiOiJjazc1OWlsNjkwN2pyM2VxajV1eGRnYzgwIn0.3lVksk1nej_0KnWjCkBDAA'
42
42
  }
43
43
 
44
+ disconnectedCallback() {
45
+ super.disconnectedCallback()
46
+ if(this.resizeObserver) {
47
+ this.resizeObserver.disconnect()
48
+ }
49
+ }
50
+
44
51
  update(changedProperties: Map<string, any>) {
45
52
  if (changedProperties.has('inputData')) {
46
53
  this.transformInputData()
@@ -55,6 +62,15 @@ export class WidgetMapbox extends LitElement {
55
62
  this.fitBounds()
56
63
  }
57
64
 
65
+ updateMap() {
66
+ if (this.customDebounce) clearTimeout(this.customDebounce)
67
+
68
+ this.customDebounce = setTimeout(() => {
69
+ this.map?.resize()
70
+ this.fitBounds()
71
+ }, 300)
72
+ }
73
+
58
74
  fitBounds() {
59
75
  const bounds = new mapboxgl.LngLatBounds()
60
76
  this.dataSources.forEach((col: GeoJSON.FeatureCollection) => {