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/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.3.4",
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.2.0",
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.2",
23
+ "gulp-sass": "^4.1.0",
24
24
  "gulp-sourcemaps": "^2.6.5",
25
25
  "gulp-uglify": "^3.0.2",
26
- "jest": "^24.9.0",
26
+ "jest": "^26.0.1",
27
27
  "svg-pan-zoom": "^3.6.1"
28
28
  },
29
29
  "dependencies": {},
@@ -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(this.mapPaths).forEach(function (countryID) {
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
- countryElement.addEventListener('mouseleave', function () {
66
- this.hideTooltip();
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
+ };