@panoramax/web-viewer 4.0.3-develop-39c77140 → 4.0.3-develop-e6a52885

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.
@@ -106,6 +106,7 @@ Component properties. All of [Basic properties](Basic.md/#Panoramax.components.c
106
106
  | [fetchOptions] | <code>object</code> | | Set custom options for fetch calls made against API ([same syntax as fetch options parameter](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters)) |
107
107
  | [lang] | <code>string</code> | | To override language used for labels. Defaults to using user's preferred languages. |
108
108
  | [url-parameters] | <code>string</code> | <code>true</code> | Should the component add and update URL query parameters to save viewer state ? |
109
+ | [keyboard-shortcuts] | <code>string</code> | <code>true</code> | Should keyboard shortcuts be enabled ? Set to "false" to fully disable any keyboard shortcuts. |
109
110
 
110
111
  <a name="Panoramax.components.core.PhotoViewer+onceReady"></a>
111
112
 
@@ -114,6 +114,7 @@ Component properties. All of [Basic properties](Basic.md/#Panoramax.components.c
114
114
  | [map] | <code>object</code> | | An object with [any map option available in Map or MapMore class](../ui/MapMore.md/#Panoramax.components.ui.MapMore).<br />Example: `map="{'background': 'aerial', 'theme': 'age'}"` |
115
115
  | [psv] | <code>object</code> | | [Any option to pass to Photo component](../ui/Photo.md/#Panoramax.components.ui.Photo) as an object.<br />Example: `psv="{'transitionDuration': 500, 'picturesNavigation': 'pic'}"` |
116
116
  | [url-parameters] | <code>string</code> | <code>true</code> | Should the component add and update URL query parameters to save viewer state ? |
117
+ | [keyboard-shortcuts] | <code>string</code> | <code>true</code> | Should keyboard shortcuts be enabled ? Set to "false" to fully disable any keyboard shortcuts. |
117
118
  | [focus] | <code>string</code> | <code>&quot;pic&quot;</code> | The component showing up as main component (pic, map) |
118
119
  | [geocoder] | <code>string</code> | <code>&quot;nominatim&quot;</code> | The geocoder engine to use (nominatim, ban, or URL to a standard [GeocodeJSON-compliant](https://github.com/geocoders/geocodejson-spec/blob/master/draft/README.md) API) |
119
120
  | [widgets] | <code>string</code> | <code>true</code> | Use default set of widgets ? Set to false to avoid any widget to show up, and use slots to populate as you like. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoramax/web-viewer",
3
- "version": "4.0.3-develop-39c77140",
3
+ "version": "4.0.3-develop-e6a52885",
4
4
  "description": "Panoramax web viewer for geolocated pictures",
5
5
  "main": "build/index.js",
6
6
  "author": "Panoramax team",
@@ -85,11 +85,13 @@ export default class PhotoViewer extends Basic {
85
85
  * @property {object} [fetchOptions] Set custom options for fetch calls made against API ([same syntax as fetch options parameter](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters))
86
86
  * @property {string} [lang] To override language used for labels. Defaults to using user's preferred languages.
87
87
  * @property {string} [url-parameters=true] Should the component add and update URL query parameters to save viewer state ?
88
+ * @property {string} [keyboard-shortcuts=true] Should keyboard shortcuts be enabled ? Set to "false" to fully disable any keyboard shortcuts.
88
89
  */
89
90
  static properties = {
90
91
  psv: {converter: Basic.GetJSONConverter()},
91
92
  widgets: {type: String},
92
93
  "url-parameters": {type: String},
94
+ "keyboard-shortcuts": {type: String},
93
95
  ...Basic.properties
94
96
  };
95
97
 
@@ -99,6 +101,7 @@ export default class PhotoViewer extends Basic {
99
101
  // Defaults
100
102
  this.psv = {};
101
103
  this["url-parameters"] = this.getAttribute("url-parameters") || true;
104
+ this["keyboard-shortcuts"] = this.getAttribute("keyboard-shortcuts") || true;
102
105
  this.widgets = this.getAttribute("widgets") || "true";
103
106
 
104
107
  // Init DOM containers
@@ -266,7 +269,10 @@ export default class PhotoViewer extends Basic {
266
269
  this._initPSV();
267
270
  this._initWidgets();
268
271
  alterPhotoViewerState(this, myPostInitParams);
269
- this._handleKeyboardManagement();
272
+
273
+ if(myPostInitParams.keyboardShortcuts) {
274
+ this._handleKeyboardManagement();
275
+ }
270
276
 
271
277
  if(myPostInitParams.picture) {
272
278
  this.psv.addEventListener("picture-loaded", () => this.loader.dismiss(), {once: true});
@@ -95,6 +95,7 @@ export default class Viewer extends PhotoViewer {
95
95
  * @property {object} [map] An object with [any map option available in Map or MapMore class](#Panoramax.components.ui.MapMore).<br />Example: `map="{'background': 'aerial', 'theme': 'age'}"`
96
96
  * @property {object} [psv] [Any option to pass to Photo component](#Panoramax.components.ui.Photo) as an object.<br />Example: `psv="{'transitionDuration': 500, 'picturesNavigation': 'pic'}"`
97
97
  * @property {string} [url-parameters=true] Should the component add and update URL query parameters to save viewer state ?
98
+ * @property {string} [keyboard-shortcuts=true] Should keyboard shortcuts be enabled ? Set to "false" to fully disable any keyboard shortcuts.
98
99
  * @property {string} [focus=pic] The component showing up as main component (pic, map)
99
100
  * @property {string} [geocoder=nominatim] The geocoder engine to use (nominatim, ban, or URL to a standard [GeocodeJSON-compliant](https://github.com/geocoders/geocodejson-spec/blob/master/draft/README.md) API)
100
101
  * @property {string} [widgets=true] Use default set of widgets ? Set to false to avoid any widget to show up, and use slots to populate as you like.
@@ -321,7 +322,10 @@ export default class Viewer extends PhotoViewer {
321
322
  this._moveChildToGrid();
322
323
 
323
324
  alterViewerState(this, myPostInitParams);
324
- this._handleKeyboardManagement();
325
+
326
+ if(myPostInitParams.keyboardShortcuts) {
327
+ this._handleKeyboardManagement();
328
+ }
325
329
 
326
330
  if(myPostInitParams.picture) {
327
331
  this.psv.addEventListener("picture-loaded", () => {
@@ -15,7 +15,7 @@ const MAPLIBRE_OPTIONS = [
15
15
  "boxZoom", "clickTolerance", "collectResourceTiming",
16
16
  "cooperativeGestures", "crossSourceCollisions", "doubleClickZoom", "dragPan",
17
17
  "dragRotate", "fadeDuration", "failIfMajorPerformanceCaveat", "fitBoundsOptions",
18
- "hash", "interactive", "keyboard", "localIdeographFontFamily", "locale", "logoPosition",
18
+ "hash", "interactive", "localIdeographFontFamily", "locale", "logoPosition",
19
19
  "maplibreLogo", "maxBounds", "maxCanvasSize", "maxPitch", "maxTileCacheSize",
20
20
  "maxTileCacheZoomLevels", "maxZoom", "minPitch", "minZoom", "pitch", "pitchWithRotate",
21
21
  "pixelRatio", "preserveDrawingBuffer", "refreshExpiredTiles", "renderWorldCopies",
@@ -80,6 +80,7 @@ export default class InitParameters { // eslint-disable-line import/no-unused-mo
80
80
  let map_raster = componentMap.raster;
81
81
  let map_attribution = componentMap.attributionControl;
82
82
  let map_others = filterMapLibreOptions(componentMap);
83
+ let keyboardShortcuts = componentAttrs["keyboard-shortcuts"];
83
84
 
84
85
  // - URL only
85
86
  let psv_xyz = urlParams.xyz;
@@ -108,13 +109,14 @@ export default class InitParameters { // eslint-disable-line import/no-unused-mo
108
109
 
109
110
  // Put all attributes in appropriate container
110
111
  this._parentInit = { map, users, fetchOptions, style, lang, endpoint };
111
- this._parentPostInit = { focus, picture, sequence, geocoder, widgets, forceFocus: true };
112
+ this._parentPostInit = { focus, picture, sequence, geocoder, widgets, forceFocus: true, keyboardShortcuts: true };
112
113
 
113
114
  this._psvInit = Object.fromEntries(
114
115
  Object.entries(componentPsv).filter(
115
116
  ([k,]) => !["transitionDuration", "picturesNavigation"].includes(k)
116
117
  )
117
118
  );
119
+
118
120
  this._psvAny = {
119
121
  transitionDuration: psv_speed,
120
122
  picturesNavigation: psv_nav,
@@ -126,6 +128,7 @@ export default class InitParameters { // eslint-disable-line import/no-unused-mo
126
128
  attributionControl: map_attribution,
127
129
  ...map_others
128
130
  };
131
+
129
132
  this._mapAny = {
130
133
  theme: map_theme,
131
134
  background: map_background,
@@ -142,6 +145,13 @@ export default class InitParameters { // eslint-disable-line import/no-unused-mo
142
145
  camera: map_camera,
143
146
  pic_score: map_pic_score,
144
147
  };
148
+
149
+ if(keyboardShortcuts === "false") {
150
+ this._psvInit.keyboard = false;
151
+ this._psvInit.keyboardActions = {};
152
+ this._mapInit.keyboard = false;
153
+ this._parentPostInit.keyboardShortcuts = false;
154
+ }
145
155
  }
146
156
 
147
157
  /**
@@ -66,6 +66,7 @@ describe("InitParameters", () => {
66
66
  geocoder: true,
67
67
  widgets: true,
68
68
  forceFocus: true,
69
+ keyboardShortcuts: true,
69
70
  });
70
71
  expect(initParams._psvInit).toEqual({});
71
72
  expect(initParams._psvAny).toEqual({
@@ -111,6 +112,7 @@ describe("InitParameters", () => {
111
112
  geocoder: true,
112
113
  widgets: true,
113
114
  forceFocus: true,
115
+ keyboardShortcuts: true,
114
116
  });
115
117
  });
116
118
 
@@ -161,6 +163,7 @@ describe("InitParameters", () => {
161
163
  geocoder: true,
162
164
  widgets: true,
163
165
  forceFocus: true,
166
+ keyboardShortcuts: true,
164
167
  });
165
168
  });
166
169
 
@@ -243,6 +246,15 @@ describe("InitParameters", () => {
243
246
  expect(initParams._mapAny.background).toBe("streets");
244
247
  expect(console.warn).toHaveBeenCalledWith("Parameter background can't be 'aerial' as no aerial imagery is available");
245
248
  });
249
+
250
+ it("should handle keyboardShortcuts=false", () => {
251
+ componentAttrs["keyboard-shortcuts"] = "false";
252
+ const initParams = new InitParameters(componentAttrs, urlParams);
253
+ expect(initParams._mapInit.keyboard).toBe(false);
254
+ expect(initParams._parentPostInit.keyboardShortcuts).toBe(false);
255
+ expect(initParams._psvInit.keyboard).toBe(false);
256
+ expect(initParams._psvInit.keyboardActions).toEqual({});
257
+ });
246
258
  });
247
259
 
248
260
  describe("getMapPositionFromString", () => {