From 26af8ab71bec926e4514c7df2d523f1635f55f9b Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 23 May 2023 15:59:44 -0400 Subject: fixed resizing physbox container. --- src/client/documents/Documents.ts | 4 +- .../nodes/PhysicsBox/PhysicsSimulationBox.scss | 2 + .../nodes/PhysicsBox/PhysicsSimulationBox.tsx | 138 ++++++++++----------- .../nodes/PhysicsBox/PhysicsSimulationWeight.tsx | 2 +- 4 files changed, 68 insertions(+), 78 deletions(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 1a2409508..13c27d182 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -689,8 +689,8 @@ export namespace Docs { DocumentType.SIMULATION, { data: '', - layout: { view: PhysicsSimulationBox, dataField: defaultDataKey }, - options: { _height: 100, position: '', acceleration: '', pendulum: '', spring: '', wedge: '', simulation: '', review: '' }, + layout: { view: PhysicsSimulationBox, dataField: defaultDataKey, _width: 1000, _height: 800 }, + options: { _height: 100, layout_forceReflow: true, nativeHeightUnfrozen: true, nativeDimModifiable: true, position: '', acceleration: '', pendulum: '', spring: '', wedge: '', simulation: '', review: '' }, }, ], ]); diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.scss b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.scss index c29e36a97..b498296bf 100644 --- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.scss +++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.scss @@ -14,6 +14,8 @@ position: fixed; left: 60%; padding: 1em; + height: 100%; + overflow: auto; .mechanicsSimulationControls { display: flex; diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx index eb41e0de8..bb41cd72e 100644 --- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx +++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx @@ -76,10 +76,6 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - return this.yMax - yPos - 2 * (0.08 * this.layoutDoc[HeightSym]()) + 5; + return this.yMax - yPos - 2 * (0.08 * this.props.PanelHeight()) + 5; }; getYPosFromDisplay = (yDisplay: number) => { - return this.yMax - yDisplay - 2 * (0.08 * this.layoutDoc[HeightSym]()) + 5; + return this.yMax - yDisplay - 2 * (0.08 * this.props.PanelHeight()) + 5; }; // Update forces when coefficient of static friction changes in freeform mode @@ -442,27 +430,27 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent= 5 && angle < 10) { - yPos += 0.08 * this.layoutDoc[HeightSym]() * 0.1; + yPos += 0.08 * this.props.PanelHeight() * 0.1; } else if (angle >= 10 && angle < 15) { - yPos += 0.08 * this.layoutDoc[HeightSym]() * 0.23; + yPos += 0.08 * this.props.PanelHeight() * 0.23; } else if (angle >= 15 && angle < 20) { - yPos += 0.08 * this.layoutDoc[HeightSym]() * 0.26; + yPos += 0.08 * this.props.PanelHeight() * 0.26; } else if (angle >= 20 && angle < 25) { - yPos += 0.08 * this.layoutDoc[HeightSym]() * 0.33; + yPos += 0.08 * this.props.PanelHeight() * 0.33; } else if (angle >= 25 && angle < 30) { - yPos += 0.08 * this.layoutDoc[HeightSym]() * 0.35; + yPos += 0.08 * this.props.PanelHeight() * 0.35; } else if (angle >= 30 && angle < 35) { - yPos += 0.08 * this.layoutDoc[HeightSym]() * 0.4; + yPos += 0.08 * this.props.PanelHeight() * 0.4; } else if (angle >= 35 && angle < 40) { - yPos += 0.08 * this.layoutDoc[HeightSym]() * 0.45; + yPos += 0.08 * this.props.PanelHeight() * 0.45; } else if (angle >= 40 && angle < 45) { - yPos += 0.08 * this.layoutDoc[HeightSym]() * 0.47; + yPos += 0.08 * this.props.PanelHeight() * 0.47; } else if (angle >= 45) { - yPos += 0.08 * this.layoutDoc[HeightSym]() * 0.52; + yPos += 0.08 * this.props.PanelHeight() * 0.52; } this.dataDoc.mass1_positionXstart = this.xMax * 0.25; @@ -692,8 +680,8 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { - let xPos = (this.xMax + this.xMin) / 2 - 0.08 * this.layoutDoc[HeightSym](); + let xPos = (this.xMax + this.xMin) / 2 - 0.08 * this.props.PanelHeight(); let yPos = this.yMin + 200; this.dataDoc.mass1_positionYstart = yPos; this.dataDoc.mass1_positionXstart = xPos; @@ -822,9 +810,9 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { this.dataDoc.simulation_showComponentForces = false; this.dataDoc.mass1_positionYstart = (this.yMax + this.yMin) / 2; - this.dataDoc.mass1_positionXstart = (this.xMin + this.xMax) / 2 - 2 * (0.08 * this.layoutDoc[HeightSym]()) - 5; + this.dataDoc.mass1_positionXstart = (this.xMin + this.xMax) / 2 - 2 * (0.08 * this.props.PanelHeight()) - 5; this.dataDoc.mass1_positionY = this.getDisplayYPos((this.yMax + this.yMin) / 2); - this.dataDoc.mass1_positionX = (this.xMin + this.xMax) / 2 - 2 * (0.08 * this.layoutDoc[HeightSym]()) - 5; + this.dataDoc.mass1_positionX = (this.xMin + this.xMax) / 2 - 2 * (0.08 * this.props.PanelHeight()) - 5; let a = (-1 * ((this.mass1 - this.mass2) * Math.abs(this.gravity))) / (this.mass1 + this.mass2); const gravityForce1: IForce = { description: 'Gravity', @@ -938,8 +926,8 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent @@ -1138,8 +1126,8 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent
-

{StrCast(this.dataDoc.questionPartOne)}

-

{StrCast(this.dataDoc.questionPartTwo)}

+

{this.questionPartOne}

+

{this.questionPartTwo}

{this.selectedQuestion.answerParts.includes('force of gravity') && ( diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx index ac28ee4a0..c036f1041 100644 --- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx +++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx @@ -1062,7 +1062,7 @@ export default class Weight extends React.Component {

{Math.round(((Math.atan(this.props.wedgeHeight / this.props.wedgeWidth) * 180) / Math.PI) * 100) / 100}° -- cgit v1.2.3-70-g09d2