svgmap 1.3.4 → 1.5.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/LICENSE +1 -1
- package/README.md +20 -4
- package/assets/create-map-paths.html +991 -8
- package/assets/map-optimized.svg +984 -1058
- package/dist/svgMap.js +262 -218
- package/dist/svgMap.min.js +1 -1
- package/package.json +4 -4
- package/src/js/svgMap/map.js +25 -5
- package/src/js/svgMap/mapPaths.js +221 -210
- package/src/js/svgMap/tooltip.js +8 -3
- package/src/js/svgMap.js +8 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svgmap",
|
|
3
3
|
"description": "svgMap is a JavaScript library that lets you easily create an interactable world map comparing customizable data for each country.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/svgMap.min.js",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"gulp": "^4.0.2",
|
|
19
|
-
"gulp-clean-css": "^4.
|
|
19
|
+
"gulp-clean-css": "^4.3.0",
|
|
20
20
|
"gulp-concat": "^2.6.1",
|
|
21
21
|
"gulp-header": "^2.0.9",
|
|
22
22
|
"gulp-rename": "^2.0.0",
|
|
23
|
-
"gulp-sass": "^4.0
|
|
23
|
+
"gulp-sass": "^4.1.0",
|
|
24
24
|
"gulp-sourcemaps": "^2.6.5",
|
|
25
25
|
"gulp-uglify": "^3.0.2",
|
|
26
|
-
"jest": "^
|
|
26
|
+
"jest": "^26.0.1",
|
|
27
27
|
"svg-pan-zoom": "^3.6.1"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {},
|
package/src/js/svgMap/map.js
CHANGED
|
@@ -22,8 +22,17 @@ svgMap.prototype.createMap = function () {
|
|
|
22
22
|
}.bind(this));
|
|
23
23
|
}.bind(this));
|
|
24
24
|
|
|
25
|
+
// Fix countries
|
|
26
|
+
var mapPaths = Object.assign({}, this.mapPaths);
|
|
27
|
+
|
|
28
|
+
if (!this.options.countries.EH) {
|
|
29
|
+
mapPaths.MA.d = mapPaths['MA-EH'].d;
|
|
30
|
+
delete mapPaths.EH;
|
|
31
|
+
}
|
|
32
|
+
delete mapPaths['MA-EH'];
|
|
33
|
+
|
|
25
34
|
// Add map elements
|
|
26
|
-
Object.keys(
|
|
35
|
+
Object.keys(mapPaths).forEach(function (countryID) {
|
|
27
36
|
var countryData = this.mapPaths[countryID];
|
|
28
37
|
if (!countryData.d) {
|
|
29
38
|
return;
|
|
@@ -52,6 +61,14 @@ svgMap.prototype.createMap = function () {
|
|
|
52
61
|
});*/
|
|
53
62
|
|
|
54
63
|
// Tooltip events
|
|
64
|
+
// Add tooltip when touch is used
|
|
65
|
+
countryElement.addEventListener('touchstart', function (e) {
|
|
66
|
+
var countryID = countryElement.getAttribute('data-id');
|
|
67
|
+
this.setTooltipContent(this.getTooltipContent(countryID));
|
|
68
|
+
this.showTooltip(e);
|
|
69
|
+
this.moveTooltip(e);
|
|
70
|
+
}.bind(this));
|
|
71
|
+
|
|
55
72
|
countryElement.addEventListener('mouseenter', function (e) {
|
|
56
73
|
var countryID = countryElement.getAttribute('data-id');
|
|
57
74
|
this.setTooltipContent(this.getTooltipContent(countryID));
|
|
@@ -62,8 +79,11 @@ svgMap.prototype.createMap = function () {
|
|
|
62
79
|
this.moveTooltip(e);
|
|
63
80
|
}.bind(this));
|
|
64
81
|
|
|
65
|
-
|
|
66
|
-
|
|
82
|
+
// Hide tooltip when event is mouseleav or touchend
|
|
83
|
+
['mouseleave', 'touchend'].forEach(function (event) {
|
|
84
|
+
countryElement.addEventListener(event, function () {
|
|
85
|
+
this.hideTooltip();
|
|
86
|
+
}.bind(this));
|
|
67
87
|
}.bind(this));
|
|
68
88
|
|
|
69
89
|
}.bind(this));
|
|
@@ -125,7 +145,7 @@ svgMap.prototype.getTooltipContent = function (countryID) {
|
|
|
125
145
|
// Title
|
|
126
146
|
this.createElement('div', 'svgMap-tooltip-title', tooltipContentWrapper)
|
|
127
147
|
.innerHTML = this.getCountryName(countryID);
|
|
128
|
-
|
|
148
|
+
|
|
129
149
|
// Content
|
|
130
150
|
var tooltipContent = this.createElement('div', 'svgMap-tooltip-content', tooltipContentWrapper);
|
|
131
151
|
if (!this.options.data.values[countryID]) {
|
|
@@ -166,4 +186,4 @@ svgMap.prototype.zoomMap = function (direction) {
|
|
|
166
186
|
return false;
|
|
167
187
|
}
|
|
168
188
|
this.mapPanZoom[direction == 'in' ? 'zoomIn' : 'zoomOut']();
|
|
169
|
-
};
|
|
189
|
+
};
|