Only move collisions/actors/triggers if tile has changed when moving mouse, prevents multiple identical redux actions which pollute undo history
@@ -39,6 +39,7 @@ class Scene extends Component {
const tX = Math.floor(x / (8 * zoomRatio));
const tY = Math.floor(y / (8 * zoomRatio));
+ if (tX !== this.lastTX || tY !== this.lastTY) {
if (creating) {
if (tool === "collisions") {
if (this.remove) {
@@ -73,7 +74,7 @@ class Scene extends Component {
let actor = this.actorAt(tX, tY);
- this.props.setStatus({
+ this.setStatus({
sceneName: scene.name,
x: tX,
y: tY,
@@ -85,8 +86,16 @@ class Scene extends Component {
hoverX: tX,
hoverY: tY
});
+
+ this.lastTX = tX;
+ this.lastTY = tY;
+ }
};
+ setStatus = throttle((options) => {
+ this.props.setStatus(options);
+ }, 200)
+
onMouseDown = e => {
const { id, tool, scene, width, showCollisions } = this.props;
const { hoverX, hoverY } = this.state;
