|
|
@ -5,14 +5,19 @@ |
|
|
|
/* jshint bitwise: false */ |
|
|
|
/* jshint bitwise: false */ |
|
|
|
/* global GLOBAL: true */ |
|
|
|
/* global GLOBAL: true */ |
|
|
|
|
|
|
|
|
|
|
|
function FingerBlast(element) { |
|
|
|
(function () { |
|
|
|
|
|
|
|
|
|
|
|
'use strict'; |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function FingerBlast(element) { |
|
|
|
this.element = typeof element === 'string' ? document.querySelector(element) : element; |
|
|
|
this.element = typeof element === 'string' ? document.querySelector(element) : element; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.element) { |
|
|
|
this.listen(); |
|
|
|
this.listen(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FingerBlast.prototype = { |
|
|
|
FingerBlast.prototype = { |
|
|
|
x: NaN, |
|
|
|
x: NaN, |
|
|
|
y: NaN, |
|
|
|
y: NaN, |
|
|
|
|
|
|
|
|
|
|
@ -22,8 +27,6 @@ FingerBlast.prototype = { |
|
|
|
mouseIsDown: false, |
|
|
|
mouseIsDown: false, |
|
|
|
|
|
|
|
|
|
|
|
listen: function () { |
|
|
|
listen: function () { |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var activate = this.activate.bind(this); |
|
|
|
var activate = this.activate.bind(this); |
|
|
|
var deactivate = this.deactivate.bind(this); |
|
|
|
var deactivate = this.deactivate.bind(this); |
|
|
|
|
|
|
|
|
|
|
@ -59,8 +62,6 @@ FingerBlast.prototype = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
activate: function () { |
|
|
|
activate: function () { |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.active) { |
|
|
|
if (this.active) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -72,8 +73,6 @@ FingerBlast.prototype = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
deactivate: function (e) { |
|
|
|
deactivate: function (e) { |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.active = false; |
|
|
|
this.active = false; |
|
|
|
if (this.mouseIsDown) { |
|
|
|
if (this.mouseIsDown) { |
|
|
|
this.touchEnd(e); |
|
|
|
this.touchEnd(e); |
|
|
@ -85,8 +84,6 @@ FingerBlast.prototype = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
click: function (e) { |
|
|
|
click: function (e) { |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (e.synthetic) { |
|
|
|
if (e.synthetic) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -95,8 +92,6 @@ FingerBlast.prototype = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
touchStart: function (e) { |
|
|
|
touchStart: function (e) { |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (e.synthetic || /input|textarea/.test(e.target.tagName.toLowerCase())) { |
|
|
|
if (e.synthetic || /input|textarea/.test(e.target.tagName.toLowerCase())) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -110,8 +105,6 @@ FingerBlast.prototype = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
touchMove: function (e) { |
|
|
|
touchMove: function (e) { |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (e.synthetic) { |
|
|
|
if (e.synthetic) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -127,8 +120,6 @@ FingerBlast.prototype = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
touchEnd: function (e) { |
|
|
|
touchEnd: function (e) { |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (e.synthetic) { |
|
|
|
if (e.synthetic) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -151,8 +142,6 @@ FingerBlast.prototype = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
fireTouchEvents: function (eventName, originalEvent) { |
|
|
|
fireTouchEvents: function (eventName, originalEvent) { |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var events = []; |
|
|
|
var events = []; |
|
|
|
var gestures = []; |
|
|
|
var gestures = []; |
|
|
|
|
|
|
|
|
|
|
@ -235,8 +224,6 @@ FingerBlast.prototype = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
createMouseEvent: function (eventName, originalEvent) { |
|
|
|
createMouseEvent: function (eventName, originalEvent) { |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var e = document.createEvent('MouseEvent'); |
|
|
|
var e = document.createEvent('MouseEvent'); |
|
|
|
|
|
|
|
|
|
|
|
e.initMouseEvent(eventName, true, true, |
|
|
|
e.initMouseEvent(eventName, true, true, |
|
|
@ -255,8 +242,6 @@ FingerBlast.prototype = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
move: function (x, y) { |
|
|
|
move: function (x, y) { |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isNaN(x) || isNaN(y)) { |
|
|
|
if (isNaN(x) || isNaN(y)) { |
|
|
|
this.target = null; |
|
|
|
this.target = null; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -268,4 +253,8 @@ FingerBlast.prototype = { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.FingerBlast = FingerBlast; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}()); |
|
|
|