-
-
Save motoishmz/5215227 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// to be binded..... | |
var fnTouchStart = function(e) { console.log("hello i am touch start"); }; | |
var fnTouchMove = function(e) { console.log("hello i am touch move"); }; | |
var fnTouchEnd = function(e) { console.log("hello i am touch end"); }; | |
var fnMouseDown = function(e) { console.log("hello i am mouse down"); }; | |
var fnMouseMove = function(e) { console.log("hello i am mouse move"); }; | |
var fnMouseUp = function(e) { console.log("hello i am mouse up"); }; | |
// register..... | |
(function() | |
{ | |
var bMobileDevice; | |
var UA = navigator.userAgent; | |
// check whether the device is mobile or not.... | |
bMobileDevice = | |
/iphone/i.test(UA) || | |
/ipad/i.test(UA) || | |
/ipod/i.test(UA) || | |
/android/i.test(UA); | |
// bind.... | |
if(bMobileDevice) | |
{ | |
document.addEventListener("touchStart", fnTouchStart); | |
document.addEventListener("touchmove", fnTouchMove); | |
document.addEventListener("touchend", fnTouchEnd); | |
} | |
else | |
{ | |
document.addEventListener("mousedown", fnMouseDown); | |
document.addEventListener("mousemove", fnMouseMove); | |
document.addEventListener("mouseup", fnMouseUp); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment