Skip to content

Commit e6c8457

Browse files
committed
Added cleanup for multiple blocks
1 parent 3fc7a79 commit e6c8457

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/botPage/view/blockly/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,19 @@ const fixCollapsedBlocks = () => {
5151
}
5252
}
5353

54-
const cleanUpForBlockLoad = (blocksToClean, dropEvent = {}) => {
54+
const cleanUpOnLoad = (blocksToClean, dropEvent = {}) => {
5555
const { clientX, clientY } = dropEvent
56-
Blockly.Events.setGroup(true)
5756
const blocklyMetrics = Blockly.mainWorkspace.getMetrics()
5857
const scaleCancellation = (1 / Blockly.mainWorkspace.scale)
5958
const blocklyLeft = blocklyMetrics.absoluteLeft - blocklyMetrics.viewLeft
6059
const blocklyTop = (document.body.offsetHeight - blocklyMetrics.viewHeight) - blocklyMetrics.viewTop
6160
const cursorX = (clientX) ? (clientX - blocklyLeft) * scaleCancellation : 0
62-
const cursorY = (clientY) ? (clientY - blocklyTop) * scaleCancellation : 0
61+
let cursorY = (clientY) ? (clientY - blocklyTop) * scaleCancellation : 0
62+
Blockly.Events.setGroup(true)
6363
for (const block of blocksToClean) {
6464
block.moveBy(cursorX, cursorY)
6565
block.snapToGrid()
66+
cursorY += block.getHeightWidth().height + Blockly.BlockSvg.MIN_BLOCK_Y
6667
}
6768
Blockly.Events.setGroup(false)
6869
// Fire an event to allow scrollbars to resize.
@@ -210,7 +211,7 @@ export default class _Blockly {
210211
for (const block of Array.prototype.slice.call(xml.children)) {
211212
addedBlocks.push(this.addDomBlocks(block))
212213
}
213-
cleanUpForBlockLoad(addedBlocks, dropEvent)
214+
cleanUpOnLoad(addedBlocks, dropEvent)
214215
this.blocksXmlStr = Blockly.Xml.domToPrettyText(
215216
Blockly.Xml.workspaceToDom(Blockly.mainWorkspace))
216217
observer.emit('ui.log.success',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy