{"version":3,"file":"index.cjs","sources":["../src/baseModule.ts","../src/pointeract.ts","../src/modules/click.ts","../src/modules/drag.ts","../src/modules/multitouchPanZoom.ts","../src/modules/preventDefault.ts","../src/modules/wheelPanZoom.ts"],"sourcesContent":["import type { Constrain, GeneralObject, ModifierReturn, Pointer, Pointers, StdEvents } from '@/declarations';\nimport type Pointeract from '@/pointeract';\n\ntype IsAny<T> = 0 extends 1 & T ? true : false;\n\nexport default class BaseModule<Events extends StdEvents = StdEvents> {\n\tprotected utils: Omit<Pointeract<never>['moduleUtils'], 'dispatch'> & {\n\t\tdispatch: <T extends keyof Constrain<Events>>(\n\t\t\tname: T,\n\t\t\t...args: IsAny<Events[T]['detail']> extends false ? [detail: Events[T]['detail']] : []\n\t\t) => void;\n\t};\n\tprotected window: Window;\n\tprotected pointers: Pointers;\n\tprotected monitoringElement: HTMLElement;\n\tconstructor(\n\t\tutils: Pointeract<never>['moduleUtils'],\n\t\twindow: Window,\n\t\tpointers: Pointers,\n\t\tmonitoringElement: HTMLElement,\n\t) {\n\t\tthis.utils = utils as typeof this.utils;\n\t\tthis.window = window;\n\t\tthis.pointers = pointers;\n\t\tthis.monitoringElement = monitoringElement;\n\t}\n\tdeclare readonly events: Events;\n\n\toptions?: GeneralObject;\n\n\t// hooks\n\tdispose?: (...args: []) => void;\n\tmodifier?: (...args: [string, unknown]) => ModifierReturn;\n\tonPointerDown?: (...args: [PointerEvent, Pointer, Pointers]) => void;\n\tonPointerMove?: (...args: [PointerEvent, Pointer, Pointers]) => void;\n\tonPointerUp?: (...args: [PointerEvent, Pointer, Pointers]) => void;\n\tonWheel?: (...args: [WheelEvent]) => void;\n\tonStart?: (...args: []) => void;\n\tonStop?: (...args: []) => void;\n}\n","import type BaseModule from '@/baseModule';\nimport type {\n\tCoordinates,\n\tEventMap,\n\tGeneralArguments,\n\tGeneralObject,\n\tHooks,\n\tModifierReturn,\n\tModuleCtor,\n\tModuleInput,\n\tOptions,\n\tPointers,\n\tReloadable,\n} from '@/declarations';\n\nexport default class Pointeract<T extends ModuleInput = []> extends EventTarget {\n\t#monitoringElement: HTMLElement;\n\t#pointers: Pointers = new Map();\n\t#modules: Record<string, BaseModule> = {};\n\t#pausedModules: Record<string, BaseModule> = {};\n\t#_window: Window | null;\n\toptions: GeneralObject;\n\n\tget #window() {\n\t\tif (!this.#_window) throw new Error('[Pointeract] Window is not defined.');\n\t\treturn this.#_window;\n\t}\n\n\tconstructor(monitoringElement: HTMLElement, _modules?: T, options: Options<T> = {}) {\n\t\tsuper();\n\t\tconst modules = toArray(_modules ? _modules : ([] as Array<ModuleCtor>));\n\t\tthis.#_window = monitoringElement.ownerDocument.defaultView;\n\t\tthis.#monitoringElement = monitoringElement;\n\t\tthis.options = options;\n\t\tthis.#fillIn({ coordinateOutput: 'relative' });\n\t\tmodules.forEach(module => {\n\t\t\tconst instance = new module(\n\t\t\t\tthis.moduleUtils,\n\t\t\t\tthis.#window,\n\t\t\t\tthis.#pointers,\n\t\t\t\tthis.#monitoringElement,\n\t\t\t);\n\t\t\tif (instance.options) this.#fillIn(instance.options);\n\t\t\tObject.assign(instance, { options });\n\t\t\tthis.#modules[module.name] = instance;\n\t\t});\n\t}\n\n\t#fillIn = (patch: GeneralObject) => {\n\t\tfor (const [k, v] of Object.entries(patch))\n\t\t\tif (!(k in this.options)) (this.options as GeneralObject)[k] = v;\n\t};\n\n\ton = <K extends keyof EventMap<T>>(type: K, listener: (event: EventMap<T>[K]) => void) => {\n\t\tsuper.addEventListener(type as string, listener as EventListener);\n\t\treturn () => this.off(type, listener);\n\t};\n\toff<K extends keyof EventMap<T>>(type: K, listener: (event: EventMap<T>[K]) => void) {\n\t\tsuper.removeEventListener(type as string, listener as EventListener);\n\t}\n\n\tdeclare readonly events: EventMap<T>;\n\n\tmoduleUtils = {\n\t\tgetNthValue: (n: number) => {\n\t\t\tconst error = new Error('[Pointeract] Invalid pointer index');\n\t\t\tif (n < 0 || n >= this.#pointers.size) throw error;\n\t\t\tlet i = 0;\n\t\t\tfor (const value of this.#pointers.values()) {\n\t\t\t\tif (i === n) return value;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tthrow error;\n\t\t},\n\n\t\t// Screen to Container\n\t\tscreenToTarget: (raw: Coordinates) => {\n\t\t\tif (this.options.coordinateOutput === 'absolute') return raw;\n\t\t\tconst rect = this.#monitoringElement.getBoundingClientRect();\n\t\t\traw.x -= rect.left;\n\t\t\traw.y -= rect.top;\n\t\t\tif (this.options.coordinateOutput === 'relative') return raw;\n\t\t\traw.x /= rect.width;\n\t\t\traw.y /= rect.height;\n\t\t\treturn raw;\n\t\t},\n\n\t\tdispatch: <T>(name: string, detail?: T) => {\n\t\t\tlet lastResult: ModifierReturn = true;\n\t\t\tfor (const value of Object.values(this.#modules)) {\n\t\t\t\tif (!value.modifier) continue;\n\t\t\t\tlastResult = value.modifier(name, detail);\n\t\t\t\tif (lastResult !== true) break;\n\t\t\t}\n\t\t\tif (lastResult === false) return;\n\t\t\tlet event: CustomEvent;\n\t\t\tif (lastResult === true) event = new CustomEvent<T>(name, { detail });\n\t\t\telse event = new CustomEvent(lastResult.name, { detail: lastResult.detail });\n\t\t\tthis.dispatchEvent(event);\n\t\t},\n\n\t\tgetLast: <T>(arr: Array<T>, num: number = 0) => arr[arr.length - 1 - num],\n\t};\n\n\t#runHooks(field: Hooks, ...args: GeneralArguments) {\n\t\tObject.values(this.#modules).forEach(module => {\n\t\t\tif (module[field]) module[field](...args);\n\t\t});\n\t}\n\n\t#onPointerDown = (e: PointerEvent) => {\n\t\tif (this.#pointers.size >= 2) return;\n\t\tif (e.isPrimary) this.#pointers.clear();\n\t\tconst pointer = {\n\t\t\trecords: [{ x: e.clientX, y: e.clientY, timestamp: Date.now() }],\n\t\t\ttarget: e.target,\n\t\t};\n\t\tthis.#pointers.set(e.pointerId, pointer);\n\t\tthis.#runHooks('onPointerDown', e, pointer, this.#pointers);\n\t};\n\n\t#onPointerMove = (e: PointerEvent) => {\n\t\tconst pointer = this.#pointers.get(e.pointerId);\n\t\tif (!pointer) return;\n\t\tpointer.records.push({ x: e.clientX, y: e.clientY, timestamp: Date.now() });\n\t\tthis.#runHooks('onPointerMove', e, pointer, this.#pointers);\n\t};\n\n\t#onPointerUp = (e: PointerEvent) => {\n\t\tconst pointer = this.#pointers.get(e.pointerId);\n\t\tif (!pointer) return;\n\t\tthis.#pointers.delete(e.pointerId);\n\t\tthis.#runHooks('onPointerUp', e, pointer, this.#pointers);\n\t};\n\n\t#onWheel = (e: WheelEvent) => this.#runHooks('onWheel', e);\n\n\tstop = (_toStop?: Reloadable<T>) => {\n\t\tconst stopPointeract = () => {\n\t\t\tthis.#monitoringElement.removeEventListener('pointerdown', this.#onPointerDown);\n\t\t\tthis.#window.removeEventListener('pointermove', this.#onPointerMove);\n\t\t\tthis.#window.removeEventListener('pointerup', this.#onPointerUp);\n\t\t\tthis.#monitoringElement.removeEventListener('wheel', this.#onWheel);\n\t\t\tthis.#runHooks('onStop');\n\t\t};\n\t\tconst stopModule = (moduleCtor: ModuleCtor) => {\n\t\t\tif (!(moduleCtor.name in this.#modules)) return;\n\t\t\tconst module = this.#modules[moduleCtor.name];\n\t\t\tif (module.onStop) module.onStop();\n\t\t\tthis.#pausedModules[moduleCtor.name] = module;\n\t\t\tdelete this.#modules[moduleCtor.name];\n\t\t};\n\t\tif (!_toStop) stopPointeract();\n\t\telse\n\t\t\ttoArray(_toStop).forEach(module => {\n\t\t\t\tstopModule(module);\n\t\t\t});\n\t\treturn this;\n\t};\n\n\tstart = (_toStart?: Reloadable<T>) => {\n\t\tconst startPointeract = () => {\n\t\t\tthis.#monitoringElement.addEventListener('pointerdown', this.#onPointerDown);\n\t\t\tthis.#window.addEventListener('pointermove', this.#onPointerMove);\n\t\t\tthis.#window.addEventListener('pointerup', this.#onPointerUp);\n\t\t\tthis.#monitoringElement.addEventListener('wheel', this.#onWheel);\n\t\t\tthis.#runHooks('onStart');\n\t\t};\n\t\tconst startModule = (moduleCtor: ModuleCtor) => {\n\t\t\tif (!(moduleCtor.name in this.#pausedModules)) return;\n\t\t\tconst module = this.#pausedModules[moduleCtor.name];\n\t\t\tif (module.onStart) module.onStart();\n\t\t\tthis.#modules[moduleCtor.name] = module;\n\t\t\tdelete this.#pausedModules[moduleCtor.name];\n\t\t};\n\t\tif (!_toStart) startPointeract();\n\t\telse\n\t\t\ttoArray(_toStart).forEach(module => {\n\t\t\t\tstartModule(module);\n\t\t\t});\n\t\treturn this;\n\t};\n\n\tdispose = () => {\n\t\tthis.stop();\n\t\tthis.#_window = null;\n\t\tthis.#runHooks('dispose');\n\t};\n}\n\nconst toArray = <T>(toTrans: T | Array<T>) => (Array.isArray(toTrans) ? toTrans : [toTrans]);\n","import BaseModule from '@/baseModule';\nimport type { Pointer, Pointers } from '@/declarations';\n\nexport default class Click extends BaseModule {\n\t#lastClickTime = -Infinity;\n\t#clickSteak = 0;\n\n\toptions = {\n\t\tclickPreserveTime: 400,\n\t\tmoveThreshold: 5,\n\t};\n\n\tonPointerDown = (_e: PointerEvent, pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tconst pointer0 = this.utils.getNthValue(0);\n\t\t\t/*\n            interrupted means that when a pointer is moving on the screen while another pointer is down, possibly for zooming, both pointers will be seen as \"interrupted\" so that they won't be used for triggering a real click.\n            */\n\t\t\tpointer0.interrupted = true;\n\t\t\tpointer.interrupted = true;\n\t\t}\n\t};\n\n\tonPointerUp = (e: PointerEvent, pointer: Pointer) => {\n\t\tif (pointer.interrupted) return;\n\t\tconst threshold = this.options.moveThreshold;\n\t\tif (\n\t\t\tMath.abs(pointer.records[0].x - e.clientX) >= threshold ||\n\t\t\tMath.abs(pointer.records[0].y - e.clientY) >= threshold\n\t\t)\n\t\t\treturn;\n\t\tconst newLast = this.utils.getLast(pointer.records).timestamp;\n\t\tif (newLast - this.#lastClickTime <= this.options.clickPreserveTime) this.#clickSteak++;\n\t\telse this.#clickSteak = 1;\n\t\tthis.#lastClickTime = newLast;\n\t\tconst coords = this.utils.screenToTarget({ x: e.clientX, y: e.clientY });\n\t\tthis.utils.dispatch('trueClick', {\n\t\t\t...coords,\n\t\t\ttarget: pointer.target,\n\t\t\tstreak: this.#clickSteak,\n\t\t});\n\t};\n}\n","import BaseModule from '@/baseModule';\nimport type { Pointer, Pointers } from '@/declarations';\n\nexport default class Drag extends BaseModule {\n\tonPointerMove = (e: PointerEvent, pointer: Pointer, pointers: Pointers) => {\n\t\tconst last = this.utils.getLast(pointer.records, 1);\n\t\tif (pointers.size === 1) {\n\t\t\tconst dx = e.clientX - last.x;\n\t\t\tconst dy = e.clientY - last.y;\n\t\t\tthis.utils.dispatch('drag', { x: dx, y: dy, clientX: e.clientX, clientY: e.clientY });\n\t\t}\n\t};\n}\n","import BaseModule from '@/baseModule';\nimport type { Coordinates, Pointer, Pointers } from '@/declarations';\n\nexport default class MultitouchPanZoom extends BaseModule {\n\t#pinchZoomState = {\n\t\tlastDistance: 0,\n\t\tlastMidpoint: { x: 0, y: 0 },\n\t};\n\n\t#getPointerDistance() {\n\t\tconst pointer0Coords = this.utils.getLast(this.utils.getNthValue(0).records);\n\t\tconst pointer1Coords = this.utils.getLast(this.utils.getNthValue(1).records);\n\t\tconst dx = pointer0Coords.x - pointer1Coords.x;\n\t\tconst dy = pointer0Coords.y - pointer1Coords.y;\n\t\treturn Math.sqrt(dx * dx + dy * dy);\n\t}\n\n\t// output screen coords\n\t#getPointerMidpoint() {\n\t\tconst pointer0Coords = this.utils.getLast(this.utils.getNthValue(0).records);\n\t\tconst pointer1Coords = this.utils.getLast(this.utils.getNthValue(1).records);\n\t\treturn {\n\t\t\tx: (pointer0Coords.x + pointer1Coords.x) / 2,\n\t\t\ty: (pointer0Coords.y + pointer1Coords.y) / 2,\n\t\t};\n\t}\n\n\tonPointerDown = (_e: PointerEvent, _pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tthis.#pinchZoomState.lastDistance = this.#getPointerDistance();\n\t\t\tthis.#pinchZoomState.lastMidpoint = this.utils.screenToTarget(this.#getPointerMidpoint());\n\t\t}\n\t};\n\n\tonPointerMove = (_e: PointerEvent, _pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tconst newDistance = this.#getPointerDistance();\n\t\t\tconst newMidpointOnScreen = this.#getPointerMidpoint();\n\t\t\tconst zoomFactor = newDistance / this.#pinchZoomState.lastDistance;\n\t\t\tthis.#pinchZoomState.lastDistance = newDistance;\n\t\t\tconst newMidpoint = this.utils.screenToTarget(newMidpointOnScreen);\n\t\t\tconst dx = newMidpoint.x - this.#pinchZoomState.lastMidpoint.x;\n\t\t\tconst dy = newMidpoint.y - this.#pinchZoomState.lastMidpoint.y;\n\t\t\tthis.#pinchZoomState.lastMidpoint = newMidpoint;\n\t\t\tthis.#dispatchPanEvent({ x: dx, y: dy });\n\t\t\tthis.#dispatchZoomEvent(zoomFactor, newMidpoint);\n\t\t}\n\t};\n\n\t#dispatchZoomEvent(factor: number, origin: Coordinates) {\n\t\tthis.utils.dispatch('zoom', { x: origin.x, y: origin.y, factor });\n\t}\n\n\t#dispatchPanEvent(diff: Coordinates) {\n\t\tthis.utils.dispatch('pan', diff);\n\t}\n}\n","import BaseModule from '@/baseModule';\n\nexport default class PreventDefault extends BaseModule {\n\tonWheel = (e: WheelEvent) => e.preventDefault();\n\t#preventDefaultFunction = (e: Event) => e.preventDefault();\n\n\tonStart = () => {\n\t\tthis.monitoringElement.style.touchAction = 'none';\n\t\tthis.monitoringElement.addEventListener('gesturestart', this.#preventDefaultFunction, {\n\t\t\tpassive: false,\n\t\t});\n\t\tthis.monitoringElement.addEventListener('gesturechange', this.#preventDefaultFunction, {\n\t\t\tpassive: false,\n\t\t});\n\t};\n\n\tonStop = () => {\n\t\tthis.monitoringElement.style.touchAction = '';\n\t\tthis.monitoringElement.removeEventListener('gesturestart', this.#preventDefaultFunction);\n\t\tthis.monitoringElement.removeEventListener('gesturechange', this.#preventDefaultFunction);\n\t};\n\n\tdispose = this.onStop;\n}\n","import BaseModule from '@/baseModule';\nimport type { Coordinates } from '@/declarations';\n\n/*\nto normal computer users:\n\n# normal schema\ndiff y > 0 => zooms in => zoom factor < 1\ndiff y < 0 => zooms out => zoom factor > 1\n\n# professional schema\ndiff y > 0 => pan up => pan y < 0\ndiff y < 0 => pan down => pan y > 0\ndiff x > 0 => pan left => pan x < 0\ndiff y < 0 => pan right => pan y > 0\n*/\n\nexport default class wheelPanZoom extends BaseModule {\n\toptions = {\n\t\tproControlSchema: false,\n\t\tzoomFactor: 0.1,\n\t\tlockControlSchema: false,\n\t};\n\n\tonWheel = (e: WheelEvent) => {\n\t\tconst options = this.options;\n\t\tif (\n\t\t\t!options.proControlSchema &&\n\t\t\t!options.lockControlSchema &&\n\t\t\t(e.ctrlKey || e.shiftKey || Math.abs(e.deltaX) > Math.abs(e.deltaY))\n\t\t)\n\t\t\toptions.proControlSchema = true;\n\t\tif (options.proControlSchema) {\n\t\t\tif (e.ctrlKey) {\n\t\t\t\tconst scaleFactor = e.deltaY > 0 ? 1 - options.zoomFactor : 1 + options.zoomFactor;\n\t\t\t\tconst origin = this.utils.screenToTarget({ x: e.clientX, y: e.clientY });\n\t\t\t\tthis.#dispatchZoomEvent(scaleFactor, origin);\n\t\t\t} else if (e.shiftKey && Math.abs(e.deltaX) <= Math.abs(e.deltaY))\n\t\t\t\tthis.#dispatchPanEvent({ x: -e.deltaY, y: -e.deltaX });\n\t\t\telse this.#dispatchPanEvent({ x: -e.deltaX, y: -e.deltaY });\n\t\t} else {\n\t\t\tconst scaleFactor = 1 - (options.zoomFactor / 50) * e.deltaY;\n\t\t\tconst origin = this.utils.screenToTarget({ x: e.clientX, y: e.clientY });\n\t\t\tthis.#dispatchZoomEvent(scaleFactor, origin);\n\t\t}\n\t};\n\n\t#dispatchZoomEvent(factor: number, origin: Coordinates) {\n\t\tthis.utils.dispatch('zoom', { x: origin.x, y: origin.y, factor });\n\t}\n\n\t#dispatchPanEvent(diff: Coordinates) {\n\t\tthis.utils.dispatch('pan', diff);\n\t}\n}\n"],"names":["BaseModule","utils","window","pointers","monitoringElement","constructor","this","options","dispose","modifier","onPointerDown","onPointerMove","onPointerUp","onWheel","onStart","onStop","Pointeract","EventTarget","Map","modules","pausedModules","_window","Error","_modules","super","toArray","ownerDocument","defaultView","fillIn","coordinateOutput","forEach","module","instance","moduleUtils","Object","assign","name","patch","k","v","entries","on","type","listener","addEventListener","off","removeEventListener","getNthValue","n","error","size","i","value","values","screenToTarget","raw","rect","getBoundingClientRect","x","left","y","top","width","height","dispatch","detail","event","lastResult","CustomEvent","dispatchEvent","getLast","arr","num","length","runHooks","field","args","e","isPrimary","clear","pointer","records","clientX","clientY","timestamp","Date","now","target","set","pointerId","get","push","delete","stop","_toStop","stopModule","moduleCtor","stopPointeract","start","_toStart","startModule","startPointeract","toTrans","Array","isArray","lastClickTime","Infinity","clickSteak","clickPreserveTime","moveThreshold","_e","interrupted","threshold","Math","abs","newLast","coords","streak","last","dx","dy","pinchZoomState","lastDistance","lastMidpoint","getPointerDistance","pointer0Coords","pointer1Coords","sqrt","getPointerMidpoint","_pointer","newDistance","newMidpointOnScreen","zoomFactor","newMidpoint","dispatchPanEvent","dispatchZoomEvent","factor","origin","diff","preventDefault","preventDefaultFunction","style","touchAction","passive","proControlSchema","lockControlSchema","ctrlKey","shiftKey","deltaX","deltaY","scaleFactor"],"mappings":"gFAKA,MAAqBA,EACVC,MAMAC,OACAC,SACAC,kBACV,WAAAC,CACCJ,EACAC,EACAC,EACAC,GAEAE,KAAKL,MAAQA,EACbK,KAAKJ,OAASA,EACdI,KAAKH,SAAWA,EAChBG,KAAKF,kBAAoBA,CAC1B,CAGAG,QAGAC,QACAC,SACAC,cACAC,cACAC,YACAC,QACAC,QACAC,OCvBD,MAAqBC,UAA+CC,YACnEb,GACAD,OAA0Be,IAC1BC,GAAuC,CAAA,EACvCC,GAA6C,CAAA,EAC7CC,GACAd,QAEA,KAAIL,GACH,IAAKI,MAAKe,EAAU,MAAM,IAA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