mirror of
https://github.com/google/blockly.git
synced 2026-03-03 03:40:11 +01:00
when workspace.dispose() is called.
This commit is contained in:
@@ -264,11 +264,12 @@ Blockly.init_ = function(mainWorkspace) {
|
||||
}
|
||||
});
|
||||
|
||||
Blockly.bindEvent_(window, 'resize', null,
|
||||
function() {
|
||||
Blockly.hideChaff(true);
|
||||
Blockly.svgResize(mainWorkspace);
|
||||
});
|
||||
var workspaceResizeHandler = Blockly.bindEvent_(window, 'resize', null,
|
||||
function() {
|
||||
Blockly.hideChaff(true);
|
||||
Blockly.svgResize(mainWorkspace);
|
||||
});
|
||||
mainWorkspace.setResizeHandlerWrapper(workspaceResizeHandler);
|
||||
|
||||
Blockly.inject.bindDocumentEvents_();
|
||||
|
||||
|
||||
@@ -64,6 +64,12 @@ Blockly.WorkspaceSvg = function(options) {
|
||||
};
|
||||
goog.inherits(Blockly.WorkspaceSvg, Blockly.Workspace);
|
||||
|
||||
/**
|
||||
* Wrapper function called when a resize event occurs.
|
||||
* @type {Array.<!Array>} Data that can be passed to unbindEvent_
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.resizeHandlerWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Svg workspaces are user-visible (as opposed to a headless workspace).
|
||||
* @type {boolean} True if visible. False if headless.
|
||||
@@ -138,6 +144,14 @@ Blockly.WorkspaceSvg.prototype.scrollbar = null;
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.lastSound_ = null;
|
||||
|
||||
/**
|
||||
* Save resize handler data so we can delete it later in dispose.
|
||||
* @param {!Array.<!Array>} handler Data that can be passed to unbindEvent_.
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.setResizeHandlerWrapper = function(handler) {
|
||||
this.resizeHandlerWrapper_ = handler;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create the workspace DOM elements.
|
||||
* @param {string=} opt_backgroundClass Either 'blocklyMainBackground' or
|
||||
@@ -238,6 +252,10 @@ Blockly.WorkspaceSvg.prototype.dispose = function() {
|
||||
// Top-most workspace. Dispose of the SVG too.
|
||||
goog.dom.removeNode(this.getParentSvg());
|
||||
}
|
||||
if (this.resizeHandlerWrapper_) {
|
||||
Blockly.unbindEvent_(this.resizeHandlerWrapper_);
|
||||
this.resizeHandlerWrapper_ = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user