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
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/procedures.js +14-12Lines changed: 14 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -290,18 +290,20 @@ function createProcedureCallbackFactory_(workspace) { |
290 | 290 | var blockDom = Blockly.utils.xml.textToDom(blockText).firstChild; |
291 | 291 | Blockly.Events.setGroup(true); |
292 | 292 | 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 | + }); |
305 | 307 | } |
306 | 308 | }; |
307 | 309 | } |
|