Bläddra i källkod

Fix DOM leaks.

pull/72/head
Matthew Petroff 9 år sedan
förälder
incheckning
6d60b961ba
2 ändrade filer med 14 tillägg och 3 borttagningar
  1. +7
    -0
      src/js/libpannellum.js
  2. +7
    -3
      src/js/pannellum.js

+ 7
- 0
src/js/libpannellum.js Visa fil

@@ -86,6 +86,7 @@ function Renderer(container, image, imageType, video) {
var loaded = 0;
var world = this.world;
var container = this.container;
var renderer = this;
var onLoad = function() {
// Draw image on canvas
var faceCanvas = document.createElement('canvas');
@@ -147,6 +148,7 @@ function Renderer(container, image, imageType, video) {
if (loaded == 6) {
fallbackImgSize = this.width;
container.appendChild(world);
renderer.image = null;
callback();
}
};
@@ -286,9 +288,14 @@ function Renderer(container, image, imageType, video) {
gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, this.image[5]);
gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, this.image[0]);
gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, this.image[2]);
this.image = undefined;
} else {
// Upload image to the texture
gl.texImage2D(glBindType, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, this.image);
if (this.video !== true) {
// Allow memory to be freed
this.image = undefined;
}
}

// Set parameters for rendering any size


+ 7
- 3
src/js/pannellum.js Visa fil

@@ -215,6 +215,7 @@ function init() {
function onImageLoad() {
renderer = new libpannellum.renderer(renderContainer, panoImage, config.type, config.video);
panoImage = undefined;
// Only add event listeners once
if (!listenersAdded) {
@@ -948,6 +949,7 @@ function renderInitCallback() {
// Remove image
setTimeout(function() {
renderContainer.removeChild(oldRenderer.fadeImg);
oldRenderer = undefined;
}, config.sceneFadeDuration);
}
}
@@ -1046,15 +1048,17 @@ function createHotSpots() {

function destroyHotSpots() {
if (config.hotSpots) {
config.hotSpots.forEach(function(hs) {
var current = hs.div;
for (var i = 0; i < config.hotSpots.length; i++) {
var current = config.hotSpots[i].div;
while(current.parentNode != renderContainer) {
current = current.parentNode;
}
renderContainer.removeChild(current);
});
config.hotSpots[i].div = null;
}
}
hotspotsCreated = false;
config.hotSpots = undefined;
}

function renderHotSpots() {


Laddar…
Avbryt
Spara