Difference between revisions of "User:Moussekateer/vector.js"
Moussekateer (talk | contribs) m |
Moussekateer (talk | contribs) m |
||
Line 43: | Line 43: | ||
} | } | ||
− | $( | + | $('.viewer-3d').bind('touchstart touchmove touchend touchcancel', function(event) { |
− | + | touchHandler(event); | |
}); | }); |
Revision as of 05:11, 16 June 2013
importScriptURI('https://raw.github.com/Moussekateer/TFWiki-scripts/master/spambot_killer.js', 'text/javascript'); importScriptURI('https://raw.github.com/Moussekateer/TFWiki-scripts/master/wikifi_toolbox.js', 'text/javascript'); // hai var clickms = 250; var lastTouchDown = -1; // /hai function touchHandler(event) { var touch = event.changedTouches[0]; // hai var d = new Date(); switch(event.type) { case "touchstart": type = "mousedown"; lastTouchDown = d.getTime(); break; case "touchmove": type="mousemove"; lastTouchDown = -1; break; case "touchend": if(lastTouchDown > -1 && (d.getTime() - lastTouchDown) < clickms){lastTouchDown = -1; type="click"; break;} type="mouseup"; break; default: return; } // /hai var simulatedEvent = document.createEvent("MouseEvent"); simulatedEvent.initMouseEvent(type, true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null); touch.target.dispatchEvent(simulatedEvent); event.preventDefault(); } function touchinit() { $('.viewer-3d').addEventListener("touchstart", touchHandler, true); $('.viewer-3d').addEventListener("touchmove", touchHandler, true); $('.viewer-3d').addEventListener("touchend", touchHandler, true); $('.viewer-3d').addEventListener("touchcancel", touchHandler, true); } $('.viewer-3d').bind('touchstart touchmove touchend touchcancel', function(event) { touchHandler(event); });