Skip to content

Commit

Permalink
Merge pull request #5 from waterbearlang/4_support_touch_and_mouse
Browse files Browse the repository at this point in the history
4 support touch and mouse
  • Loading branch information
kylepaulsen committed Mar 22, 2015
2 parents 88a66e2 + 5ef79d5 commit 5acbf5f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions nanomodal.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ function El(tag, classNames) {
};

var addClickListener = function(handler) {
if ("ontouchend" in document.documentElement) {
addListener("touchstart", handler);
} else {
addListener("click", handler);
var flag = false;
var wrappedHandler = function(evt){
if (!flag){
flag = true;
setTimeout(function(){ flag = false; }, 100);
handler(evt);
}
}
addListener("touchstart", wrappedHandler);
addListener("mousedown", wrappedHandler);
};

var show = function(arg) {
Expand Down Expand Up @@ -371,7 +376,7 @@ var ModalEvent = require("./ModalEvent");

var nanoModalAPI = (function() {



var El = require("./El");
var Modal = require("./Modal");
Expand Down

0 comments on commit 5acbf5f

Please sign in to comment.