123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- function touchHandler(event) {
- event.stopPropagation();
- var touches = event.changedTouches,
- first = touches[0],
- type = "";
- switch (event.type) {
- case "touchstart": type = "mousedown"; break;
- case "touchmove": type = "mousemove"; break;
- case "touchend": type = "mouseup"; break;
- default: return;
- }
- var simulatedEvent = new MouseEvent(type, { "altKey": false, "button": 0, "buttons": 0, "clientX": first.clientX, "clientY": first.clientY, "ctrlKey": false, "metaKey": false, "relatedTarget": first, "screenX": first.screenX, "screenY": first.screenY, "shiftKey": false });
-
-
-
-
-
- first.target.dispatchEvent(simulatedEvent);
- }
- function init() {
- document.addEventListener("touchstart", touchHandler, true);
- document.addEventListener("touchmove", touchHandler, true);
- document.addEventListener("touchend", touchHandler, true);
- document.addEventListener("touchcancel", touchHandler, true);
- HTMLElement.prototype.__defineGetter__("ondblclick", function () {
- return this.doubleTap;
- });
- HTMLElement.prototype.__defineSetter__("ondblclick", function (fun) {
- this.doubleTap = fun;
- $(this).on("doubleTap", fun)
- });
- var eventlstener = HTMLElement.prototype.addEventListener;
- HTMLElement.prototype.addEventListener = function (type, fun, op) {
- if (type == "click") {
- eventlstener.call(this, type, function (e) {
- if (!this.startTime) {
- this.startTime = new Date().getTime();
- fun.call(this);
- }
- else {
- const time = new Date().getTime() - this.startTime;
- this.startTime = new Date().getTime();
- if (time > 200) {
- fun.call(this);
- }
- else {
- e.detail = 2;
- fun.call(this);
- }
- }
- }, op);
- }
- else {
- eventlstener.apply(this, arguments);
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
|