Skip to content
Browse files

update minified version (refactored, sandboxed code better)

  • Loading branch information...
1 parent 2377313 commit 3301d9a841f460e147d6daa8011d437a74bff3b2 @davidcalhoun davidcalhoun committed
Showing with 3 additions and 2 deletions.
  1. +3 −2 touche-min.js
View
5 touche-min.js
@@ -1,2 +1,3 @@
-if(!("ontouchstart"in window)){var d=!1,e=null,g=function(c,a){var h=e||a.target,b=document.createEvent("MouseEvent");b.initMouseEvent(c,!0,!0,window,a.detail,a.screenX,a.screenY,a.clientX,a.clientY,a.ctrlKey,a.shiftKey,a.altKey,a.metaKey,a.button,a.relatedTarget);var f=[{identifier:(new Date).getTime(),pageX:a.pageX,pageY:a.pageY,clientX:a.clientX,clientY:a.clientY,target:h,screenX:a.screenX,screenY:a.screenY}];switch(c){case "touchstart":e=h;b.touches=b.targetTouches=f;break;case "touchmove":b.touches=
-b.changedTouches=b.targetTouches=f;break;case "touchend":e=null,b.changedTouches=b.targetTouches=f}a.target.dispatchEvent(b)},i=function(c){d=!0;g("touchstart",c)},j=function(c){d&&g("touchmove",c)},k=function(c){d=!1;g("touchend",c)};document.addEventListener("mousedown",i,!1);document.addEventListener("mousemove",j,!1);document.addEventListener("mouseup",k,!1);window.ontouchstart=i;window.ontouchmove=j;window.ontouchend=k};
+// Touché: bringing touch events to non-touch browsers https://github.com/davidcalhoun/touche
+(function(){if(!("ontouchstart"in window)){var f=!1,g,c,h,i,j;c=function(d,a){var c,b,e;c=g||a.target;b=document.createEvent("MouseEvent");b.initMouseEvent(d,!0,!0,window,a.detail,a.screenX,a.screenY,a.clientX,a.clientY,a.ctrlKey,a.shiftKey,a.altKey,a.metaKey,a.button,a.relatedTarget);e=[{identifier:(new Date).getTime(),pageX:a.pageX,pageY:a.pageY,clientX:a.clientX,clientY:a.clientY,target:c,screenX:a.screenX,screenY:a.screenY}];switch(d){case "touchstart":g=c;b.touches=b.targetTouches=e;break;case "touchmove":b.touches=
+b.changedTouches=b.targetTouches=e;break;case "touchend":g=null,b.changedTouches=b.targetTouches=e}a.target.dispatchEvent(b)};h=function(d){f=!0;c("touchstart",d)};i=function(d){f&&c("touchmove",d)};j=function(d){f=!1;c("touchend",d)};document.addEventListener("mousedown",h,!1);document.addEventListener("mousemove",i,!1);document.addEventListener("mouseup",j,!1);window.ontouchstart=h;window.ontouchmove=i;window.ontouchend=j}})();

0 comments on commit 3301d9a

Please sign in to comment.
Something went wrong with that request. Please try again.