diff options
Diffstat (limited to 'src/client/views/nodes/PhysicsSimulationWeight.tsx')
-rw-r--r-- | src/client/views/nodes/PhysicsSimulationWeight.tsx | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/client/views/nodes/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsSimulationWeight.tsx index 669aab67a..9ce740ae9 100644 --- a/src/client/views/nodes/PhysicsSimulationWeight.tsx +++ b/src/client/views/nodes/PhysicsSimulationWeight.tsx @@ -1,6 +1,4 @@ -import React from "react"; -import { useEffect, useState } from "react"; -import { render } from "react-dom"; +import React = require('react'); import { IWallProps } from "./PhysicsSimulationWall"; import Wedge from "./PhysicsSimulationWedge"; @@ -94,9 +92,9 @@ export default class Weight extends React.Component<IWeightProps, IState> { magnitude: this.props.mass * 9.81, directionInDegrees: 270, }; - xMax = window.innerWidth * 0.7; + xMax = 300; xMin = 0; - yMax = window.innerHeight * 0.8; + yMax = 300; yMin = 0; // Helper function to go between display and real values @@ -352,11 +350,11 @@ export default class Weight extends React.Component<IWeightProps, IState> { let collision = false; const minX = this.state.xPosition; const maxX = this.state.xPosition + 2 * this.props.radius; - const containerWidth = window.innerWidth; + const containerWidth = 300; if (this.state.xVelocity != 0) { this.props.walls.forEach((wall) => { if (wall.angleInDegrees == 90) { - const wallX = (wall.xPos / 100) * window.innerWidth; + const wallX = (wall.xPos / 100) * 300; if (wall.xPos < 0.35) { if (minX <= wallX) { if (this.props.elasticCollisions) { @@ -390,7 +388,7 @@ export default class Weight extends React.Component<IWeightProps, IState> { if (this.state.yVelocity > 0) { this.props.walls.forEach((wall) => { if (wall.angleInDegrees == 0) { - const groundY = (wall.yPos / 100) * window.innerHeight; + const groundY = (wall.yPos / 100) * 300; if (maxY >= groundY) { if (this.props.elasticCollisions) { this.setState({yVelocity: -this.state.yVelocity}) @@ -602,7 +600,7 @@ export default class Weight extends React.Component<IWeightProps, IState> { zIndex: -2, }} > - <svg width={this.xMax + "px"} height={window.innerHeight + "px"}> + <svg width={this.xMax + "px"} height={300 + "px"}> <line x1={this.state.xPosition + this.props.radius} y1={this.state.yPosition + this.props.radius} @@ -651,7 +649,7 @@ export default class Weight extends React.Component<IWeightProps, IState> { top: 0, }} > - <svg width={this.xMax + "px"} height={window.innerHeight + "px"}> + <svg width={this.xMax + "px"} height={300 + "px"}> <defs> <marker id="accArrow" @@ -720,7 +718,7 @@ export default class Weight extends React.Component<IWeightProps, IState> { top: 0, }} > - <svg width={this.xMax + "px"} height={window.innerHeight + "px"}> + <svg width={this.xMax + "px"} height={300 + "px"}> <defs> <marker id="velArrow" @@ -815,7 +813,7 @@ export default class Weight extends React.Component<IWeightProps, IState> { > <svg width={this.xMax - this.xMin + "px"} - height={window.innerHeight + "px"} + height={300 + "px"} > <defs> <marker |