Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions core/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Blockly.inject = function(container, opt_options) {

var workspace = Blockly.createMainWorkspace_(svg, options, blockDragSurface,
workspaceDragSurface);
Blockly.init_(workspace);
Blockly.init_(workspace, subContainer);
Blockly.mainWorkspace = workspace;

Blockly.svgResize(workspace);
Expand Down Expand Up @@ -347,9 +347,10 @@ Blockly.createMainWorkspace_ = function(svg, options, blockDragSurface, workspac
/**
* Initialize Blockly with various handlers.
* @param {!Blockly.Workspace} mainWorkspace Newly created main workspace.
* @param {!Element} container Containing element.
* @private
*/
Blockly.init_ = function(mainWorkspace) {
Blockly.init_ = function(mainWorkspace, container) {
var options = mainWorkspace.options;
var svg = mainWorkspace.getParentSvg();

Expand All @@ -361,13 +362,12 @@ Blockly.init_ = function(mainWorkspace) {
}
});

var workspaceResizeHandler = Blockly.bindEventWithChecks_(window, 'resize',
null,
function() {
Blockly.hideChaffOnResize(true);
Blockly.svgResize(mainWorkspace);
});
mainWorkspace.setResizeHandlerWrapper(workspaceResizeHandler);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old code kept track of this handler and would remove it in the workspace's dispose() function. Do we need to do something equivalent in the new code?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I added logic for disconnecting the observer

const resizeObserver = new ResizeObserver(() => {
Blockly.hideChaffOnResize(true);
Blockly.svgResize(mainWorkspace);
});

resizeObserver.observe(container);

Blockly.inject.bindDocumentEvents_();

Expand Down
Loading