Skip to content

Commit 63088d7

Browse files
Last selected grid is re-applied after expand from helpfulwheel in advance mode (#4400)
1 parent e1cae4c commit 63088d7

File tree

1 file changed

+10
-63
lines changed

1 file changed

+10
-63
lines changed

js/turtles.js

Lines changed: 10 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,69 +1059,7 @@ Turtles.TurtlesView = class {
10591059
}
10601060

10611061
this._expandButton.onclick = () => {
1062-
// If the aux toolbar is open, close it.
1063-
const auxToolbar = docById("aux-toolbar");
1064-
if (auxToolbar.style.display === "block") {
1065-
const menuIcon = docById("menu");
1066-
auxToolbar.style.display = "none";
1067-
menuIcon.innerHTML = "menu";
1068-
docById("toggleAuxBtn").className -= "blue darken-1";
1069-
}
1070-
this.hideMenu();
1071-
this.setStageScale(1.0);
1072-
this._expandedBoundary.visible = true;
1073-
this.gridButton.style.visibility = "visible";
1074-
this._collapseButton.style.visibility = "visible";
1075-
this._expandButton.style.visibility = "hidden";
1076-
this.activity.helpfulWheelItems.forEach(ele => {
1077-
if (ele.label === "Expand") {
1078-
ele.display = false;
1079-
} else if (ele.label === "Collapse") {
1080-
ele.display = true;
1081-
} else if (ele.label === "Grid") {
1082-
ele.display = true;
1083-
}
1084-
});
1085-
this._collapsedBoundary.visible = false;
1086-
turtlesStage.removeAllEventListeners("pressmove");
1087-
turtlesStage.removeAllEventListeners("mousedown");
1088-
1089-
turtlesStage.x = 0;
1090-
turtlesStage.y = 0;
1091-
this._isShrunk = false;
1092-
1093-
for (let i = 0; i < this.getTurtleCount(); i++) {
1094-
const turtle = this.getTurtle(i);
1095-
turtle.container.scaleX = 1;
1096-
turtle.container.scaleY = 1;
1097-
turtle.container.scale = 1;
1098-
}
1099-
1100-
this._clearButton.scaleX = 1;
1101-
this._clearButton.scaleY = 1;
1102-
this._clearButton.scale = 1;
1103-
this._clearButton.x = this._w - 5 - 2 * 55;
1104-
1105-
if (this.gridButton !== null) {
1106-
this.gridButton.scaleX = 1;
1107-
this.gridButton.scaleY = 1;
1108-
this.gridButton.scale = 1;
1109-
this.gridButton.x = this._w - 10 - 3 * 55;
1110-
this.gridButton.visible = true;
1111-
}
1112-
1113-
// Restore the previously selected grid
1114-
if (this.selectedGrid !== undefined) {
1115-
this.activity.turtles.currentGrid = this.selectedGrid;
1116-
this.activity.turtles.doGrid(this.selectedGrid);
1117-
} else {
1118-
this.activity.turtles.currentGrid = 0;
1119-
this.activity.turtles.doGrid(0);
1120-
}
1121-
1122-
// remove the stage and add it back in position 0
1123-
this.masterStage.removeChild(turtlesStage);
1124-
this.masterStage.addChildAt(turtlesStage, 0);
1062+
this.expand();
11251063
};
11261064
};
11271065

@@ -1178,6 +1116,15 @@ Turtles.TurtlesView = class {
11781116
this.gridButton.visible = true;
11791117
}
11801118

1119+
// Restore the previously selected grid
1120+
if (this.selectedGrid !== undefined) {
1121+
this.activity.turtles.currentGrid = this.selectedGrid;
1122+
this.activity.turtles.doGrid(this.selectedGrid);
1123+
} else {
1124+
this.activity.turtles.currentGrid = 0;
1125+
this.activity.turtles.doGrid(0);
1126+
}
1127+
11811128
// remove the stage and add it back in position 0
11821129
this.masterStage.removeChild(turtlesStage);
11831130
this.masterStage.addChildAt(turtlesStage, 0);

0 commit comments

Comments
 (0)