From a05721198901cf2554e560f5029184ee897b4fc1 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 13 Nov 2018 21:55:22 -0500 Subject: [PATCH 01/10] Allow switching to dynamic scenes (fixes #686). --- doc/json-config-parameters.md | 6 ++++++ src/js/pannellum.js | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/doc/json-config-parameters.md b/doc/json-config-parameters.md index 9cddd9d..7f872ea 100644 --- a/doc/json-config-parameters.md +++ b/doc/json-config-parameters.md @@ -446,6 +446,12 @@ Currently, only equirectangular dynamic content is supported. The panorama source is considered dynamic when this is set to `true`. Defaults to `false`. This should be set to `true` for video. +### `dynamicUpdate` (boolean) + +For dynamic content, viewer will start automatically updating when set to +`true`. Defaults to `false`. If the updates are controlled via the `setUpdate` +method, as with the Video.js plugin, this should be set to `false`. + ## Additional information for tour configuration files diff --git a/src/js/pannellum.js b/src/js/pannellum.js index f040a6e..077fa57 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -92,6 +92,7 @@ var defaultConfig = { northOffset: 0, showFullscreenCtrl: true, dynamic: false, + dynamicUpdate: false, doubleClickZoom: true, keyboardZoom: true, mouseZoom: true, @@ -2287,6 +2288,13 @@ function loadScene(sceneId, targetPitch, targetYaw, targetHfov, fadeDone) { } fireEvent('scenechange', sceneId); load(); + + // Properly handle switching to dynamic scenes + update = config.dynamicUpdate === true; + if (config.dynamic) { + panoImage = config.panorama; + onImageLoad(); + } } /** From 4242e7c53aec68780d298456f92ea88b02575b14 Mon Sep 17 00:00:00 2001 From: Will Calderbank Date: Wed, 5 Dec 2018 23:15:26 +0000 Subject: [PATCH 02/10] Add stopMovement to stop all movement (#690) Add `stopMovement` to stop all movement --- src/js/pannellum.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/js/pannellum.js b/src/js/pannellum.js index 077fa57..51feb0d 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -2713,6 +2713,16 @@ this.stopAutoRotate = function() { }; /** + * Stops all movement. + * @memberof Viewer + * @instance + */ +this.stopMovement = function() { + stopAnimation(); + speed = {'yaw': 0, 'pitch': 0, 'hfov': 0}; +} + +/** * Returns the panorama renderer. * @memberof Viewer * @instance From f0af9d07bfe46200ebe4b1bf81eb5658a0653cf5 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 21 Dec 2018 16:23:31 -0500 Subject: [PATCH 03/10] Fix interaction between F11 and API fullscreens in Chrome (fixes #696). --- src/js/pannellum.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/pannellum.js b/src/js/pannellum.js index 51feb0d..f5ec471 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -480,10 +480,10 @@ function onImageLoad() { if (config.doubleClickZoom) { dragFix.addEventListener('dblclick', onDocumentDoubleClick, false); } - uiContainer.addEventListener('mozfullscreenchange', onFullScreenChange, false); - uiContainer.addEventListener('webkitfullscreenchange', onFullScreenChange, false); - uiContainer.addEventListener('msfullscreenchange', onFullScreenChange, false); - uiContainer.addEventListener('fullscreenchange', onFullScreenChange, false); + container.addEventListener('mozfullscreenchange', onFullScreenChange, false); + container.addEventListener('webkitfullscreenchange', onFullScreenChange, false); + container.addEventListener('msfullscreenchange', onFullScreenChange, false); + container.addEventListener('fullscreenchange', onFullScreenChange, false); window.addEventListener('resize', onDocumentResize, false); window.addEventListener('orientationchange', onDocumentResize, false); if (!config.disableKeyboardCtrl) { From f05615045e976d069f972869f1988ff61f83fda0 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 21 Dec 2018 16:25:33 -0500 Subject: [PATCH 04/10] Fix event listener removal regression introduced in 64c337beff511a0eaa862179bc4cd919ba87e5ae. --- src/js/pannellum.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/js/pannellum.js b/src/js/pannellum.js index f5ec471..149b10c 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -3053,17 +3053,17 @@ this.destroy = function() { dragFix.removeEventListener('dblclick', onDocumentDoubleClick, false); document.removeEventListener('mousemove', onDocumentMouseMove, false); document.removeEventListener('mouseup', onDocumentMouseUp, false); - container.removeEventListener('mousewheel', onDocumentMouseWheel, false); - container.removeEventListener('DOMMouseScroll', onDocumentMouseWheel, false); + uiContainer.removeEventListener('mousewheel', onDocumentMouseWheel, false); + uiContainer.removeEventListener('DOMMouseScroll', onDocumentMouseWheel, false); container.removeEventListener('mozfullscreenchange', onFullScreenChange, false); container.removeEventListener('webkitfullscreenchange', onFullScreenChange, false); container.removeEventListener('msfullscreenchange', onFullScreenChange, false); container.removeEventListener('fullscreenchange', onFullScreenChange, false); window.removeEventListener('resize', onDocumentResize, false); window.removeEventListener('orientationchange', onDocumentResize, false); - container.removeEventListener('keydown', onDocumentKeyPress, false); - container.removeEventListener('keyup', onDocumentKeyUp, false); - container.removeEventListener('blur', clearKeys, false); + uiContainer.removeEventListener('keydown', onDocumentKeyPress, false); + uiContainer.removeEventListener('keyup', onDocumentKeyUp, false); + uiContainer.removeEventListener('blur', clearKeys, false); document.removeEventListener('mouseleave', onDocumentMouseUp, false); dragFix.removeEventListener('touchstart', onDocumentTouchStart, false); dragFix.removeEventListener('touchmove', onDocumentTouchMove, false); From bcebff27d115e527652e270d62f48d69867a1104 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 21 Dec 2018 16:32:31 -0500 Subject: [PATCH 05/10] Don't fire `fullscreenchange` event on resize. --- src/js/pannellum.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/js/pannellum.js b/src/js/pannellum.js index 149b10c..c6a904e 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -1329,7 +1329,7 @@ function onDocumentResize() { //animateInit(); // Kludge to deal with WebKit regression: https://bugs.webkit.org/show_bug.cgi?id=93525 - onFullScreenChange(); + onFullScreenChange('resize'); } /** @@ -2105,7 +2105,7 @@ function toggleFullscreen() { * Event handler for fullscreen changes. * @private */ -function onFullScreenChange() { +function onFullScreenChange(resize) { if (document.fullscreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement) { controls.fullscreen.classList.add('pnlm-fullscreen-toggle-button-active'); fullscreenActive = true; @@ -2113,7 +2113,8 @@ function onFullScreenChange() { controls.fullscreen.classList.remove('pnlm-fullscreen-toggle-button-active'); fullscreenActive = false; } - fireEvent('fullscreenchange', fullscreenActive); + if (resize !== 'resize') + fireEvent('fullscreenchange', fullscreenActive); // Resize renderer (deal with browser quirks and fixes #155) renderer.resize(); setHfov(config.hfov); From 03eb7fa13151dd2b6854b59e0fc76564192a8ffe Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 21 Dec 2018 16:40:02 -0500 Subject: [PATCH 06/10] Add check for `document.fullscreenElement` since `document.fullscreen` is deprecated. --- src/js/pannellum.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/pannellum.js b/src/js/pannellum.js index c6a904e..ba6b90b 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -2106,7 +2106,7 @@ function toggleFullscreen() { * @private */ function onFullScreenChange(resize) { - if (document.fullscreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement) { + if (document.fullscreenElement || document.fullscreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement) { controls.fullscreen.classList.add('pnlm-fullscreen-toggle-button-active'); fullscreenActive = true; } else { From 12516e69b90e8ab4c6f42b64560aef92ae539bd0 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 21 Dec 2018 17:16:14 -0500 Subject: [PATCH 07/10] Fix issue with mouse dragging causing jump around yaw limits (fixes #698) --- src/js/pannellum.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/js/pannellum.js b/src/js/pannellum.js index ba6b90b..3d1fb33 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -1399,12 +1399,6 @@ function render() { var tmpyaw; if (loaded) { - if (config.yaw > 180) { - config.yaw -= 360; - } else if (config.yaw < -180) { - config.yaw += 360; - } - // Keep a tmp value of yaw for autoRotate comparison later tmpyaw = config.yaw; @@ -1439,6 +1433,12 @@ function render() { config.yaw = Math.max(minYaw, Math.min(maxYaw, config.yaw)); } + if (config.yaw > 180) { + config.yaw -= 360; + } else if (config.yaw < -180) { + config.yaw += 360; + } + // Check if we autoRotate in a limited by min and max yaw // If so reverse direction if (config.autoRotate !== false && tmpyaw != config.yaw && From 19b020dbc72b9aeb5d6e3faca95bb55ce5418bb5 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 31 Dec 2018 14:36:39 -0500 Subject: [PATCH 08/10] Check to make sure hot spot div exists before deleting it (#702). --- src/js/pannellum.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/pannellum.js b/src/js/pannellum.js index 3d1fb33..fb5bebb 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -1784,10 +1784,12 @@ function destroyHotSpots() { if (hs) { for (var i = 0; i < hs.length; i++) { var current = hs[i].div; - while(current.parentNode != renderContainer) { - current = current.parentNode; + if (current) { + while(current.parentNode != renderContainer) { + current = current.parentNode; + } + renderContainer.removeChild(current); } - renderContainer.removeChild(current); delete hs[i].div; } } From 34cb1a409ef169167536bef199a2a95d2642ab19 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 31 Dec 2018 14:41:05 -0500 Subject: [PATCH 09/10] Another check to make sure hot spot div exists before deleting it (#702). --- src/js/pannellum.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/pannellum.js b/src/js/pannellum.js index fb5bebb..4df169b 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -1785,7 +1785,7 @@ function destroyHotSpots() { for (var i = 0; i < hs.length; i++) { var current = hs[i].div; if (current) { - while(current.parentNode != renderContainer) { + while (current.parentNode && current.parentNode != renderContainer) { current = current.parentNode; } renderContainer.removeChild(current); From 71bf642860f2cc34c7120435ed635b893d92e5c5 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 30 Jan 2019 20:17:34 -0500 Subject: [PATCH 10/10] Properly remove event listeners from container element (fixes #710). For three event listeners added to the container elements weren't being removed properly, since `removeEventListener` was mistakenly being called on `uiContainer` instead. This was preventing garbage collection. --- src/js/pannellum.js | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/js/pannellum.js b/src/js/pannellum.js index 4df169b..fa7f947 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -3050,36 +3050,23 @@ function fireEvent(type) { */ this.destroy = function() { if (renderer) - renderer.destroy() + renderer.destroy(); if (listenersAdded) { - dragFix.removeEventListener('mousedown', onDocumentMouseDown, false); - dragFix.removeEventListener('dblclick', onDocumentDoubleClick, false); document.removeEventListener('mousemove', onDocumentMouseMove, false); document.removeEventListener('mouseup', onDocumentMouseUp, false); - uiContainer.removeEventListener('mousewheel', onDocumentMouseWheel, false); - uiContainer.removeEventListener('DOMMouseScroll', onDocumentMouseWheel, false); container.removeEventListener('mozfullscreenchange', onFullScreenChange, false); container.removeEventListener('webkitfullscreenchange', onFullScreenChange, false); container.removeEventListener('msfullscreenchange', onFullScreenChange, false); container.removeEventListener('fullscreenchange', onFullScreenChange, false); window.removeEventListener('resize', onDocumentResize, false); window.removeEventListener('orientationchange', onDocumentResize, false); - uiContainer.removeEventListener('keydown', onDocumentKeyPress, false); - uiContainer.removeEventListener('keyup', onDocumentKeyUp, false); - uiContainer.removeEventListener('blur', clearKeys, false); + container.removeEventListener('keydown', onDocumentKeyPress, false); + container.removeEventListener('keyup', onDocumentKeyUp, false); + container.removeEventListener('blur', clearKeys, false); document.removeEventListener('mouseleave', onDocumentMouseUp, false); - dragFix.removeEventListener('touchstart', onDocumentTouchStart, false); - dragFix.removeEventListener('touchmove', onDocumentTouchMove, false); - dragFix.removeEventListener('touchend', onDocumentTouchEnd, false); - dragFix.removeEventListener('pointerdown', onDocumentPointerDown, false); - dragFix.removeEventListener('pointermove', onDocumentPointerMove, false); - dragFix.removeEventListener('pointerup', onDocumentPointerUp, false); - dragFix.removeEventListener('pointerleave', onDocumentPointerUp, false); } container.innerHTML = ''; container.classList.remove('pnlm-container'); - uiContainer.classList.remove('pnlm-grab'); - uiContainer.classList.remove('pnlm-grabbing'); } }