-
Notifications
You must be signed in to change notification settings - Fork 783
/
plugin.js.map
64 lines (64 loc) · 9.99 KB
/
plugin.js.map
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
"version": 3,
"names": [
"is",
"install",
"scope",
"actions",
"Interactable",
"defaults",
"prototype",
"draggable",
"drag",
"map",
"methodDict",
"beforeMove",
"interaction",
"prepared",
"name",
"axis",
"coords",
"cur",
"page",
"y",
"start",
"client",
"velocity",
"x",
"move",
"iEvent",
"opposite",
"delta",
"options",
"object",
"enabled",
"setPerAction",
"setOnEvents",
"test",
"lockAxis",
"startAxis",
"bool",
"id",
"listeners",
"arg",
"interactable",
"buttons",
"dragOptions",
"pointerIsDown",
"pointerType",
"mouseButtons",
"undefined",
"action",
"getCursor",
"filterEventType",
"type",
"search"
],
"sources": [
"plugin.ts"
],
"sourcesContent": [
"import type { InteractEvent } from '@interactjs/core/InteractEvent'\nimport type { Interactable } from '@interactjs/core/Interactable'\nimport type { PerActionDefaults } from '@interactjs/core/options'\nimport type { Scope, Plugin } from '@interactjs/core/scope'\nimport type { ActionMethod, ListenersArg } from '@interactjs/core/types'\nimport is from '@interactjs/utils/is'\n\ndeclare module '@interactjs/core/Interactable' {\n interface Interactable {\n draggable: DraggableMethod\n }\n}\n\ndeclare module '@interactjs/core/options' {\n interface ActionDefaults {\n drag: DraggableOptions\n }\n}\n\ndeclare module '@interactjs/core/types' {\n interface ActionMap {\n drag?: typeof drag\n }\n}\n\nexport type DragEvent = InteractEvent<'drag'>\n\nexport type DraggableMethod = ActionMethod<DraggableOptions>\n\nexport interface DraggableOptions extends PerActionDefaults {\n startAxis?: 'x' | 'y' | 'xy'\n lockAxis?: 'x' | 'y' | 'xy' | 'start'\n oninertiastart?: ListenersArg\n onstart?: ListenersArg\n onmove?: ListenersArg\n onend?: ListenersArg\n}\n\nfunction install (scope: Scope) {\n const { actions, Interactable, defaults } = scope\n\n Interactable.prototype.draggable = drag.draggable\n\n actions.map.drag = drag\n actions.methodDict.drag = 'draggable'\n\n defaults.actions.drag = drag.defaults\n}\n\nfunction beforeMove ({ interaction }) {\n if (interaction.prepared.name !== 'drag') return\n\n const axis = interaction.prepared.axis\n\n if (axis === 'x') {\n interaction.coords.cur.page.y = interaction.coords.start.page.y\n interaction.coords.cur.client.y = interaction.coords.start.client.y\n\n interaction.coords.velocity.client.y = 0\n interaction.coords.velocity.page.y = 0\n } else if (axis === 'y') {\n interaction.coords.cur.page.x = interaction.coords.start.page.x\n interaction.coords.cur.client.x = interaction.coords.start.client.x\n\n interaction.coords.velocity.client.x = 0\n interaction.coords.velocity.page.x = 0\n }\n}\n\nfunction move ({ iEvent, interaction }) {\n if (interaction.prepared.name !== 'drag') return\n\n const axis = interaction.prepared.axis\n\n if (axis === 'x' || axis === 'y') {\n const opposite = axis === 'x' ? 'y' : 'x'\n\n iEvent.page[opposite] = interaction.coords.start.page[opposite]\n iEvent.client[opposite] = interaction.coords.start.client[opposite]\n iEvent.delta[opposite] = 0\n }\n}\n\n/**\n * ```js\n * interact(element).draggable({\n * onstart: function (event) {},\n * onmove : function (event) {},\n * onend : function (event) {},\n *\n * // the axis in which the first movement must be\n * // for the drag sequence to start\n * // 'xy' by default - any direction\n * startAxis: 'x' || 'y' || 'xy',\n *\n * // 'xy' by default - don't restrict to one axis (move in any direction)\n * // 'x' or 'y' to restrict movement to either axis\n * // 'start' to restrict movement to the axis the drag started in\n * lockAxis: 'x' || 'y' || 'xy' || 'start',\n *\n * // max number of drags that can happen concurrently\n * // with elements of this Interactable. Infinity by default\n * max: Infinity,\n *\n * // max number of drags that can target the same element+Interactable\n * // 1 by default\n * maxPerElement: 2\n * })\n *\n * var isDraggable = interact('element').draggable(); // true\n * ```\n *\n * Get or set whether drag actions can be performed on the target\n *\n * @alias Interactable.prototype.draggable\n *\n * @param {boolean | object} [options] true/false or An object with event\n * listeners to be fired on drag events (object makes the Interactable\n * draggable)\n * @return {boolean | Interactable} boolean indicating if this can be the\n * target of drag events, or this Interctable\n */\nconst draggable: DraggableMethod = function draggable (\n this: Interactable,\n options?: DraggableOptions | boolean,\n): any {\n if (is.object(options)) {\n this.options.drag.enabled = options.enabled !== false\n this.setPerAction('drag', options)\n this.setOnEvents('drag', options)\n\n if (/^(xy|x|y|start)$/.test(options.lockAxis)) {\n this.options.drag.lockAxis = options.lockAxis\n }\n if (/^(xy|x|y)$/.test(options.startAxis)) {\n this.options.drag.startAxis = options.startAxis\n }\n\n return this\n }\n\n if (is.bool(options)) {\n this.options.drag.enabled = options\n\n return this\n }\n\n return this.options.drag as DraggableOptions\n}\n\nconst drag: Plugin = {\n id: 'actions/drag',\n install,\n listeners: {\n 'interactions:before-action-move': beforeMove,\n 'interactions:action-resume': beforeMove,\n\n // dragmove\n 'interactions:action-move': move,\n 'auto-start:check': (arg) => {\n const { interaction, interactable, buttons } = arg\n const dragOptions = interactable.options.drag\n\n if (\n !(dragOptions && dragOptions.enabled) ||\n // check mouseButton setting if the pointer is down\n (interaction.pointerIsDown &&\n /mouse|pointer/.test(interaction.pointerType) &&\n (buttons & interactable.options.drag.mouseButtons) === 0)\n ) {\n return undefined\n }\n\n arg.action = {\n name: 'drag',\n axis: dragOptions.lockAxis === 'start' ? dragOptions.startAxis : dragOptions.lockAxis,\n }\n\n return false\n },\n },\n draggable,\n beforeMove,\n move,\n defaults: {\n startAxis: 'xy',\n lockAxis: 'xy',\n } as DraggableOptions,\n\n getCursor () {\n return 'move'\n },\n\n filterEventType: (type: string) => type.search('drag') === 0,\n}\n\nexport default drag\n"
],
"mappings": "AAKA,OAAOA,EAAP,MAAe,mBAAf;;AAiCA,SAASC,OAAT,CAAkBC,KAAlB,EAAgC;EAC9B,MAAM;IAAEC,OAAF;IAAWC,YAAX;IAAyBC;EAAzB,IAAsCH,KAA5C;EAEAE,YAAY,CAACE,SAAb,CAAuBC,SA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