Skip to content

Commit 8cc50c1

Browse files
committed
Fix snap & restrict inaccuracy of first move event
1 parent 2634996 commit 8cc50c1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

interact.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,9 +1626,7 @@
16261626
if (this.prepared && this.target) {
16271627
var target = this.target,
16281628
shouldSnap = checkSnap(target, this.prepared) && (!target.options.snap.endOnly || preEnd),
1629-
shouldRestrict = checkRestrict(target, this.prepared) && (!target.options.restrict.endOnly || preEnd),
1630-
1631-
coords = starting? this.startCoords.page : this.curCoords.page;
1629+
shouldRestrict = checkRestrict(target, this.prepared) && (!target.options.restrict.endOnly || preEnd);
16321630

16331631
if (starting) {
16341632
var rect = target.getRect(this.element),
@@ -1666,8 +1664,10 @@
16661664
}
16671665
}
16681666

1669-
if (shouldSnap ) { this.setSnapping (coords); } else { this.snapStatus .locked = false; }
1670-
if (shouldRestrict) { this.setRestriction(coords); } else { this.restrictStatus.restricted = false; }
1667+
var snapCoords = starting? this.startCoords.page : this.curCoords.page;
1668+
1669+
if (shouldSnap ) { this.setSnapping (snapCoords); } else { this.snapStatus .locked = false; }
1670+
if (shouldRestrict) { this.setRestriction(snapCoords); } else { this.restrictStatus.restricted = false; }
16711671

16721672
var shouldMove = (shouldSnap? (this.snapStatus.changed || !this.snapStatus.locked): true)
16731673
&& (shouldRestrict? (!this.restrictStatus.restricted || (this.restrictStatus.restricted && this.restrictStatus.changed)): true);
@@ -1695,9 +1695,11 @@
16951695
this.fireActiveDrops(dropEvents.activate);
16961696
}
16971697

1698+
snapCoords = this.curCoords.page;
1699+
16981700
// set snapping and restriction for the move event
1699-
if (shouldSnap ) { this.setSnapping (coords); }
1700-
if (shouldRestrict) { this.setRestriction(coords); }
1701+
if (shouldSnap ) { this.setSnapping (snapCoords); }
1702+
if (shouldRestrict) { this.setRestriction(snapCoords); }
17011703
}
17021704

17031705
this.prevEvent = this[action + 'Move'](event);

0 commit comments

Comments
 (0)