Преглед на файлове

Add events for errors (implements #164).

pull/166/merge
Matthew Petroff преди 8 години
родител
ревизия
8ade302e7a
променени са 2 файла, в които са добавени 25 реда и са изтрити 11 реда
  1. +12
    -0
      doc/events.md
  2. +13
    -11
      src/js/pannellum.js

+ 12
- 0
doc/events.md Целия файл

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

Fired when a panorama finishes loading.


## `scenechange`

Fired when a scene change is initiated. A `load` event will be fired when the
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 Целия файл

@@ -501,20 +501,19 @@ function parseGPanoXMP(image) {
/**
* Displays an error message.
* @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.
*/
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';
infoDisplay.load.box.style.display = 'none';
infoDisplay.errorMsg.style.display = 'table';
error = true;
renderContainer.style.display = 'none';
fireEvent('error', errorMsg);
}

/**
@@ -522,9 +521,12 @@ function anError(error) {
* @private
*/
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) {
if (type in externalEventListeners) {
for (var i = 0; i < externalEventListeners[type].length; i++) {
externalEventListeners[type][i].call();
externalEventListeners[type][i].apply(null, [].slice.call(arguments, 1));
}
}
}


Зареждане…
Отказ
Запис