@antv/l7-core
Advanced tools
Comparing version 2.0.30 to 2.0.31
@@ -6,2 +6,3 @@ import { ISceneConfig } from '../config/IConfigService'; | ||
export interface ISceneService { | ||
destroyed: boolean; | ||
on(type: string, handle: (...args: any[]) => void): void; | ||
@@ -8,0 +9,0 @@ off(type: string, handle: (...args: any[]) => void): void; |
@@ -9,2 +9,3 @@ import { EventEmitter } from 'eventemitter3'; | ||
export default class Scene extends EventEmitter implements ISceneService { | ||
destroyed: true; | ||
private readonly id; | ||
@@ -11,0 +12,0 @@ /** |
@@ -31,2 +31,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(Scene).call(this)); | ||
_this.destroyed = void 0; | ||
@@ -227,3 +228,3 @@ _initializerDefineProperty(_this, "id", _descriptor, _assertThisInitialized(_this)); | ||
case 0: | ||
if (!this.rendering) { | ||
if (!(this.rendering && !this.destroyed)) { | ||
_context3.next = 2; | ||
@@ -239,3 +240,3 @@ break; | ||
if (this.inited) { | ||
_context3.next = 11; | ||
_context3.next = 12; | ||
break; | ||
@@ -248,2 +249,6 @@ } | ||
case 6: | ||
if (this.destroy) { | ||
this.destroy(); | ||
} | ||
this.logger.info(' render inited'); | ||
@@ -255,3 +260,3 @@ this.layerService.initLayers(); | ||
case 11: | ||
case 12: | ||
this.layerService.renderLayers(); | ||
@@ -261,3 +266,3 @@ this.logger.debug("scene ".concat(this.id, " render")); | ||
case 14: | ||
case 15: | ||
case "end": | ||
@@ -299,6 +304,11 @@ return _context3.stop(); | ||
value: function destroy() { | ||
if (!this.inited) { | ||
this.destroyed = true; | ||
return; | ||
} | ||
this.emit('destroy'); | ||
this.inited = false; | ||
this.layerService.destroy(); | ||
this.rendererService.destroy(); | ||
this.map.destroy(); | ||
this.interactionService.destroy(); | ||
@@ -308,3 +318,3 @@ this.controlService.destroy(); | ||
this.removeAllListeners(); | ||
this.map.destroy(); | ||
this.inited = false; | ||
unbind(this.$container, this.handleWindowResized); | ||
@@ -311,0 +321,0 @@ window.matchMedia('screen and (min-resolution: 2dppx)').removeListener(this.handleWindowResized); |
@@ -12,3 +12,3 @@ var docStyle = window.document.documentElement.style; | ||
var $container = document.createElement('div'); | ||
$container.style.cssText += "\n position: absolute;\n top: 0;\n z-index:2;\n height: 100%;\n width: 100%;\n background: inherit;\n pointer-events: none;\n "; | ||
$container.style.cssText += "\n position: absolute;\n top: 0;\n z-index:2;\n height: 100%;\n width: 100%;\n pointer-events: none;\n "; | ||
$container.id = "l7-scene-".concat(containerCounter++); | ||
@@ -15,0 +15,0 @@ $container.classList.add('l7-scene'); |
@@ -58,2 +58,3 @@ "use strict"; | ||
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Scene).call(this)); | ||
_this.destroyed = void 0; | ||
(0, _initializerDefineProperty2.default)(_this, "id", _descriptor, (0, _assertThisInitialized2.default)(_this)); | ||
@@ -238,3 +239,3 @@ (0, _initializerDefineProperty2.default)(_this, "iconService", _descriptor2, (0, _assertThisInitialized2.default)(_this)); | ||
case 0: | ||
if (!this.rendering) { | ||
if (!(this.rendering && !this.destroyed)) { | ||
_context3.next = 2; | ||
@@ -250,3 +251,3 @@ break; | ||
if (this.inited) { | ||
_context3.next = 11; | ||
_context3.next = 12; | ||
break; | ||
@@ -259,2 +260,6 @@ } | ||
case 6: | ||
if (this.destroy) { | ||
this.destroy(); | ||
} | ||
this.logger.info(' render inited'); | ||
@@ -266,3 +271,3 @@ this.layerService.initLayers(); | ||
case 11: | ||
case 12: | ||
this.layerService.renderLayers(); | ||
@@ -272,3 +277,3 @@ this.logger.debug("scene ".concat(this.id, " render")); | ||
case 14: | ||
case 15: | ||
case "end": | ||
@@ -310,6 +315,11 @@ return _context3.stop(); | ||
value: function destroy() { | ||
if (!this.inited) { | ||
this.destroyed = true; | ||
return; | ||
} | ||
this.emit('destroy'); | ||
this.inited = false; | ||
this.layerService.destroy(); | ||
this.rendererService.destroy(); | ||
this.map.destroy(); | ||
this.interactionService.destroy(); | ||
@@ -319,3 +329,3 @@ this.controlService.destroy(); | ||
this.removeAllListeners(); | ||
this.map.destroy(); | ||
this.inited = false; | ||
(0, _elementResizeEvent.unbind)(this.$container, this.handleWindowResized); | ||
@@ -322,0 +332,0 @@ window.matchMedia('screen and (min-resolution: 2dppx)').removeListener(this.handleWindowResized); |
@@ -19,3 +19,3 @@ "use strict"; | ||
var $container = document.createElement('div'); | ||
$container.style.cssText += "\n position: absolute;\n top: 0;\n z-index:2;\n height: 100%;\n width: 100%;\n background: inherit;\n pointer-events: none;\n "; | ||
$container.style.cssText += "\n position: absolute;\n top: 0;\n z-index:2;\n height: 100%;\n width: 100%;\n pointer-events: none;\n "; | ||
$container.id = "l7-scene-".concat(containerCounter++); | ||
@@ -22,0 +22,0 @@ $container.classList.add('l7-scene'); |
{ | ||
"name": "@antv/l7-core", | ||
"version": "2.0.30", | ||
"version": "2.0.31", | ||
"description": "", | ||
@@ -49,3 +49,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "387f76a55f25b18c5d71f86a4d7931d8e0808900", | ||
"gitHead": "132c0e01ee9c4844a90476f3f06a46162192d778", | ||
"publishConfig": { | ||
@@ -52,0 +52,0 @@ "access": "public" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1359658
14805