GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: improve positioning of newly created procedure blocks (#121) · scratchfoundation/scratch-blocks@84a9e5b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • procedures.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/procedures.js‎

Copy file name to clipboardExpand all lines: src/procedures.js
+14-12Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -290,18 +290,20 @@ function createProcedureCallbackFactory_(workspace) {
290290
var blockDom = Blockly.utils.xml.textToDom(blockText).firstChild;
291291
Blockly.Events.setGroup(true);
292292
var block = Blockly.Xml.domToBlock(blockDom, workspace);
293-
var scale = workspace.scale; // To convert from pixel units to workspace units
294-
// Position the block so that it is at the top left of the visible workspace,
295-
// padded from the edge by 30 units. Position in the top right if RTL.
296-
var posX = -workspace.scrollX;
297-
if (workspace.RTL) {
298-
posX += workspace.getMetrics().contentWidth - 30;
299-
} else {
300-
posX += 30;
301-
}
302-
block.moveBy(posX / scale, (-workspace.scrollY + 30) / scale);
303-
block.scheduleSnapAndBump();
304-
Blockly.Events.setGroup(false);
293+
Blockly.renderManagement.finishQueuedRenders().then(() => {
294+
var scale = workspace.scale; // To convert from pixel units to workspace units
295+
// Position the block so that it is at the top left of the visible workspace,
296+
// padded from the edge by 30 units. Position in the top right if RTL.
297+
var posX = -workspace.scrollX;
298+
if (workspace.RTL) {
299+
posX += workspace.getMetrics().contentWidth - 30;
300+
} else {
301+
posX += 30;
302+
}
303+
block.moveBy(posX / scale, (-workspace.scrollY + 30) / scale);
304+
block.scheduleSnapAndBump();
305+
Blockly.Events.setGroup(false);
306+
});
305307
}
306308
};
307309
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.