Skip to content

Commit

Permalink
issue pukhalski#55
Browse files Browse the repository at this point in the history
  • Loading branch information
langlangxu committed Aug 30, 2018
1 parent 6c4dc01 commit efbc0b1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
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;
};

0 comments on commit efbc0b1

Please sign in to comment.