Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

touch.js.map 7.1KB

1
  1. {"version":3,"sources":["../../src/directives/touch.ts"],"names":[],"mappings":";;;;;;;;AAqCA,IAAM,gBAAgB,SAAhB,aAAgB,CAAC,OAAD,EAA0B;AAAA,QACtC,WADsC,GACa,OADb,CACtC,WADsC;AAAA,QACzB,SADyB,GACa,OADb,CACzB,SADyB;AAAA,QACd,WADc,GACa,OADb,CACd,WADc;AAAA,QACD,SADC,GACa,OADb,CACD,SADC;;AAE9C,QAAM,WAAW,GAAjB;AACA,QAAM,cAAc,EAApB;AACA,YAAQ,OAAR,GAAkB,YAAY,WAA9B;AACA,YAAQ,OAAR,GAAkB,YAAY,WAA9B;AAEA,QAAI,KAAK,GAAL,CAAS,QAAQ,OAAjB,IAA4B,WAAW,KAAK,GAAL,CAAS,QAAQ,OAAjB,CAA3C,EAAsE;AACpE,gBAAQ,IAAR,IAAiB,YAAY,cAAc,WAA3C,IAA2D,QAAQ,IAAR,CAAa,OAAb,CAA3D;AACA,gBAAQ,KAAR,IAAkB,YAAY,cAAc,WAA5C,IAA4D,QAAQ,KAAR,CAAc,OAAd,CAA5D;AACD;AAED,QAAI,KAAK,GAAL,CAAS,QAAQ,OAAjB,IAA4B,WAAW,KAAK,GAAL,CAAS,QAAQ,OAAjB,CAA3C,EAAsE;AACpE,gBAAQ,EAAR,IAAe,YAAY,cAAc,WAAzC,IAAyD,QAAQ,EAAR,CAAW,OAAX,CAAzD;AACA,gBAAQ,IAAR,IAAiB,YAAY,cAAc,WAA3C,IAA2D,QAAQ,IAAR,CAAa,OAAb,CAA3D;AACD;AACF,CAhBD;AAkBA,SAAS,WAAT,CAAqB,KAArB,EAAwC,OAAxC,EAA6D;AAC3D,QAAM,QAAQ,MAAM,cAAN,CAAqB,CAArB,CAAd;AACA,YAAQ,WAAR,GAAsB,MAAM,OAA5B;AACA,YAAQ,WAAR,GAAsB,MAAM,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SAFL;AAGL,mBAAW,mBAAC,CAAD;AAAA,mBAAmB,WAAU,CAAV,EAAa,OAAb,CAAnB;AAAA;AAHN,KAAP;AAKD;AAED,SAAS,QAAT,CAAmB,EAAnB,EAAoC,OAApC,EAAkE,KAAlE,EAA8E;AAC5E,QAAM,QAAQ,QAAQ,KAAtB;AACA,QAAM,SAAS,MAAM,MAAN,GAAe,GAAG,aAAlB,GAAkC,EAAjD;AACA,QAAM,UAAU,MAAM,OAAN,IAAiB,EAAE,SAAS,IAAX,EAAjC;AAEA;AACA,QAAI,CAAC,MAAL,EAAa;AAEb,QAAM,WAAW,eAAe,QAAQ,KAAvB,CAAjB;AACA,WAAO,cAAP,GAAwB,OAAO,OAAO,cAAd,CAAxB;AACA,WAAO,cAAP,CAAuB,MAAM,OAAN,CAAe,IAAtC,IAA8C,QAA9C;AAEA,uBAAK,QAAL,EAAe,OAAf,CAAuB,qBAAY;AACjC,eAAO,gBAAP,CAAwB,SAAxB,EAAmC,SAAS,SAAT,CAAnC,EAAyE,OAAzE;AACD,KAFD;AAGD;AAED,SAAS,MAAT,CAAiB,EAAjB,EAAkC,OAAlC,EAAgE,KAAhE,EAA4E;AAC1E,QAAM,SAAS,QAAQ,KAAR,CAAe,MAAf,GAAwB,GAAG,aAA3B,GAA2C,EAA1D;AACA,QAAI,CAAC,MAAD,IAAW,CAAC,OAAO,cAAvB,EAAuC;AAEvC,QAAM,WAAW,OAAO,cAAP,CAAsB,MAAM,OAAN,CAAe,IAArC,CAAjB;AACA,uBAAK,QAAL,EAAe,OAAf,CAAuB,qBAAY;AACjC,eAAO,mBAAP,CAA2B,SAA3B,EAAsC,SAAS,SAAT,CAAtC;AACD,KAFD;AAGA,WAAO,OAAO,cAAP,CAAsB,MAAM,OAAN,CAAe,IAArC,CAAP;AACD;kBAEc;AACb,sBADa;AAEb;AAFa,C","sourcesContent":["import { VNodeDirective, VNode } from 'vue/types/vnode'\nimport { keys } from '../util/helpers'\n\nexport interface TouchStoredHandlers {\n touchstart: (e: TouchEvent) => void\n touchend: (e: TouchEvent) => void\n touchmove: (e: TouchEvent) => void\n}\n\ninterface TouchHandlers {\n start?: (wrapperEvent: TouchEvent & TouchWrapper) => void\n end?: (wrapperEvent: TouchEvent & TouchWrapper) => void\n move?: (wrapperEvent: TouchEvent & TouchWrapper) => void\n left?: (wrapper: TouchWrapper) => void\n right?: (wrapper: TouchWrapper) => void\n up?: (wrapper: TouchWrapper) => void\n down?: (wrapper: TouchWrapper) => void\n}\n\nexport interface TouchWrapper extends TouchHandlers {\n touchstartX: number\n touchstartY: number\n touchmoveX: number\n touchmoveY: number\n touchendX: number\n touchendY: number\n offsetX: number\n offsetY: number\n}\n\ninterface TouchVNodeDirective extends VNodeDirective {\n value?: TouchHandlers & {\n parent?: boolean\n options?: AddEventListenerOptions\n }\n}\n\nconst handleGesture = (wrapper: TouchWrapper) => {\n const { touchstartX, touchendX, touchstartY, touchendY } = wrapper\n const dirRatio = 0.5\n const minDistance = 16\n wrapper.offsetX = touchendX - touchstartX\n wrapper.offsetY = touchendY - touchstartY\n\n if (Math.abs(wrapper.offsetY) < dirRatio * Math.abs(wrapper.offsetX)) {\n wrapper.left && (touchendX < touchstartX - minDistance) && wrapper.left(wrapper)\n wrapper.right && (touchendX > touchstartX + minDistance) && wrapper.right(wrapper)\n }\n\n if (Math.abs(wrapper.offsetX) < dirRatio * Math.abs(wrapper.offsetY)) {\n wrapper.up && (touchendY < touchstartY - minDistance) && wrapper.up(wrapper)\n wrapper.down && (touchendY > touchstartY + minDistance) && wrapper.down(wrapper)\n }\n}\n\nfunction touchstart (event: TouchEvent, wrapper: TouchWrapper) {\n const touch = event.changedTouches[0]\n wrapper.touchstartX = touch.clientX\n wrapper.touchstartY = touch.clientY\n\n wrapper.start &&\n wrapper.start(Object.assign(event, wrapper))\n}\n\nfunction touchend (event: TouchEvent, wrapper: TouchWrapper) {\n const touch = event.changedTouches[0]\n wrapper.touchendX = touch.clientX\n wrapper.touchendY = touch.clientY\n\n wrapper.end &&\n wrapper.end(Object.assign(event, wrapper))\n\n handleGesture(wrapper)\n}\n\nfunction touchmove (event: TouchEvent, wrapper: TouchWrapper) {\n const touch = event.changedTouches[0]\n wrapper.touchmoveX = touch.clientX\n wrapper.touchmoveY = touch.clientY\n\n wrapper.move && wrapper.move(Object.assign(event, wrapper))\n}\n\nfunction createHandlers (value: TouchHandlers): TouchStoredHandlers {\n const wrapper = {\n touchstartX: 0,\n touchstartY: 0,\n touchendX: 0,\n touchendY: 0,\n touchmoveX: 0,\n touchmoveY: 0,\n offsetX: 0,\n offsetY: 0,\n left: value.left,\n right: value.right,\n up: value.up,\n down: value.down,\n start: value.start,\n move: value.move,\n end: value.end\n }\n\n return {\n touchstart: (e: TouchEvent) => touchstart(e, wrapper),\n touchend: (e: TouchEvent) => touchend(e, wrapper),\n touchmove: (e: TouchEvent) => touchmove(e, wrapper)\n }\n}\n\nfunction inserted (el: HTMLElement, binding: TouchVNodeDirective, vnode: VNode) {\n const value = binding.value!\n const target = value.parent ? el.parentElement : el\n const options = value.options || { passive: true }\n\n // Needed to pass unit tests\n if (!target) return\n\n const handlers = createHandlers(binding.value!)\n target._touchHandlers = Object(target._touchHandlers)\n target._touchHandlers![vnode.context!._uid] = handlers\n\n keys(handlers).forEach(eventName => {\n target.addEventListener(eventName, handlers[eventName] as EventListener, options)\n })\n}\n\nfunction unbind (el: HTMLElement, binding: TouchVNodeDirective, vnode: VNode) {\n const target = binding.value!.parent ? el.parentElement : el\n if (!target || !target._touchHandlers) return\n\n const handlers = target._touchHandlers[vnode.context!._uid]\n keys(handlers).forEach(eventName => {\n target.removeEventListener(eventName, handlers[eventName])\n })\n delete target._touchHandlers[vnode.context!._uid]\n}\n\nexport default {\n inserted,\n unbind\n}\n"],"sourceRoot":""}