Skip to content

Commit 3489ee1

Browse files
committed
Interaction: add redoMove method
interact(target).on('dragmove', function (event) { if (someCondition) { // change the snap settings event.interactable.draggable({ snap: { targets: [] }}); // fire another move event with re-calculated snap event.interaction.redoMove(); } }) Close #151
1 parent 531461f commit 3489ee1

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/Interaction.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,37 @@ class Interaction {
359359
}
360360
}
361361

362+
/*\
363+
* Interaction.redoMove
364+
[ method ]
365+
*
366+
* Force a move of the current action at the same coordinates. Useful if
367+
* snap/restrict has been changed and you want a movement with the new
368+
* settings.
369+
*
370+
**
371+
| interact(target)
372+
| .draggable(true)
373+
| .on('dragmove', function (event) {
374+
| if (someCondition) {
375+
| // change the snap settings
376+
| event.interactable.draggable({ snap: { targets: [] }});
377+
| // fire another move event with re-calculated snap
378+
| event.interaction.redoMove();
379+
| }
380+
| });
381+
\*/
382+
redoMove () {
383+
modifiers.setAll(this, this.curCoords.page, this.modifierStatuses);
384+
385+
Interaction.signals.fire('move-' + this.prepared.name, {
386+
pointer: this.pointers[0],
387+
event: this.prevEvent,
388+
eventTarget: this._eventTarget,
389+
interaction: this,
390+
});
391+
}
392+
362393
pointerUp (pointer, event, eventTarget, curEventTarget) {
363394
const pointerIndex = this.mouse? 0 : utils.indexOf(this.pointerIds, utils.getPointerId(pointer));
364395

0 commit comments

Comments
 (0)