@@ -21,79 +21,79 @@ var TouchHistoryMath = {
21
21
* touches vs. previous centroid of now actively moving touches.
22
22
* @return {number } value of centroid in specified dimension.
23
23
*/
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 ;
28
28
29
- var oneTouchData = touchHistory . numberActiveTouches === 1 ? touchHistory . touchBank [ touchHistory . indexOfSingleActiveTouch ] : null ;
29
+ var oneTouchData = touchHistory . numberActiveTouches === 1 ? touchHistory . touchBank [ touchHistory . indexOfSingleActiveTouch ] : null ;
30
30
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
+ }
52
54
}
53
- }
54
- }
55
- return count > 0 ? total / count : TouchHistoryMath . noCentroid ;
56
- } ,
55
+ return count > 0 ? total / count : TouchHistoryMath . noCentroid ;
56
+ } ,
57
57
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
60
60
true // ofCurrent
61
61
) ;
62
- } ,
62
+ } ,
63
63
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
66
66
true // ofCurrent
67
67
) ;
68
- } ,
68
+ } ,
69
69
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
72
72
false // ofCurrent
73
73
) ;
74
- } ,
74
+ } ,
75
75
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
78
78
false // ofCurrent
79
79
) ;
80
- } ,
80
+ } ,
81
81
82
- currentCentroidX : function ( touchHistory ) {
83
- return TouchHistoryMath . centroidDimension ( touchHistory , 0 , // touchesChangedAfter
82
+ currentCentroidX : function ( touchHistory ) {
83
+ return TouchHistoryMath . centroidDimension ( touchHistory , 0 , // touchesChangedAfter
84
84
true , // isXAxis
85
85
true // ofCurrent
86
86
) ;
87
- } ,
87
+ } ,
88
88
89
- currentCentroidY : function ( touchHistory ) {
90
- return TouchHistoryMath . centroidDimension ( touchHistory , 0 , // touchesChangedAfter
89
+ currentCentroidY : function ( touchHistory ) {
90
+ return TouchHistoryMath . centroidDimension ( touchHistory , 0 , // touchesChangedAfter
91
91
false , // isXAxis
92
92
true // ofCurrent
93
93
) ;
94
- } ,
94
+ } ,
95
95
96
- noCentroid : - 1
96
+ noCentroid : - 1
97
97
} ;
98
98
99
- module . exports = TouchHistoryMath ;
99
+ module . exports = TouchHistoryMath ;
0 commit comments