@geolonia/embed 1.19.0 → 1.19.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/embed.js +3 -3
- package/package.json +1 -1
- package/src/embed.js +12 -4
package/package.json
CHANGED
package/src/embed.js
CHANGED
|
@@ -18,6 +18,7 @@ if ( util.checkPermission() ) {
|
|
|
18
18
|
let isDOMContentLoaded = false
|
|
19
19
|
const alreadyRenderedMaps = []
|
|
20
20
|
const plugins = []
|
|
21
|
+
const isRemoved = Symbol('map-is-removed')
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
*
|
|
@@ -26,9 +27,14 @@ if ( util.checkPermission() ) {
|
|
|
26
27
|
const renderGeoloniaMap = target => {
|
|
27
28
|
const map = new GeoloniaMap(target)
|
|
28
29
|
|
|
30
|
+
// detect if the map removed manually
|
|
31
|
+
map.on('remove', () => {
|
|
32
|
+
map[isRemoved] = true
|
|
33
|
+
})
|
|
34
|
+
|
|
29
35
|
// plugin
|
|
30
36
|
const atts = parseAtts(target)
|
|
31
|
-
if (isDOMContentLoaded) {
|
|
37
|
+
if (isDOMContentLoaded && !map[isRemoved]) {
|
|
32
38
|
plugins.forEach(plugin => plugin(map, target, atts))
|
|
33
39
|
} else {
|
|
34
40
|
alreadyRenderedMaps.push({ map, target: target, atts })
|
|
@@ -37,9 +43,11 @@ if ( util.checkPermission() ) {
|
|
|
37
43
|
|
|
38
44
|
document.addEventListener('DOMContentLoaded', () => {
|
|
39
45
|
isDOMContentLoaded = true
|
|
40
|
-
alreadyRenderedMaps.forEach(({ map, target, atts }) =>
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
alreadyRenderedMaps.forEach(({ map, target, atts }) => {
|
|
47
|
+
if (!map[isRemoved]) {
|
|
48
|
+
plugins.forEach(plugin => plugin(map, target, atts))
|
|
49
|
+
}
|
|
50
|
+
})
|
|
43
51
|
// clear
|
|
44
52
|
alreadyRenderedMaps.splice(0, alreadyRenderedMaps.length)
|
|
45
53
|
})
|