Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
Chore: better backpack (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
sverben authored Jan 31, 2024
1 parent d513d01 commit 5b3fc06
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Blockly from "blockly/core";
export class Backpack extends BaseBackpack {
constructor(workspace: Blockly.WorkspaceSvg) {
super(workspace, {
allowEmptyBackpackOpen: true,
allowEmptyBackpackOpen: false,
});
}

Expand Down Expand Up @@ -38,11 +38,17 @@ export class Backpack extends BaseBackpack {
}
override addBlock(block: Blockly.Block) {
if (block.type === 'leaphy_start') {
return this.addBlocks(block.getChildren(false));
this.addBlocks(block.getChildren(false));
block.getChildren(false).forEach((child) => {
setTimeout(() => child.dispose(undefined), 0);
});

return;
}

// @ts-ignore
this.addItem(this.blockToJsonString(block));
setTimeout(() => block.dispose(undefined), 0);
}

override position(metrics: Blockly.MetricsManager.UiMetrics, savedPositions: Blockly.utils.Rect[]) {
Expand All @@ -59,8 +65,6 @@ export class Backpack extends BaseBackpack {
this.MARGIN_VERTICAL_ -
15;

console.log(this.left_, this.top_);

if (this.svgGroup_) {
this.svgGroup_.setAttribute(
'transform',
Expand Down

0 comments on commit 5b3fc06

Please sign in to comment.