The on document scroll -> updateInverseScreenCTM event is only bound to the first injected workspace because of the Blockly.documentEventsBound_ check. (link)
This causes zooming with wheel to be off (for any secondary workspaces) after the page is scrolled.
Every workspace should have updateInverseScreenCTM called on it when the document is scrolled.
Only the workspace that is injected first has updateInverseScreenCTM called on it.
console.log(this.id);N/A
I am assuming this is not browse specific.
N/A
Actually this may not need to be an event binding, we may just need to call updateScreenCalculationsIfScrolled_ in onMouseWheel_.
Good catch. There's a workspaceDB object on Blockly that has all of the known workspaces; you can call updateInverseScreenCTM on each one, after confirming that the function exists (workspace_svg has it, but workspace doesn't).
Good catch. There's a workspaceDB object on Blockly that has all of the known workspaces; you can call updateInverseScreenCTM on each one, after confirming that the function exists (workspace_svg has it, but workspace doesn't).
I gave it a shot, but it seems like the WorkspaceDB_ object only stores workspace's and not workspace_svg's?
This code always returns undefined:
Blockly.bindEventWithChecks_(document, 'scroll', null, function() {
for (var workspace in Blockly.Workspace.WorkspaceDB_) {
console.log(workspace.updateInverseScreenCTM);
}
});
I can make workspace_svg overwrite the database if this is the route you want to go.
It contains both types of workspaces. WorkspaceSvgs extend Workspace and call that constructor as well. If you open up the multi_playground and type Object.keys(Blockly.Workspace.WorkspaceDB_).length in the console, you'll see that it has 24 elements: (one trash workspace, one flyout workspace, and one main workspace) * (8 blockly instances on the page).
Your code didn't work because you have to get items in the DB by key (it's just an object). Change it to this:
Blockly.bindEventWithChecks_(document, 'scroll', null, function() {
for (var key in Blockly.Workspace.WorkspaceDB_) {
var workspace = Blockly.Workspace.WorkspaceDB_[key];
console.log(workspace.updateInverseScreenCTM);
}
});