-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtouch.js
More file actions
60 lines (48 loc) · 1.37 KB
/
Copy pathtouch.js
File metadata and controls
60 lines (48 loc) · 1.37 KB
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
var Touch = {
touch : false,
X : 0,
Y : 0,
oldX : 0,
oldY : 0,
delX : 0,
delY : 0
};
var ontouchstartCallback = undefined;
var setOntouchstartCallback = function(f){
ontouchstartCallback = f;
};
$(document).on("touchstart",function(e){
Touch.touch = true;
Touch.X = Math.round(e.targetTouches[0].pageX) - e.target.getBoundingClientRect().left;
Touch.Y = Math.round(e.targetTouches[0].pageY) - e.target.getBoundingClientRect().top;
if(ontouchstartCallback != undefined)
ontouchstartCallback(e);
});
var ontouchendCallback = undefined;
var setOntouchendCallback = function(f){
ontouchendCallback = f;
};
$(document).on("touchend",function(e){
Touch.touch = false;
if(ontouchendCallback != undefined)
ontouchendCallback(e);
});
var ontouchmoveCallback = undefined;
var setOntouchmoveCallback = function(f){
ontouchmoveCallback = f;
};
$(document).on("touchmove",function(e){
Touch.X = Math.round(e.targetTouches[0].pageX) - e.target.getBoundingClientRect().left;
Touch.Y = Math.round(e.targetTouches[0].pageY) - e.target.getBoundingClientRect().top;
if(ontouchmoveCallback != undefined)
ontouchmoveCallback(e);
});
var ontouchcancelCallback = undefined;
var setOntouchcancelCallback = function(f){
ontouchcancelCallback = f;
};
$(document).on("touchcancel",function(e){
Touch.touch = false;
if(ontouchcancelCallback != undefined)
ontouchcancelCallback(e);
});