Переглянути джерело

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.
tags/2.5.0
Matthew Petroff 5 роки тому
джерело
коміт
71bf642860
1 змінених файлів з 4 додано та 17 видалено
  1. +4
    -17
      src/js/pannellum.js

+ 4
- 17
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');
}

}


Завантаження…
Відмінити
Зберегти