Skip to content

Commit caf9728

Browse files
committed
chore(GestureResponder): lint baked-in dependency
1 parent e36a35e commit caf9728

File tree

4 files changed

+303
-308
lines changed

4 files changed

+303
-308
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
'use strict';
22

3-
export function distance(touchTrackA, touchTrackB, ofCurrent) {
4-
let xa, ya, xb, yb;
5-
if(ofCurrent) {
6-
xa = touchTrackA.currentPageX;
7-
ya = touchTrackA.currentPageY;
8-
xb = touchTrackB.currentPageX;
9-
yb = touchTrackB.currentPageY;
10-
} else {
11-
xa = touchTrackA.previousPageX;
12-
ya = touchTrackA.previousPageY;
13-
xb = touchTrackB.previousPageX;
14-
yb = touchTrackB.previousPageY;
15-
}
16-
return Math.sqrt(Math.pow(xa - xb, 2) + Math.pow(ya - yb, 2));
3+
export function distance (touchTrackA, touchTrackB, ofCurrent) {
4+
let xa, ya, xb, yb;
5+
if (ofCurrent) {
6+
xa = touchTrackA.currentPageX;
7+
ya = touchTrackA.currentPageY;
8+
xb = touchTrackB.currentPageX;
9+
yb = touchTrackB.currentPageY;
10+
} else {
11+
xa = touchTrackA.previousPageX;
12+
ya = touchTrackA.previousPageY;
13+
xb = touchTrackB.previousPageX;
14+
yb = touchTrackB.previousPageY;
15+
}
16+
return Math.sqrt(Math.pow(xa - xb, 2) + Math.pow(ya - yb, 2));
1717
}
1818

19-
export function maxDistance(touchBank, ofCurrent) {
20-
let max = 0;
21-
for(let i = 0; i < touchBank.length - 1; i++) {
22-
for(let j = i+1; j < touchBank.length; j++) {
23-
let d = distance(touchBank[i], touchBank[j], ofCurrent);
24-
if(d > max) {
25-
max = d;
26-
}
19+
export function maxDistance (touchBank, ofCurrent) {
20+
let max = 0;
21+
for (let i = 0; i < touchBank.length - 1; i++) {
22+
for (let j = i + 1; j < touchBank.length; j++) {
23+
let d = distance(touchBank[i], touchBank[j], ofCurrent);
24+
if (d > max) {
25+
max = d;
26+
}
27+
}
2728
}
28-
}
29-
return max;
29+
return max;
3030
}
3131

32-
export function pinchDistance(touchHistory, touchesChangedAfter, ofCurrent) {
33-
let touchBank = touchHistory.touchBank;
34-
if(touchHistory.numberActiveTouches > 1) {
35-
let filteredTouchBank = touchBank.filter((touchTrack) => {
36-
return touchTrack && touchTrack.currentTimeStamp >= touchesChangedAfter;
37-
});
38-
return maxDistance(filteredTouchBank, ofCurrent);
39-
}
40-
}
32+
export function pinchDistance (touchHistory, touchesChangedAfter, ofCurrent) {
33+
let touchBank = touchHistory.touchBank;
34+
if (touchHistory.numberActiveTouches > 1) {
35+
let filteredTouchBank = touchBank.filter((touchTrack) => {
36+
return touchTrack && touchTrack.currentTimeStamp >= touchesChangedAfter;
37+
});
38+
return maxDistance(filteredTouchBank, ofCurrent);
39+
}
40+
}

src/libraries/GestureResponder/TouchHistoryMath.js

+50-50
Original file line numberDiff line numberDiff line change
@@ -21,79 +21,79 @@ var TouchHistoryMath = {
2121
* touches vs. previous centroid of now actively moving touches.
2222
* @return {number} value of centroid in specified dimension.
2323
*/
24-
centroidDimension: function (touchHistory, touchesChangedAfter, isXAxis, ofCurrent) {
25-
var touchBank = touchHistory.touchBank;
26-
var total = 0;
27-
var count = 0;
24+
centroidDimension: function (touchHistory, touchesChangedAfter, isXAxis, ofCurrent) {
25+
var touchBank = touchHistory.touchBank;
26+
var total = 0;
27+
var count = 0;
2828

29-
var oneTouchData = touchHistory.numberActiveTouches === 1 ? touchHistory.touchBank[touchHistory.indexOfSingleActiveTouch] : null;
29+
var oneTouchData = touchHistory.numberActiveTouches === 1 ? touchHistory.touchBank[touchHistory.indexOfSingleActiveTouch] : null;
3030

31-
if (oneTouchData !== null) {
32-
if (oneTouchData.touchActive && oneTouchData.currentTimeStamp > touchesChangedAfter) {
33-
total += ofCurrent && isXAxis ? oneTouchData.currentPageX : ofCurrent && !isXAxis ? oneTouchData.currentPageY : !ofCurrent && isXAxis ? oneTouchData.previousPageX : oneTouchData.previousPageY;
34-
count = 1;
35-
}
36-
} else {
37-
for (var i = 0; i < touchBank.length; i++) {
38-
var touchTrack = touchBank[i];
39-
if (touchTrack !== null && touchTrack !== undefined && touchTrack.touchActive && touchTrack.currentTimeStamp >= touchesChangedAfter) {
40-
var toAdd; // Yuck, program temporarily in invalid state.
41-
if (ofCurrent && isXAxis) {
42-
toAdd = touchTrack.currentPageX;
43-
} else if (ofCurrent && !isXAxis) {
44-
toAdd = touchTrack.currentPageY;
45-
} else if (!ofCurrent && isXAxis) {
46-
toAdd = touchTrack.previousPageX;
47-
} else {
48-
toAdd = touchTrack.previousPageY;
49-
}
50-
total += toAdd;
51-
count++;
31+
if (oneTouchData !== null) {
32+
if (oneTouchData.touchActive && oneTouchData.currentTimeStamp > touchesChangedAfter) {
33+
total += ofCurrent && isXAxis ? oneTouchData.currentPageX : ofCurrent && !isXAxis ? oneTouchData.currentPageY : !ofCurrent && isXAxis ? oneTouchData.previousPageX : oneTouchData.previousPageY;
34+
count = 1;
35+
}
36+
} else {
37+
for (var i = 0; i < touchBank.length; i++) {
38+
var touchTrack = touchBank[i];
39+
if (touchTrack !== null && touchTrack !== undefined && touchTrack.touchActive && touchTrack.currentTimeStamp >= touchesChangedAfter) {
40+
var toAdd; // Yuck, program temporarily in invalid state.
41+
if (ofCurrent && isXAxis) {
42+
toAdd = touchTrack.currentPageX;
43+
} else if (ofCurrent && !isXAxis) {
44+
toAdd = touchTrack.currentPageY;
45+
} else if (!ofCurrent && isXAxis) {
46+
toAdd = touchTrack.previousPageX;
47+
} else {
48+
toAdd = touchTrack.previousPageY;
49+
}
50+
total += toAdd;
51+
count++;
52+
}
53+
}
5254
}
53-
}
54-
}
55-
return count > 0 ? total / count : TouchHistoryMath.noCentroid;
56-
},
55+
return count > 0 ? total / count : TouchHistoryMath.noCentroid;
56+
},
5757

58-
currentCentroidXOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
59-
return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, true, // isXAxis
58+
currentCentroidXOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
59+
return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, true, // isXAxis
6060
true // ofCurrent
6161
);
62-
},
62+
},
6363

64-
currentCentroidYOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
65-
return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, false, // isXAxis
64+
currentCentroidYOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
65+
return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, false, // isXAxis
6666
true // ofCurrent
6767
);
68-
},
68+
},
6969

70-
previousCentroidXOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
71-
return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, true, // isXAxis
70+
previousCentroidXOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
71+
return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, true, // isXAxis
7272
false // ofCurrent
7373
);
74-
},
74+
},
7575

76-
previousCentroidYOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
77-
return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, false, // isXAxis
76+
previousCentroidYOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
77+
return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, false, // isXAxis
7878
false // ofCurrent
7979
);
80-
},
80+
},
8181

82-
currentCentroidX: function (touchHistory) {
83-
return TouchHistoryMath.centroidDimension(touchHistory, 0, // touchesChangedAfter
82+
currentCentroidX: function (touchHistory) {
83+
return TouchHistoryMath.centroidDimension(touchHistory, 0, // touchesChangedAfter
8484
true, // isXAxis
8585
true // ofCurrent
8686
);
87-
},
87+
},
8888

89-
currentCentroidY: function (touchHistory) {
90-
return TouchHistoryMath.centroidDimension(touchHistory, 0, // touchesChangedAfter
89+
currentCentroidY: function (touchHistory) {
90+
return TouchHistoryMath.centroidDimension(touchHistory, 0, // touchesChangedAfter
9191
false, // isXAxis
9292
true // ofCurrent
9393
);
94-
},
94+
},
9595

96-
noCentroid: -1
96+
noCentroid: -1
9797
};
9898

99-
module.exports = TouchHistoryMath;
99+
module.exports = TouchHistoryMath;

0 commit comments

Comments
 (0)