aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/PhysicsSimulationWeight.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/PhysicsSimulationWeight.tsx')
-rw-r--r--src/client/views/nodes/PhysicsSimulationWeight.tsx51
1 files changed, 34 insertions, 17 deletions
diff --git a/src/client/views/nodes/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsSimulationWeight.tsx
index 9ce740ae9..07ab84bd8 100644
--- a/src/client/views/nodes/PhysicsSimulationWeight.tsx
+++ b/src/client/views/nodes/PhysicsSimulationWeight.tsx
@@ -97,6 +97,23 @@ export default class Weight extends React.Component<IWeightProps, IState> {
yMax = 300;
yMin = 0;
+ // Var
+ weightStyle = {
+ backgroundColor: this.props.color,
+ borderStyle: "solid",
+ borderColor: "black",
+ position: "absolute" as "absolute",
+ left: this.props.startPosX + "px",
+ top: this.props.startPosY + "px",
+ width: 2 * this.props.radius + "px",
+ height: 2 * this.props.radius + "px",
+ borderRadius: 50 + "%",
+ display: "flex",
+ justifyContent: "center",
+ alignItems: "center",
+ touchAction: "none",
+ };
+
// Helper function to go between display and real values
getDisplayYPos = (yPos: number) => {
return this.yMax - yPos - 2 * this.props.radius + 5;
@@ -138,8 +155,8 @@ export default class Weight extends React.Component<IWeightProps, IState> {
);
};
- // When display values updated by user, update real values
componentDidUpdate(prevProps: Readonly<IWeightProps>, prevState: Readonly<IState>, snapshot?: any): void {
+ // When display values updated by user, update real values
if (this.props.updateDisplay != prevProps.updateDisplay) {
if (this.props.updateDisplay.xDisplay != this.state.xPosition) {
let x = this.props.updateDisplay.xDisplay;
@@ -187,6 +204,22 @@ export default class Weight extends React.Component<IWeightProps, IState> {
this.setDisplayValues();
}
}
+ this.weightStyle = {
+ backgroundColor: this.props.color,
+ borderStyle: "solid",
+ borderColor: this.state.dragging ? "lightblue" : "black",
+ position: "absolute" as "absolute",
+ left: this.state.xPosition + "px",
+ top: this.state.yPosition + "px",
+ width: 2 * this.props.radius + "px",
+ height: 2 * this.props.radius + "px",
+ borderRadius: 50 + "%",
+ display: "flex",
+ justifyContent: "center",
+ alignItems: "center",
+ touchAction: "none",
+ };
+
if (this.props.reset != prevProps.reset) {
this.resetEverything();
}
@@ -481,22 +514,6 @@ export default class Weight extends React.Component<IWeightProps, IState> {
this.props.setUpdatedForces(this.getNewForces(xPos, yPos, xVel, yVel));
};
- weightStyle = {
- backgroundColor: this.props.color,
- borderStyle: "solid",
- borderColor: this.state.dragging ? "lightblue" : "black",
- position: "absolute" as "absolute",
- left: this.state.xPosition + "px",
- top: this.state.yPosition + "px",
- width: 2 * this.props.radius + "px",
- height: 2 * this.props.radius + "px",
- borderRadius: 50 + "%",
- display: "flex",
- justifyContent: "center",
- alignItems: "center",
- touchAction: "none",
- };
-
labelBackgroundColor = `rgba(255,255,255,0.5)`;
render () {