Browse Source

Add events for errors (implements #164).

pull/166/merge
Matthew Petroff 8 years ago
parent
commit
8ade302e7a
2 changed files with 25 additions and 11 deletions
  1. +12
    -0
      doc/events.md
  2. +13
    -11
      src/js/pannellum.js

+ 12
- 0
doc/events.md View File

@@ -4,7 +4,19 @@


Fired when a panorama finishes loading. Fired when a panorama finishes loading.



## `scenechange` ## `scenechange`


Fired when a scene change is initiated. A `load` event will be fired when the Fired when a scene change is initiated. A `load` event will be fired when the
new scene finishes loading. new scene finishes loading.


## `error`

Fired when an error occured. The error message string is passed to the
event listener.


## `errorcleared`

Fired when an error is cleared.

+ 13
- 11
src/js/pannellum.js View File

@@ -501,20 +501,19 @@ function parseGPanoXMP(image) {
/** /**
* Displays an error message. * Displays an error message.
* @private * @private
* @param {string} error - Error message to display. If not specified, a
* @param {string} errorMsg - Error message to display. If not specified, a
* generic WebGL error is displayed. * generic WebGL error is displayed.
*/ */
function anError(error) {
if (error !== undefined) {
infoDisplay.errorMsg.innerHTML = '<p>' + error + '</p>';
} else {
infoDisplay.errorMsg.innerHTML = '<p>Your browser does not have the necessary WebGL support to display this panorama.</p>';
}
function anError(errorMsg) {
if (errorMsg === undefined)
errorMsg = 'Your browser does not have the necessary WebGL support to display this panorama.';
infoDisplay.errorMsg.innerHTML = '<p>' + errorMsg + '</p>';
controls.load.style.display = 'none'; controls.load.style.display = 'none';
infoDisplay.load.box.style.display = 'none'; infoDisplay.load.box.style.display = 'none';
infoDisplay.errorMsg.style.display = 'table'; infoDisplay.errorMsg.style.display = 'table';
error = true; error = true;
renderContainer.style.display = 'none'; renderContainer.style.display = 'none';
fireEvent('error', errorMsg);
} }


/** /**
@@ -522,9 +521,12 @@ function anError(error) {
* @private * @private
*/ */
function clearError() { function clearError() {
infoDisplay.load.box.style.display = 'none';
infoDisplay.errorMsg.style.display = 'none';
error = false;
if (error) {
infoDisplay.load.box.style.display = 'none';
infoDisplay.errorMsg.style.display = 'none';
error = false;
fireEvent('errorcleared');
}
} }


/** /**
@@ -2143,7 +2145,7 @@ this.off = function(type, listener) {
function fireEvent(type) { function fireEvent(type) {
if (type in externalEventListeners) { if (type in externalEventListeners) {
for (var i = 0; i < externalEventListeners[type].length; i++) { for (var i = 0; i < externalEventListeners[type].length; i++) {
externalEventListeners[type][i].call();
externalEventListeners[type][i].apply(null, [].slice.call(arguments, 1));
} }
} }
} }


Loading…
Cancel
Save