Skip to content

Commit

Permalink
[BUG FIX] Sets turtle canvas width equal to output panel width (hedyo…
Browse files Browse the repository at this point in the history
…rg#1952)

* Set width dynamically to output width

* Fix width bug

* Visually centered turtle

* Remove redundant empty line

Co-authored-by: boryanagoncharenko <[email protected]>
  • Loading branch information
TiBiBa and boryanagoncharenko authored Feb 15, 2022
1 parent 2a10ff1 commit b02469c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
6 changes: 4 additions & 2 deletions static/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,15 +847,17 @@ function runPythonProgram(this: any, code: string, hasTurtle: boolean, hasSleep:
Sk.pre = "output";
const turtleConfig = (Sk.TurtleGraphics || (Sk.TurtleGraphics = {}));
turtleConfig.target = 'turtlecanvas';
// If the adventures are not shown -> increase height of turtleConfig
if ($('#adventures').is(":hidden")) {
turtleConfig.height = 600;
turtleConfig.worldHeight = 600;
} else {
turtleConfig.height = 300;
turtleConfig.worldHeight = 300;
}
turtleConfig.width = 400;
turtleConfig.worldWidth = 400;
// Always set the width to output panel width -> match the UI
turtleConfig.width = $( '#output' ).width();
turtleConfig.worldWidth = $( '#output' ).width();

if (!hasTurtle) {
// There might still be a visible turtle panel. If the new program does not use the Turtle,
Expand Down
16 changes: 8 additions & 8 deletions static/js/appbundle.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions static/js/appbundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion templates/incl-editor-and-output.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<div class="flex flex-col order-3" id="code_output" style="height: 22rem;">
<!-- tabindex=0 makes the div focusable -->
<div id="output" tabindex=0 class="flex-1 rounded p-2 px-3 bg-gray-900 color-white w-full text-lg overflow-auto" style="min-height: 3rem"></div>
<div id="turtlecanvas" class="flex-0"></div>
<div id="turtlecanvas" class="flex-0 ltr:pl-4 rtl:pr-4"></div>
<div id="inline-modal" class="flex-0" style="display: none">
<div class="py-2 text-left px-3 border-4 border-teal-500 mt-3 rounded bg-green-100">
<!--Title-->
Expand Down

0 comments on commit b02469c

Please sign in to comment.