svgmap 2.12.2 → 2.13.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": "2.12.2",
4
+ "version": "2.13.0",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "main": "dist/svgMap.min.js",
@@ -15,16 +15,16 @@
15
15
  "url": "https://github.com/StephanWagner/svgMap.git"
16
16
  },
17
17
  "devDependencies": {
18
- "gulp": "^5.0.0",
18
+ "gulp": "^5.0.1",
19
19
  "gulp-clean-css": "^4.3.0",
20
20
  "gulp-concat": "^2.6.1",
21
- "gulp-header": "^2.0.9",
22
- "gulp-rename": "^2.0.0",
23
- "gulp-sass": "^6.0.0",
24
- "gulp-sourcemaps": "^3.0.0",
21
+ "gulp-header": "^1.8.9",
22
+ "gulp-rename": "^2.1.0",
23
+ "gulp-sass": "^6.0.1",
24
+ "gulp-sourcemaps": "^2.6.5",
25
25
  "gulp-uglify": "^3.0.2",
26
- "jest": "^29.7.0",
27
- "sass": "^1.83.1"
26
+ "jest": "^30.0.5",
27
+ "sass": "^1.90.0"
28
28
  },
29
29
  "dependencies": {
30
30
  "svg-pan-zoom": "^3.6.2"
package/src/js/svgMap.js CHANGED
@@ -11,6 +11,9 @@ function svgMapWrapper(svgPanZoom) {
11
11
  // The element to render the map in
12
12
  targetElementID: '',
13
13
 
14
+ // Allow user to zoom and pan
15
+ allowInteraction: true,
16
+
14
17
  // Minimum and maximum zoom
15
18
  minZoom: 1,
16
19
  maxZoom: 25,
@@ -27,6 +30,9 @@ function svgMapWrapper(svgPanZoom) {
27
30
  // Zoom sensitivity
28
31
  zoomScaleSensitivity: 0.2,
29
32
 
33
+ // Zoom with double-click
34
+ dblClickZoomEnabled: true,
35
+
30
36
  // Zoom with mousewheel
31
37
  mouseWheelZoomEnabled: true,
32
38
 
@@ -113,6 +119,7 @@ function svgMapWrapper(svgPanZoom) {
113
119
 
114
120
  // Block scrolling when option is enabled
115
121
  if (
122
+ this.options.allowInteraction &&
116
123
  this.options.mouseWheelZoomEnabled &&
117
124
  this.options.mouseWheelZoomWithKey
118
125
  ) {
@@ -794,8 +801,10 @@ function svgMapWrapper(svgPanZoom) {
794
801
  this[zoomControlName].type = 'button';
795
802
  this[zoomControlName].addEventListener(
796
803
  'click',
797
- function () {
798
- this.zoomMap(item);
804
+ function() {
805
+ if (this.options.allowInteraction) {
806
+ this.zoomMap(item);
807
+ }
799
808
  }.bind(this),
800
809
  { passive: true }
801
810
  );
@@ -803,11 +812,16 @@ function svgMapWrapper(svgPanZoom) {
803
812
  }.bind(this)
804
813
  );
805
814
 
815
+ if (!this.options.allowInteraction) {
816
+ mapControlsWrapper.classList.add('svgMap-disabled');
817
+ mapControlsWrapper.setAttribute('aria-disabled', 'true');
818
+ }
819
+
806
820
  // Add accessible names to zoom controls
807
821
  this.zoomControlIn.setAttribute('aria-label', 'Zoom in');
808
822
  this.zoomControlOut.setAttribute('aria-label', 'Zoom out');
809
823
 
810
- if (this.options.showContinentSelector) {
824
+ if (this.options.allowInteraction && this.options.showContinentSelector) {
811
825
  // Add continent controls
812
826
  var mapContinentControlsWrapper = this.createElement(
813
827
  'div',
@@ -1007,14 +1021,16 @@ function svgMapWrapper(svgPanZoom) {
1007
1021
 
1008
1022
  // Init pan zoom
1009
1023
  this.mapPanZoom = svgPanZoom(this.mapImage, {
1010
- zoomEnabled: true,
1024
+ zoomEnabled: this.options.allowInteraction,
1025
+ panEnabled: this.options.allowInteraction,
1011
1026
  fit: true,
1012
1027
  center: true,
1013
1028
  minZoom: this.options.minZoom,
1014
1029
  maxZoom: this.options.maxZoom,
1015
1030
  zoomScaleSensitivity: this.options.zoomScaleSensitivity,
1016
1031
  controlIconsEnabled: false,
1017
- mouseWheelZoomEnabled: this.options.mouseWheelZoomEnabled,
1032
+ dblClickZoomEnabled: this.options.allowInteraction ? this.options.dblClickZoomEnabled : false,
1033
+ mouseWheelZoomEnabled: this.options.allowInteraction ? this.options.mouseWheelZoomEnabled : false,
1018
1034
  preventMouseEventsDefault: true,
1019
1035
  onZoom: function () {
1020
1036
  me.setControlStatuses();
package/src/scss/map.scss CHANGED
@@ -77,6 +77,10 @@
77
77
  overflow: hidden;
78
78
  border-radius: 2px;
79
79
  box-shadow: $mapControlsBoxShadow;
80
+
81
+ &.svgMap-disabled {
82
+ display: none;
83
+ }
80
84
  }
81
85
 
82
86
  .svgMap-map-controls-zoom,
@@ -10,7 +10,7 @@ $blockZoomNoticeColor: #fff !default;
10
10
  $blockZoomNoticeBackgroundColor: rgba(0, 0, 0, 0.8) !default;
11
11
 
12
12
  // Map Controls
13
- $mapControlsColor: #fff;
13
+ $mapControlsColor: #fff !default;
14
14
  $mapControlsBackgroundColor: #fff !default;
15
15
  $mapControlsIconColor: #ccc !default;
16
16
  $mapControlsIconColorActive: #000 !default;