-
Notifications
You must be signed in to change notification settings - Fork 21
/
TouchAction.js
74 lines (63 loc) · 1.56 KB
/
TouchAction.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* A GameAction that handles Touch events
* @name TouchAction
* @constructor TouchAction
* @extends {GameAction}
*/
const GameAction = require('./GameAction');
class TouchAction extends GameAction {
constructor(options = {}){
super(options);
/**
* Array of positions where touchstart happened
* @type {Array}
* @memberOf TouchAction#
* @default
*/
this.startPositions = null;
/**
* Array of positions where touchend happened
* @type {Array}
* @memberOf TouchAction#
* @default
*/
this.endPositions = null;
/**
* Array of positions where touchmove happened
* @type {Array}
* @memberOf TouchAction#
* @default
*/
this.positions = null;
/**
* Wether any of the touch actions originated inside the canvas
* @type {Boolean}
* @memberOf TouchAction#
* @default
*/
this.insideCanvas = null;
Object.assign(this, options);
}
/**
* Signals that the touch was initiated.
* @function
* @memberOf TouchAction#
* @param {Array} startPositions Array of points where touch was pressed
*/
press(startPositions){
this.startPositions = startPositions;
this.positions = startPositions;
super.press(startPositions);
}
/**
* Signals that the touch was released
* @function
* @memberOf TouchAction#
* @param {Array} endPositions Array of points where touch was released
*/
release(endPositions){
this.endPositions = endPositions;
super.release(endPositions);
}
}
module.exports = TouchAction;