Skip to content

Commit de1f2f7

Browse files
committed
Add and use Interaction#interacting method
1 parent 0c7369c commit de1f2f7

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

interact.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@
898898
for (var i = 0, len = interactions.length; i < len; i++) {
899899
var interaction = interactions[i],
900900
otherAction = /resize/.test(interaction.prepared)? 'resize': interaction.prepared,
901-
active = interaction.dragging || interaction.resizing || interaction.gesturing;
901+
active = interaction.interacting();
902902

903903
if (!active) { continue; }
904904

@@ -1301,7 +1301,7 @@
13011301
listeners.pointerHover);
13021302
}
13031303

1304-
if (this.target && this.target.options.styleCursor && !(this.dragging || this.resizing || this.gesturing)) {
1304+
if (this.target && this.target.options.styleCursor && !this.interacting()) {
13051305
document.documentElement.style.cursor = '';
13061306
}
13071307
},
@@ -1335,7 +1335,7 @@
13351335
}
13361336

13371337
// do nothing if interacting
1338-
if (this.dragging || this.resizing || this.gesturing) {
1338+
if (this.interacting()) {
13391339
return;
13401340
}
13411341

@@ -1426,7 +1426,7 @@
14261426
var target = this.target,
14271427
options = target && target.options;
14281428

1429-
if (target && !(this.dragging || this.resizing || this.gesturing)) {
1429+
if (target && !this.interacting()) {
14301430
action = action || validateAction(forceAction || target.getAction(pointer, this), target, this.element);
14311431

14321432
this.setEventXY(this.startCoords);
@@ -1511,7 +1511,7 @@
15111511
&& (!this.inertiaStatus.active || (pointer instanceof InteractEvent && /inertiastart/.test(pointer.type)))) {
15121512

15131513
// if just starting an action, calculate the pointer speed now
1514-
if (!(this.dragging || this.resizing || this.gesturing)) {
1514+
if (!this.interacting()) {
15151515
setEventDeltas(this.pointerDelta, this.prevCoords, this.curCoords);
15161516

15171517
// check if a drag is in the correct axis
@@ -1589,7 +1589,7 @@
15891589
}
15901590
}
15911591

1592-
var starting = !!this.prepared && !(this.dragging || this.resizing || this.gesturing);
1592+
var starting = !!this.prepared && !this.interacting();
15931593

15941594
if (starting && !withinInteractionLimit(this.target, this.element, this.prepared)) {
15951595
this.stop();
@@ -1787,7 +1787,7 @@
17871787
inertiaOptions = options && options.inertia,
17881788
inertiaStatus = this.inertiaStatus;
17891789

1790-
if (this.dragging || this.resizing || this.gesturing) {
1790+
if (this.interacting()) {
17911791

17921792
if (inertiaStatus.active) { return; }
17931793

@@ -2149,6 +2149,10 @@
21492149
return (this.dragging && 'drag') || (this.resizing && 'resize') || (this.gesturing && 'gesture') || null;
21502150
},
21512151

2152+
interacting: function () {
2153+
return this.dragging || this.resizing || this.gesturing;
2154+
},
2155+
21522156
clearTargets: function () {
21532157
if (this.target && !this.target.selector) {
21542158
this.target = this.element = null;
@@ -2158,7 +2162,7 @@
21582162
},
21592163

21602164
stop: function (event) {
2161-
if (this.dragging || this.resizing || this.gesturing) {
2165+
if (this.interacting()) {
21622166
autoScroll.stop();
21632167
this.matches = [];
21642168
this.matchElements = [];
@@ -2766,7 +2770,7 @@
27662770
interaction = interactions[i];
27672771

27682772
if ((!interaction.prepared || (interaction.target.gesturable()))
2769-
&& !(interaction.dragging || interaction.resizing || interaction.gesturing)
2773+
&& !interaction.interacting()
27702774
&& !(!mouseEvent && interaction.mouse)) {
27712775

27722776
interaction.addPointer(pointer);

0 commit comments

Comments
 (0)