Skip to content

Commit

Permalink
fix: snap to grid immediately (#7745)
Browse files Browse the repository at this point in the history
  • Loading branch information
BeksOmega committed Jan 23, 2024
1 parent b1ef6ae commit 2e1297e
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,23 +455,12 @@ export class BlockSvg

/** Snap this block to the nearest grid point. */
snapToGrid() {
if (this.isDeadOrDying()) {
return; // Deleted block.
}
if (this.workspace.isDragging()) {
return; // Don't bump blocks during a drag.
}

if (this.getParent()) {
return; // Only snap top-level blocks.
}
if (this.isInFlyout) {
return; // Don't move blocks around in a flyout.
}
if (this.isDeadOrDying()) return;
if (this.getParent()) return;
if (this.isInFlyout) return;
const grid = this.workspace.getGrid();
if (!grid || !grid.shouldSnap()) {
return; // Config says no snapping.
}
if (!grid || !grid.shouldSnap()) return;

const spacing = grid.getSpacing();
const half = spacing / 2;
const xy = this.getRelativeToSurfaceXY();
Expand Down Expand Up @@ -1530,15 +1519,7 @@ export class BlockSvg
* @internal
*/
scheduleSnapAndBump() {
// Ensure that any snap and bump are part of this move's event group.
const group = eventUtils.getGroup();

setTimeout(() => {
eventUtils.setGroup(group);
this.snapToGrid();
eventUtils.setGroup(false);
}, config.bumpDelay / 2);

this.snapToGrid();
this.bumpNeighbours();
}

Expand Down

0 comments on commit 2e1297e

Please sign in to comment.