Skip to content

Commit

Permalink
Fixed jittering
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTrustyPwo committed Aug 20, 2024
1 parent dc6464f commit 8770ace
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/javascript/simulations/doubleSlit.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ class DoubleSlitSimulation extends Simulation {
mouseUp = (event) => {};

mouseMove = (event, x, y) => {
const prevX = this.screen.x;
this.screen.x = Math.max(Math.min(x, this.screen.maxX), this.screen.minX);
if (prevX === this.screen.x) return;
this.redraw = true;
this.cache = {};
}
Expand Down
2 changes: 2 additions & 0 deletions src/javascript/simulations/nSlit.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ class NSlitSimulation extends Simulation {
mouseUp = () => {};

mouseMove = (event, x, y) => {
const prevY = this.screen.y;
this.screen.y = Math.max(Math.min(y, this.screen.maxY), this.screen.minY);
if (prevY === this.screen.y) return;
this.redraw = true;
this.cache = {};
}
Expand Down
2 changes: 2 additions & 0 deletions src/javascript/simulations/singleSlit.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class SingleSlitSimulation extends Simulation {
mouseUp = (event) => {};

mouseMove = (event, x, y) => {
const prevX = this.screen.x;
this.screen.x = Math.max(Math.min(x, this.screen.maxX), this.screen.minX);
if (prevX === this.screen.x) return;
this.redraw = true;
this.cache = {};
}
Expand Down

0 comments on commit 8770ace

Please sign in to comment.