aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/PhysicsSimulationWedge.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/PhysicsSimulationWedge.tsx')
-rw-r--r--src/client/views/nodes/PhysicsSimulationWedge.tsx21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/client/views/nodes/PhysicsSimulationWedge.tsx b/src/client/views/nodes/PhysicsSimulationWedge.tsx
index b3988221c..43a4d69de 100644
--- a/src/client/views/nodes/PhysicsSimulationWedge.tsx
+++ b/src/client/views/nodes/PhysicsSimulationWedge.tsx
@@ -5,6 +5,8 @@ export interface IWedgeProps {
startHeight: number;
startWidth: number;
startLeft: number;
+ xMax: number;
+ yMax: number;
}
interface IState {
@@ -28,18 +30,19 @@ export default class Wedge extends React.Component<IWedgeProps, IState> {
updateCoordinates() {
const coordinatePair1 =
- Math.round(this.state.left) + "," + Math.round(300 * 0.8) + " ";
+ Math.round(this.state.left) + "," + Math.round(this.props.yMax) + " ";
const coordinatePair2 =
Math.round(this.state.left + this.props.startWidth) +
"," +
- Math.round(300 * 0.8) +
+ Math.round(this.props.yMax) +
" ";
const coordinatePair3 =
Math.round(this.state.left) +
"," +
- Math.round(300 * 0.8 - this.props.startHeight);
+ Math.round(this.props.yMax - this.props.startHeight);
const coord = coordinatePair1 + coordinatePair2 + coordinatePair3;
this.setState({coordinates: coord});
+ console.log("coordinates: ", coord)
}
componentDidMount() {
@@ -47,7 +50,9 @@ export default class Wedge extends React.Component<IWedgeProps, IState> {
}
componentDidUpdate(prevProps: Readonly<IWedgeProps>, prevState: Readonly<IState>, snapshot?: any): void {
- this.updateCoordinates();
+ if (prevState.coordinates != this.state.coordinates) {
+ this.updateCoordinates();
+ }
if (prevProps.startHeight != this.props.startHeight || prevProps.startWidth != this.props.startWidth) {
this.setState({angleInRadians: Math.atan(this.props.startHeight / this.props.startWidth)});
}
@@ -56,10 +61,10 @@ export default class Wedge extends React.Component<IWedgeProps, IState> {
render() {
return (
<div>
- <div style={{ position: "absolute", left: "0", top: "0", zIndex: -5 }}>
+ <div style={{ position: "absolute", left: "0", top: "0" }}>
<svg
- width={300 * 0.7 + "px"}
- height={300 * 0.8 + "px"}
+ width={this.props.xMax + "px"}
+ height={this.props.yMax + "px"}
>
<polygon points={this.state.coordinates} style={{ fill: "burlywood" }} />
</svg>
@@ -70,7 +75,7 @@ export default class Wedge extends React.Component<IWedgeProps, IState> {
position: "absolute",
zIndex: 500,
left: Math.round(this.state.left + this.props.startWidth - 80) + "px",
- top: Math.round(300 * 0.8 - 40) + "px",
+ top: Math.round(this.props.yMax - 40) + "px",
}}
>
{Math.round(((this.state.angleInRadians * 180) / Math.PI) * 100) / 100}°