Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #55 #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion dist/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@
return e;
};

utils.isPc = function () {
var uaInfo = navigator.userAgent;
var agents = ["Android", "iPhone", "Windows Phone", "iPad", "iPod"];
var flag = true;
for (var i = 0; i < agents.length; i++) {
if (uaInfo.indexOf(agents[i]) > 0) {
flag = false;
break;
}
}
return flag;
};

var eventMatrix = [{
// Touchable devices
test: ('propertyIsEnumerable' in window || 'hasOwnProperty' in document) && (window.propertyIsEnumerable('ontouchstart') || document.hasOwnProperty('ontouchstart') || window.hasOwnProperty('ontouchstart')),
Expand Down Expand Up @@ -127,6 +140,9 @@
init = function() {
var i = 0;

if(utils.isPc()) {
return utils.attachEvent(document.documentElement, 'click', handlers.click);
}
for (; i < eventMatrix.length; i++) {
if (eventMatrix[i].test) {
deviceEvents = eventMatrix[i].events;
Expand All @@ -139,7 +155,6 @@
}
}

return utils.attachEvent(document.documentElement, 'click', handlers.click);
};

utils.attachEvent(window, 'load', init);
Expand Down
2 changes: 1 addition & 1 deletion dist/tap.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
init = function() {
var i = 0;

if(utils.isPc()) {
return utils.attachEvent(document.documentElement, 'click', handlers.click);
}
for (; i < eventMatrix.length; i++) {
if (eventMatrix[i].test) {
deviceEvents = eventMatrix[i].events;
Expand All @@ -75,7 +78,6 @@
}
}

return utils.attachEvent(document.documentElement, 'click', handlers.click);
};

utils.attachEvent(window, 'load', init);
Expand Down
13 changes: 13 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,16 @@

return e;
};

utils.isPc = function () {
var uaInfo = navigator.userAgent;
var agents = ["Android", "iPhone", "Windows Phone", "iPad", "iPod"];
var flag = true;
for (var i = 0; i < agents.length; i++) {
if (uaInfo.indexOf(agents[i]) > 0) {
flag = false;
break;
}
}
return flag;
};