@panoramax/web-viewer 3.2.3-develop-b76f2545 → 3.2.3-develop-6f02288e

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoramax/web-viewer",
3
- "version": "3.2.3-develop-b76f2545",
3
+ "version": "3.2.3-develop-6f02288e",
4
4
  "description": "Panoramax web viewer for geolocated pictures",
5
5
  "main": "build/index.js",
6
6
  "author": "Panoramax team",
@@ -105,14 +105,6 @@ export default class PhotoViewer extends Basic {
105
105
  this.psvContainer.setAttribute("slot", "bg");
106
106
  this.grid.appendChild(this.psvContainer);
107
107
  this.popup = createWebComp("pnx-popup", {_parent: this, onclose: this._onPopupClose.bind(this)});
108
-
109
- if(this["url-parameters"] && this["url-parameters"] !== "false") {
110
- this.urlHandler = new URLHandler(this);
111
- this.onceReady().then(() => {
112
- this.urlHandler.listenToChanges();
113
- this.urlHandler._onParentChange();
114
- });
115
- }
116
108
  }
117
109
 
118
110
  /** @private */
@@ -168,26 +160,22 @@ export default class PhotoViewer extends Basic {
168
160
  /** @private */
169
161
  connectedCallback() {
170
162
  super.connectedCallback();
171
- this._moveChildToGrid();
172
163
 
173
- this.onceAPIReady().then(async () => {
174
- this.loader.setAttribute("value", 30);
175
- this._createInitParamsHandler();
164
+ if(this["url-parameters"] && this["url-parameters"] !== "false") {
165
+ this.urlHandler = new URLHandler(this);
166
+ this.onceReady().then(() => {
167
+ this.urlHandler.listenToChanges();
168
+ this.urlHandler._onParentChange();
169
+ });
170
+ }
176
171
 
177
- const myPostInitParams = this._initParams.getParentPostInit();
172
+ this.onceAPIReady().then(this._postAPIInit.bind(this));
173
+ }
178
174
 
179
- this._initPSV();
180
- this._initWidgets();
181
- alterPhotoViewerState(this, myPostInitParams);
182
- this._handleKeyboardManagement();
183
-
184
- if(myPostInitParams.picture) {
185
- this.psv.addEventListener("picture-loaded", () => this.loader.dismiss(), {once: true});
186
- }
187
- else {
188
- this.loader.dismiss();
189
- }
190
- });
175
+ /** @private */
176
+ firstUpdated() {
177
+ super.firstUpdated();
178
+ this._moveChildToGrid();
191
179
  }
192
180
 
193
181
  getClassName() {
@@ -208,7 +196,7 @@ export default class PhotoViewer extends Basic {
208
196
 
209
197
  /** @private */
210
198
  render() {
211
- return [this.loader, this.grid, this.popup, this.slot];
199
+ return [this.loader, this.grid, this.popup];
212
200
  }
213
201
 
214
202
  getSubComponentsNames() {
@@ -257,6 +245,26 @@ export default class PhotoViewer extends Basic {
257
245
  });
258
246
  }
259
247
 
248
+ /** @private */
249
+ async _postAPIInit() {
250
+ this.loader.setAttribute("value", 30);
251
+ this._createInitParamsHandler();
252
+
253
+ const myPostInitParams = this._initParams.getParentPostInit();
254
+
255
+ this._initPSV();
256
+ this._initWidgets();
257
+ alterPhotoViewerState(this, myPostInitParams);
258
+ this._handleKeyboardManagement();
259
+
260
+ if(myPostInitParams.picture) {
261
+ this.psv.addEventListener("picture-loaded", () => this.loader.dismiss(), {once: true});
262
+ }
263
+ else {
264
+ this.loader.dismiss();
265
+ }
266
+ }
267
+
260
268
  /** @private */
261
269
  _initPSV() {
262
270
  try {
@@ -330,26 +338,24 @@ export default class PhotoViewer extends Basic {
330
338
 
331
339
  /** @private */
332
340
  _moveChildToGrid() {
333
- let i = 0;
334
- while(i < this.childNodes.length) {
335
- let n = this.childNodes[i];
336
- if(n.getAttribute?.("slot")) {
337
- // Add parent + translation for our components
338
- if(n.tagName?.toLowerCase().startsWith("pnx-")) {
339
- n._parent = this;
340
- n._t = this._t;
341
- }
342
- // Editors slot -> legend
343
- if(n.getAttribute("slot") === "editors") {
344
- this.onceReady().then(() => this.legend.appendChild(n));
345
- }
346
- // Add to grid for other cases
347
- else {
348
- this.grid.appendChild(n);
349
- }
341
+ const slotContent = Array.from(this.querySelectorAll("[slot]"));
342
+
343
+ slotContent.forEach(n => {
344
+ // Add parent + translation for our components
345
+ if(n.tagName?.toLowerCase().startsWith("pnx-")) {
346
+ n._parent = this;
347
+ n._t = this._t;
350
348
  }
351
- else { i++; }
352
- }
349
+
350
+ // Editors slot -> legend
351
+ if(n.getAttribute("slot") === "editors") {
352
+ this.onceReady().then(() => this.legend?.appendChild(n));
353
+ }
354
+ // Add to grid else
355
+ else {
356
+ this.grid.appendChild(n);
357
+ }
358
+ });
353
359
  }
354
360
 
355
361
  /**
@@ -196,35 +196,6 @@ export default class Viewer extends PhotoViewer {
196
196
  }
197
197
  }
198
198
 
199
- /** @private */
200
- connectedCallback() {
201
- Basic.prototype.connectedCallback.call(this);
202
- this._moveChildToGrid();
203
-
204
- this.onceAPIReady().then(async () => {
205
- this.loader.setAttribute("value", 30);
206
- this._createInitParamsHandler();
207
-
208
- const myPostInitParams = this._initParams.getParentPostInit();
209
-
210
- this._initPSV();
211
- await this._initMap();
212
- this._initWidgets();
213
- alterViewerState(this, myPostInitParams);
214
- this._handleKeyboardManagement();
215
-
216
- if(myPostInitParams.picture) {
217
- this.psv.addEventListener("picture-loaded", () => {
218
- alterViewerState(this, myPostInitParams); // Do it again for forcing focus
219
- this.loader.dismiss();
220
- }, {once: true});
221
- }
222
- else {
223
- this.loader.dismiss();
224
- }
225
- });
226
- }
227
-
228
199
  getClassName() {
229
200
  return "Viewer";
230
201
  }
@@ -328,6 +299,34 @@ export default class Viewer extends PhotoViewer {
328
299
  linkMapAndPhoto(this);
329
300
  }
330
301
 
302
+ /** @private */
303
+ async _postAPIInit() {
304
+ this.loader.setAttribute("value", 30);
305
+ this._createInitParamsHandler();
306
+
307
+ const myPostInitParams = this._initParams.getParentPostInit();
308
+
309
+ this._initPSV();
310
+ await this._initMap();
311
+ this._initWidgets();
312
+
313
+ // Re-launch slot move (for those depending on widgets)
314
+ this._moveChildToGrid();
315
+
316
+ alterViewerState(this, myPostInitParams);
317
+ this._handleKeyboardManagement();
318
+
319
+ if(myPostInitParams.picture) {
320
+ this.psv.addEventListener("picture-loaded", () => {
321
+ alterViewerState(this, myPostInitParams); // Do it again for forcing focus
322
+ this.loader.dismiss();
323
+ }, {once: true});
324
+ }
325
+ else {
326
+ this.loader.dismiss();
327
+ }
328
+ }
329
+
331
330
  /** @private */
332
331
  _handleKeyboardManagement() {
333
332
  // Switchers
@@ -210,15 +210,16 @@ export default class Photo extends PSViewer {
210
210
  const sameSequence = fromNode && toNode.sequence.id === fromNode.sequence.id;
211
211
  const fromNodeHeading = (fromNode?.properties?.["view:azimuth"] || 0) * (Math.PI / 180);
212
212
  const toNodeHeading = (toNode?.properties?.["view:azimuth"] || 0) * (Math.PI / 180);
213
+ const toNodeRelHeading = getRelativeHeading(toNode) * (Math.PI / 180);
213
214
 
214
215
  this.setOption("maxFov", Math.min(toNode.horizontalFov * 3/4, 90));
215
216
 
216
- const centerNoAnim = {
217
+ const forwardNoAnim = {
217
218
  showLoader: false,
218
219
  effect: "none",
219
220
  speed: 0,
220
221
  rotation: false,
221
- rotateTo: { pitch: 0, yaw: 0 },
222
+ rotateTo: { pitch: 0, yaw: -toNodeRelHeading },
222
223
  zoomTo: PSV_DEFAULT_ZOOM
223
224
  };
224
225
 
@@ -226,13 +227,13 @@ export default class Photo extends PSViewer {
226
227
  if(toNode.horizontalFov == 360) {
227
228
  // No previous sequence -> Point to center + no animation
228
229
  if(!fromNode) {
229
- nodeTransition = centerNoAnim;
230
+ nodeTransition = forwardNoAnim;
230
231
  }
231
232
  // Has a previous sequence
232
233
  else {
233
234
  // Far away sequences -> Point to center + no animation
234
235
  if(getDistance(fromNode.gps, toNode.gps) >= 0.001) {
235
- nodeTransition = centerNoAnim;
236
+ nodeTransition = forwardNoAnim;
236
237
  }
237
238
  // Nearby sequences -> Keep orientation
238
239
  else {
@@ -265,7 +266,7 @@ export default class Photo extends PSViewer {
265
266
  }
266
267
  // Different sequence -> Point to center + no animation
267
268
  else {
268
- nodeTransition = centerNoAnim;
269
+ nodeTransition = forwardNoAnim;
269
270
  }
270
271
  }
271
272