@krainovsd/graph 0.14.0-beta.4 → 0.14.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,10 +20,10 @@ function initPointer() {
20
20
  let highlightNode = true;
21
21
  let highlightLink = true;
22
22
  if (checkHighlightNode) {
23
+ const [pointerX, pointerY] = this.getPointerAreaPosition(event);
23
24
  currentNode = nodeByPointerGetter({
24
- areaRect: this.areaRect,
25
- areaTransform: this.areaTransform,
26
- mouseEvent: event,
25
+ pointerX,
26
+ pointerY,
27
27
  nodes: this.nodes,
28
28
  });
29
29
  if (currentNode?.highlight != undefined)
@@ -33,11 +33,11 @@ function initPointer() {
33
33
  this.area.style.cursor = "pointer";
34
34
  }
35
35
  else if (checkHighlightLink) {
36
+ const [pointerX, pointerY] = this.getPointerAreaPosition(event);
36
37
  currentLink = linkByPointerGetter({
38
+ pointerX,
39
+ pointerY,
37
40
  linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,
38
- areaRect: this.areaRect,
39
- areaTransform: this.areaTransform,
40
- mouseEvent: event,
41
41
  links: this.links,
42
42
  curve: this.linkSettings.curve,
43
43
  });
@@ -56,19 +56,20 @@ function initPointer() {
56
56
  this.animateHighlight(highlightNode ? currentNode : undefined, highlightLink ? currentLink : undefined);
57
57
  if (!this.listeners.onMove)
58
58
  return;
59
- if (!currentNode && !checkHighlightNode)
59
+ if (!currentNode && !checkHighlightNode) {
60
+ const [pointerX, pointerY] = this.getPointerAreaPosition(event);
60
61
  currentNode = nodeByPointerGetter({
61
- areaRect: this.areaRect,
62
- areaTransform: this.areaTransform,
63
- mouseEvent: event,
62
+ pointerX,
63
+ pointerY,
64
64
  nodes: this.nodes,
65
65
  });
66
+ }
66
67
  if (!currentNode && (!checkHighlightNode || (!checkHighlightLink && !currentLink))) {
68
+ const [pointerX, pointerY] = this.getPointerAreaPosition(event);
67
69
  currentLink = linkByPointerGetter({
70
+ pointerX,
71
+ pointerY,
68
72
  linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,
69
- areaRect: this.areaRect,
70
- areaTransform: this.areaTransform,
71
- mouseEvent: event,
72
73
  links: this.links,
73
74
  curve: this.linkSettings.curve,
74
75
  });
@@ -82,18 +83,18 @@ function initPointer() {
82
83
  !("button" in event) ||
83
84
  event.button !== 1)
84
85
  return;
86
+ const [pointerX, pointerY] = this.getPointerAreaPosition(event);
85
87
  const currentNode = nodeByPointerGetter({
86
- areaRect: this.areaRect,
87
- areaTransform: this.areaTransform,
88
- mouseEvent: event,
88
+ pointerX,
89
+ pointerY,
89
90
  nodes: this.nodes,
90
91
  });
91
92
  if (!currentNode) {
93
+ const [pointerX, pointerY] = this.getPointerAreaPosition(event);
92
94
  const currentLink = linkByPointerGetter({
95
+ pointerX,
96
+ pointerY,
93
97
  linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,
94
- areaRect: this.areaRect,
95
- areaTransform: this.areaTransform,
96
- mouseEvent: event,
97
98
  links: this.links,
98
99
  curve: this.linkSettings.curve,
99
100
  });
@@ -104,18 +105,18 @@ function initPointer() {
104
105
  function onRightClick(event) {
105
106
  if (!this.listeners.onContextMenu)
106
107
  return;
108
+ const [pointerX, pointerY] = this.getPointerAreaPosition(event);
107
109
  const currentNode = nodeByPointerGetter({
108
- areaRect: this.areaRect,
109
- areaTransform: this.areaTransform,
110
- mouseEvent: event,
110
+ pointerX,
111
+ pointerY,
111
112
  nodes: this.nodes,
112
113
  });
113
114
  if (!currentNode) {
115
+ const [pointerX, pointerY] = this.getPointerAreaPosition(event);
114
116
  const currentLink = linkByPointerGetter({
117
+ pointerX,
118
+ pointerY,
115
119
  linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,
116
- areaRect: this.areaRect,
117
- areaTransform: this.areaTransform,
118
- mouseEvent: event,
119
120
  links: this.links,
120
121
  curve: this.linkSettings.curve,
121
122
  });
@@ -126,18 +127,18 @@ function initPointer() {
126
127
  function onDoubleClick(event) {
127
128
  if (!this.listeners.onDoubleClick)
128
129
  return;
130
+ const [pointerX, pointerY] = this.getPointerAreaPosition(event);
129
131
  const currentNode = nodeByPointerGetter({
130
- areaRect: this.areaRect,
131
- areaTransform: this.areaTransform,
132
- mouseEvent: event,
132
+ pointerX,
133
+ pointerY,
133
134
  nodes: this.nodes,
134
135
  });
135
136
  if (!currentNode) {
137
+ const [pointerX, pointerY] = this.getPointerAreaPosition(event);
136
138
  const currentLink = linkByPointerGetter({
139
+ pointerX,
140
+ pointerY,
137
141
  linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,
138
- areaRect: this.areaRect,
139
- areaTransform: this.areaTransform,
140
- mouseEvent: event,
141
142
  links: this.links,
142
143
  curve: this.linkSettings.curve,
143
144
  });
@@ -148,18 +149,18 @@ function initPointer() {
148
149
  function onClick(event) {
149
150
  if (this.isDragging || !this.listeners.onClick || ("button" in event && event.button !== 0))
150
151
  return;
152
+ const [pointerX, pointerY] = this.getPointerAreaPosition(event);
151
153
  const currentNode = nodeByPointerGetter({
152
- areaRect: this.areaRect,
153
- areaTransform: this.areaTransform,
154
- mouseEvent: event,
154
+ pointerX,
155
+ pointerY,
155
156
  nodes: this.nodes,
156
157
  });
157
158
  if (!currentNode) {
159
+ const [pointerX, pointerY] = this.getPointerAreaPosition(event);
158
160
  const currentLink = linkByPointerGetter({
161
+ pointerX,
162
+ pointerY,
159
163
  linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,
160
- areaRect: this.areaRect,
161
- areaTransform: this.areaTransform,
162
- mouseEvent: event,
163
164
  links: this.links,
164
165
  curve: this.linkSettings.curve,
165
166
  });
@@ -1 +1 @@
1
- {"version":3,"file":"init-pointer.js","sources":["../../../../../src/module/GraphCanvas/slices/init-pointer.ts"],"sourcesContent":["import type { GraphCanvas } from \"../GraphCanvas\";\nimport { linkByPointerGetter, nodeByPointerGetter } from \"../lib\";\nimport type { LinkInterface, NodeInterface } from \"../types\";\n\nexport function initPointer<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.area || !this.nodes) throw new Error(\"bad init data\");\n\n function onHover(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent | TouchEvent) {\n if (!this.area || this.isSelecting) return;\n\n let currentNode: NodeInterface<NodeData> | undefined;\n let currentLink: LinkInterface<NodeData, LinkData> | undefined;\n const checkHighlightNode = this.highlightSettings.highlightByHoverNode && !this.isDragging;\n const checkHighlightLink = this.highlightSettings.highlightByHoverLink && !this.isDragging;\n let highlightNode = true;\n let highlightLink = true;\n\n if (checkHighlightNode) {\n currentNode = nodeByPointerGetter({\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n nodes: this.nodes,\n });\n if (currentNode?.highlight != undefined) highlightNode = currentNode.highlight;\n }\n if (currentNode && highlightNode) {\n this.area.style.cursor = \"pointer\";\n } else if (checkHighlightLink) {\n currentLink = linkByPointerGetter({\n linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n links: this.links,\n curve: this.linkSettings.curve,\n });\n if (currentLink?.highlight != undefined) highlightLink = currentLink?.highlight;\n if (currentLink && highlightLink) {\n this.area.style.cursor = \"pointer\";\n } else {\n this.area.style.cursor = \"default\";\n }\n } else {\n this.area.style.cursor = \"default\";\n }\n this.animateHighlight(\n highlightNode ? currentNode : undefined,\n highlightLink ? currentLink : undefined,\n );\n\n if (!this.listeners.onMove) return;\n if (!currentNode && !checkHighlightNode)\n currentNode = nodeByPointerGetter({\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n nodes: this.nodes,\n });\n if (!currentNode && (!checkHighlightNode || (!checkHighlightLink && !currentLink))) {\n currentLink = linkByPointerGetter({\n linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n links: this.links,\n curve: this.linkSettings.curve,\n });\n }\n\n if (!currentNode) return void this.listeners.onMove.call(this, event, currentNode, currentLink);\n }\n function onWheelClick(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent | TouchEvent) {\n if (\n this.isDragging ||\n !this.listeners.onWheelClick ||\n !(\"button\" in event) ||\n event.button !== 1\n )\n return;\n\n const currentNode = nodeByPointerGetter({\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n nodes: this.nodes,\n });\n\n if (!currentNode) {\n const currentLink = linkByPointerGetter({\n linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n links: this.links,\n curve: this.linkSettings.curve,\n });\n\n return void this.listeners.onWheelClick.call(this, event, undefined, currentLink);\n }\n\n return void this.listeners.onWheelClick.call(this, event, currentNode, undefined);\n }\n function onRightClick(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent) {\n if (!this.listeners.onContextMenu) return;\n\n const currentNode = nodeByPointerGetter({\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n nodes: this.nodes,\n });\n\n if (!currentNode) {\n const currentLink = linkByPointerGetter({\n linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n links: this.links,\n curve: this.linkSettings.curve,\n });\n\n return void this.listeners.onContextMenu.call(this, event, undefined, currentLink);\n }\n\n return void this.listeners.onContextMenu.call(this, event, currentNode, undefined);\n }\n function onDoubleClick(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent | TouchEvent) {\n if (!this.listeners.onDoubleClick) return;\n\n const currentNode = nodeByPointerGetter({\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n nodes: this.nodes,\n });\n if (!currentNode) {\n const currentLink = linkByPointerGetter({\n linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n links: this.links,\n curve: this.linkSettings.curve,\n });\n\n return void this.listeners.onDoubleClick.call(this, event, undefined, currentLink);\n }\n\n return void this.listeners.onDoubleClick.call(this, event, currentNode, undefined);\n }\n function onClick(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent | TouchEvent) {\n if (this.isDragging || !this.listeners.onClick || (\"button\" in event && event.button !== 0))\n return;\n const currentNode = nodeByPointerGetter({\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n nodes: this.nodes,\n });\n if (!currentNode) {\n const currentLink = linkByPointerGetter({\n linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n links: this.links,\n curve: this.linkSettings.curve,\n });\n\n return void this.listeners.onClick.call(this, event, undefined, currentLink);\n }\n\n return void this.listeners.onClick.call(this, event, currentNode, undefined);\n }\n\n /** hover */\n this.area.addEventListener(\"mousemove\", onHover.bind(this), {\n signal: this.eventAbortController.signal,\n });\n this.area.addEventListener(\"touchmove\", onHover.bind(this), {\n signal: this.eventAbortController.signal,\n });\n\n /** dblclick */\n this.area.addEventListener(\"dblclick\", onDoubleClick.bind(this), {\n signal: this.eventAbortController.signal,\n });\n\n /** wheel click */\n this.area.addEventListener(\"mousedown\", onWheelClick.bind(this), {\n signal: this.eventAbortController.signal,\n });\n\n /** click */\n this.area.addEventListener(\"click\", onClick.bind(this), {\n signal: this.eventAbortController.signal,\n });\n\n /** right click */\n this.area.addEventListener(\"contextmenu\", onRightClick.bind(this), {\n signal: this.eventAbortController.signal,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;SAIgB,WAAW,GAAA;IAIzB,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;IAE/D,SAAS,OAAO,CAAwC,KAA8B,EAAA;AACpF,QAAA,IAAI,CAAC,IAAI,CA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as } from \"../GraphCanvas\";\nimport { linkByPointerGetter, nodeByPointerGetter } from \"../lib\";\nimport type { LinkInterface, NodeInterface } from \"../types\";\n\nexport function initPointer<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.area || !this.nodes) throw new Error(\"bad init data\");\n\n function onHover(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent | TouchEvent) {\n if (!this.area || this.isSelecting) return;\n\n let currentNode: NodeInterface<NodeData> | undefined;\n let currentLink: LinkInterface<NodeData, LinkData> | undefined;\n const checkHighlightNode = this.highlightSettings.highlightByHoverNode && !this.isDragging;\n const checkHighlightLink = this.highlightSettings.highlightByHoverLink && !this.isDragging;\n let highlightNode = true;\n let highlightLink = true;\n\n if (checkHighlightNode) {\n const [pointerX, pointerY] = this.getPointerAreaPosition(event);\n currentNode = nodeByPointerGetter({\n pointerX,\n pointerY,\n nodes: this.nodes,\n });\n if (currentNode?.highlight != undefined) highlightNode = currentNode.highlight;\n }\n if (currentNode && highlightNode) {\n this.area.style.cursor = \"pointer\";\n } else if (checkHighlightLink) {\n const [pointerX, pointerY] = this.getPointerAreaPosition(event);\n currentLink = linkByPointerGetter({\n pointerX,\n pointerY,\n linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,\n links: this.links,\n curve: this.linkSettings.curve,\n });\n if (currentLink?.highlight != undefined) highlightLink = currentLink?.highlight;\n if (currentLink && highlightLink) {\n this.area.style.cursor = \"pointer\";\n } else {\n this.area.style.cursor = \"default\";\n }\n } else {\n this.area.style.cursor = \"default\";\n }\n this.animateHighlight(\n highlightNode ? currentNode : undefined,\n highlightLink ? currentLink : undefined,\n );\n\n if (!this.listeners.onMove) return;\n if (!currentNode && !checkHighlightNode) {\n const [pointerX, pointerY] = this.getPointerAreaPosition(event);\n currentNode = nodeByPointerGetter({\n pointerX,\n pointerY,\n nodes: this.nodes,\n });\n }\n if (!currentNode && (!checkHighlightNode || (!checkHighlightLink && !currentLink))) {\n const [pointerX, pointerY] = this.getPointerAreaPosition(event);\n currentLink = linkByPointerGetter({\n pointerX,\n pointerY,\n linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,\n links: this.links,\n curve: this.linkSettings.curve,\n });\n }\n if (!currentNode) return void this.listeners.onMove.call(this, event, currentNode, currentLink);\n }\n function onWheelClick(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent | TouchEvent) {\n if (\n this.isDragging ||\n !this.listeners.onWheelClick ||\n !(\"button\" in event) ||\n event.button !== 1\n )\n return;\n\n const [pointerX, pointerY] = this.getPointerAreaPosition(event);\n const currentNode = nodeByPointerGetter({\n pointerX,\n pointerY,\n nodes: this.nodes,\n });\n\n if (!currentNode) {\n const [pointerX, pointerY] = this.getPointerAreaPosition(event);\n const currentLink = linkByPointerGetter({\n pointerX,\n pointerY,\n linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,\n links: this.links,\n curve: this.linkSettings.curve,\n });\n\n return void this.listeners.onWheelClick.call(this, event, undefined, currentLink);\n }\n\n return void this.listeners.onWheelClick.call(this, event, currentNode, undefined);\n }\n function onRightClick(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent) {\n if (!this.listeners.onContextMenu) return;\n\n const [pointerX, pointerY] = this.getPointerAreaPosition(event);\n const currentNode = nodeByPointerGetter({\n pointerX,\n pointerY,\n nodes: this.nodes,\n });\n\n if (!currentNode) {\n const [pointerX, pointerY] = this.getPointerAreaPosition(event);\n const currentLink = linkByPointerGetter({\n pointerX,\n pointerY,\n linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,\n links: this.links,\n curve: this.linkSettings.curve,\n });\n\n return void this.listeners.onContextMenu.call(this, event, undefined, currentLink);\n }\n\n return void this.listeners.onContextMenu.call(this, event, currentNode, undefined);\n }\n function onDoubleClick(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent | TouchEvent) {\n if (!this.listeners.onDoubleClick) return;\n\n const [pointerX, pointerY] = this.getPointerAreaPosition(event);\n const currentNode = nodeByPointerGetter({\n pointerX,\n pointerY,\n nodes: this.nodes,\n });\n if (!currentNode) {\n const [pointerX, pointerY] = this.getPointerAreaPosition(event);\n const currentLink = linkByPointerGetter({\n pointerX,\n pointerY,\n linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,\n links: this.links,\n curve: this.linkSettings.curve,\n });\n\n return void this.listeners.onDoubleClick.call(this, event, undefined, currentLink);\n }\n\n return void this.listeners.onDoubleClick.call(this, event, currentNode, undefined);\n }\n function onClick(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent | TouchEvent) {\n if (this.isDragging || !this.listeners.onClick || (\"button\" in event && event.button !== 0))\n return;\n const [pointerX, pointerY] = this.getPointerAreaPosition(event);\n const currentNode = nodeByPointerGetter({\n pointerX,\n pointerY,\n nodes: this.nodes,\n });\n if (!currentNode) {\n const [pointerX, pointerY] = this.getPointerAreaPosition(event);\n const currentLink = linkByPointerGetter({\n pointerX,\n pointerY,\n linkHoverExtraZone: this.highlightSettings.linkHoverExtraZone,\n links: this.links,\n curve: this.linkSettings.curve,\n });\n\n return void this.listeners.onClick.call(this, event, undefined, currentLink);\n }\n\n return void this.listeners.onClick.call(this, event, currentNode, undefined);\n }\n\n /** hover */\n this.area.addEventListener(\"mousemove\", onHover.bind(this), {\n signal: this.eventAbortController.signal,\n });\n this.area.addEventListener(\"touchmove\", onHover.bind(this), {\n signal: this.eventAbortController.signal,\n });\n\n /** dblclick */\n this.area.addEventListener(\"dblclick\", onDoubleClick.bind(this), {\n signal: this.eventAbortController.signal,\n });\n\n /** wheel click */\n this.area.addEventListener(\"mousedown\", onWheelClick.bind(this), {\n signal: this.eventAbortController.signal,\n });\n\n /** click */\n this.area.addEventListener(\"click\", onClick.bind(this), {\n signal: this.eventAbortController.signal,\n });\n\n /** right click */\n this.area.addEventListener(\"contextmenu\", onRightClick.bind(this), {\n signal: this.eventAbortController.signal,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;SAIgB,WAAW,GAAA;IAIz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CAAC,EAAE;AACtD,QAAA,MAAM,EAAE,IAAI,CAAC,oBAAoB,CAAC,MAAM;AACzC,KAAA,CAAC;;AAGF,IAAA,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AACjE,QAAA,MAAM,EAAE,IAAI,CAAC,oBAAoB,CAAC,MAAM;AACzC,KAAA,CAAC;AACJ;;;;"}
@@ -24,7 +24,7 @@ function initResize() {
24
24
  });
25
25
  document.addEventListener("visibilitychange", () => {
26
26
  if (!document.hidden)
27
- this.updateRect();
27
+ this.updateSize();
28
28
  }, { signal: abortController.signal });
29
29
  observer.observe(this.area);
30
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"init-resize.js","sources":["../../../../../src/module/GraphCanvas/slices/init-resize.ts"],"sourcesContent":["import type { GraphCanvas } from \"../GraphCanvas\";\n\nexport function initResize<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.area) throw new Error(\"bad init data\");\n\n let initialResizeCall = true;\n\n const abortController = this.eventAbortController;\n const observer = new ResizeObserver(() => {\n if (initialResizeCall) {\n initialResizeCall = false;\n\n return;\n }\n\n if (abortController.signal.aborted) {\n observer.disconnect();\n\n return;\n }\n\n this.updateSize();\n requestAnimationFrame(() => {\n this.updateSize();\n });\n });\n\n document.addEventListener(\"scroll\", this.updateRect.bind(this), {\n capture: true,\n passive: true,\n signal: abortController.signal,\n });\n\n document.addEventListener(\n \"visibilitychange\",\n () => {\n if (!document.hidden) this.updateRect();\n },\n { signal: abortController.signal },\n );\n\n observer.observe(this.area);\n}\n"],"names":[],"mappings":"SAEgB,UAAU,GAAA;IAIxB,IAAI,CAAC,IAAI,CAAC,IAAI;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;IAEhD,IAAI,iBAAiB,GAAG,IAAI;AAE5B,IAAA,MAAM,eAAe,GAAG,IAAI,CAAC,oBAAoB;AACjD,IAAA,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,MAAK;QACvC,IAAI,iBAAiB,EAAE;YACrB,iBAAiB,GAAG,KAAK;YAEzB;;AAGF,QAAA,IAAI,eAAe,CAAC,MAAM,CAAC,OAAO,EAAE;YAClC,QAAQ,CAAC,UAAU,EAAE;YAErB;;QAGF,IAAI,CAAC,UAAU,EAAE;QACjB,qBAAqB,CAAC,MAAK;YACzB,IAAI,CAAC,UAAU,EAAE;AACnB,SAAC,CAAC;AACJ,KAAC,CAAC;AAEF,IAAA,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AAC9D,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,eAAe,CAAC,MAAM;AAC/B,KAAA,CAAC;AAEF,IAAA,QAAQ,CAAC,gBAAgB,CACvB,kBAAkB,EAClB,MAAK;QACH,IAAI,CAAC,QAAQ,CAAC,MAAM;YAAE,IAAI,CAAC,UAAU,EAAE;KACxC,EACD,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,CACnC;AAED,IAAA,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;AAC7B;;;;"}
1
+ {"version":3,"file":"init-resize.js","sources":["../../../../../src/module/GraphCanvas/slices/init-resize.ts"],"sourcesContent":["import type { GraphCanvas } from \"../GraphCanvas\";\n\nexport function initResize<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.area) throw new Error(\"bad init data\");\n\n let initialResizeCall = true;\n\n const abortController = this.eventAbortController;\n const observer = new ResizeObserver(() => {\n if (initialResizeCall) {\n initialResizeCall = false;\n\n return;\n }\n\n if (abortController.signal.aborted) {\n observer.disconnect();\n\n return;\n }\n\n this.updateSize();\n requestAnimationFrame(() => {\n this.updateSize();\n });\n });\n\n document.addEventListener(\"scroll\", this.updateRect.bind(this), {\n capture: true,\n passive: true,\n signal: abortController.signal,\n });\n\n document.addEventListener(\n \"visibilitychange\",\n () => {\n if (!document.hidden) this.updateSize();\n },\n { signal: abortController.signal },\n );\n\n observer.observe(this.area);\n}\n"],"names":[],"mappings":"SAEgB,UAAU,GAAA;IAIxB,IAAI,CAAC,IAAI,CAAC,IAAI;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;IAEhD,IAAI,iBAAiB,GAAG,IAAI;AAE5B,IAAA,MAAM,eAAe,GAAG,IAAI,CAAC,oBAAoB;AACjD,IAAA,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,MAAK;QACvC,IAAI,iBAAiB,EAAE;YACrB,iBAAiB,GAAG,KAAK;YAEzB;;AAGF,QAAA,IAAI,eAAe,CAAC,MAAM,CAAC,OAAO,EAAE;YAClC,QAAQ,CAAC,UAAU,EAAE;YAErB;;QAGF,IAAI,CAAC,UAAU,EAAE;QACjB,qBAAqB,CAAC,MAAK;YACzB,IAAI,CAAC,UAAU,EAAE;AACnB,SAAC,CAAC;AACJ,KAAC,CAAC;AAEF,IAAA,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AAC9D,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,eAAe,CAAC,MAAM;AAC/B,KAAA,CAAC;AAEF,IAAA,QAAQ,CAAC,gBAAgB,CACvB,kBAAkB,EAClB,MAAK;QACH,IAAI,CAAC,QAAQ,CAAC,MAAM;YAAE,IAAI,CAAC,UAAU,EAAE;KACxC,EACD,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,CACnC;AAED,IAAA,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;AAC7B;;;;"}
@@ -1,14 +1,5 @@
1
- import '../constants/force-settings.js';
2
- import '../constants/graph-settings.js';
3
- import '../constants/highlight-settings.js';
4
- import '../constants/link-settings.js';
5
- import '../constants/node-settings.js';
6
- import '@krainovsd/js-helpers';
7
- import { pointerGetter } from '../lib/utils/pointer-getter.js';
8
- import 'd3-array';
9
-
10
1
  function initSelection() {
11
- if (!this.area || !this.areaRect)
2
+ if (!this.area)
12
3
  throw new Error("bad init data");
13
4
  this.isSelecting = false;
14
5
  this.selectionRect = null;
@@ -18,11 +9,11 @@ function initSelection() {
18
9
  function onMouseDown(event) {
19
10
  if (event.button !== 0 || !event.shiftKey)
20
11
  return;
21
- if (!this.areaRect || !this.area)
12
+ if (!this.area)
22
13
  return;
23
14
  event.stopPropagation();
24
15
  event.preventDefault();
25
- const [startX, startY] = pointerGetter(event, this.areaRect, this.areaTransform);
16
+ const [startX, startY] = this.getPointerAreaPosition(event);
26
17
  this.isSelecting = true;
27
18
  localSelection = true;
28
19
  this.selectionRect = { x1: startX, y1: startY, x2: startX, y2: startY };
@@ -44,10 +35,10 @@ function initSelection() {
44
35
  }, { signal: controller.signal });
45
36
  }
46
37
  function onMouseMove(event) {
47
- if (!this.isSelecting || !this.selectionRect || !this.areaRect)
38
+ if (!this.isSelecting || !this.selectionRect)
48
39
  return;
49
40
  event.stopPropagation();
50
- const [x, y] = pointerGetter(event, this.areaRect, this.areaTransform);
41
+ const [x, y] = this.getPointerAreaPosition(event);
51
42
  this.selectionRect.x2 = x;
52
43
  this.selectionRect.y2 = y;
53
44
  const rect = normalizeRect(this.selectionRect);
@@ -1 +1 @@
1
- {"version":3,"file":"init-selection.js","sources":["../../../../../src/module/GraphCanvas/slices/init-selection.ts"],"sourcesContent":["import type { GraphCanvas } from \"../GraphCanvas\";\nimport { pointerGetter } from \"../lib\";\nimport type { LinkInterface, NodeInterface, NodeOptionsInterface } from \"../types\";\n\nexport function initSelection<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.area || !this.areaRect) throw new Error(\"bad init data\");\n\n this.isSelecting = false;\n this.selectionRect = null;\n let selectedNodesSet = new Set<NodeInterface<NodeData>>();\n let selectedLinksSet = new Set<LinkInterface<NodeData, LinkData>>();\n let localSelection = false;\n\n function onMouseDown(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent) {\n if (event.button !== 0 || !event.shiftKey) return;\n if (!this.areaRect || !this.area) return;\n event.stopPropagation();\n event.preventDefault();\n\n const [startX, startY] = pointerGetter(event, this.areaRect, this.areaTransform);\n this.isSelecting = true;\n localSelection = true;\n this.selectionRect = { x1: startX, y1: startY, x2: startX, y2: startY };\n selectedNodesSet = new Set<NodeInterface<NodeData>>();\n selectedLinksSet = new Set<LinkInterface<NodeData, LinkData>>();\n const controller = new AbortController();\n this.area.addEventListener(\"mousemove\", onMouseMove.bind(this), {\n signal: controller.signal,\n });\n this.area.addEventListener(\n \"mouseup\",\n () => {\n onMouseUp.call(this, controller);\n },\n {\n signal: controller.signal,\n },\n );\n window.addEventListener(\n \"keyup\",\n (event) => {\n if (event.key === \"Shift\") {\n onMouseUp.call(this, controller);\n }\n },\n { signal: controller.signal },\n );\n }\n\n function onMouseMove(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent) {\n if (!this.isSelecting || !this.selectionRect || !this.areaRect) return;\n event.stopPropagation();\n const [x, y] = pointerGetter(event, this.areaRect, this.areaTransform);\n this.selectionRect.x2 = x;\n this.selectionRect.y2 = y;\n const rect = normalizeRect(this.selectionRect);\n const newNodes = new Set<NodeInterface<NodeData>>();\n for (let i = 0; i < this.nodes.length; i++) {\n const node = this.nodes[i];\n if (node.x == undefined || node.y == undefined) continue;\n if (node.visible === false) continue;\n const cache = this.nodeOptionsCache[i];\n if (isNodeInRect(node, rect, cache)) {\n newNodes.add(node);\n }\n }\n const newLinks = new Set<LinkInterface<NodeData, LinkData>>();\n for (const link of this.links) {\n const source = link.source as NodeInterface<NodeData>;\n const target = link.target as NodeInterface<NodeData>;\n if (newNodes.has(source) && newNodes.has(target)) {\n newLinks.add(link);\n }\n }\n for (const node of selectedNodesSet) {\n if (!newNodes.has(node)) {\n node._selected = false;\n this.listeners.onSelectionOut?.call(this, node, undefined);\n }\n }\n for (const link of selectedLinksSet) {\n if (!newLinks.has(link)) {\n link._selected = false;\n this.listeners.onSelectionOut?.call(this, undefined, link);\n }\n }\n for (const node of newNodes) {\n if (!selectedNodesSet.has(node)) {\n node._selected = true;\n this.listeners.onSelectionIn?.call(this, node, undefined);\n }\n }\n for (const link of newLinks) {\n if (!selectedLinksSet.has(link)) {\n link._selected = true;\n this.listeners.onSelectionIn?.call(this, undefined, link);\n }\n }\n selectedNodesSet = newNodes;\n selectedLinksSet = newLinks;\n this.draw();\n }\n\n function onMouseUp(this: GraphCanvas<NodeData, LinkData>, controller: AbortController) {\n controller.abort();\n if (!this.isSelecting) return;\n const nodes = Array.from(selectedNodesSet);\n const links = Array.from(selectedLinksSet);\n for (const node of nodes) {\n node._selected = false;\n }\n for (const link of links) {\n link._selected = false;\n }\n this.isSelecting = false;\n this.selectionRect = null;\n selectedNodesSet = new Set<NodeInterface<NodeData>>();\n selectedLinksSet = new Set<LinkInterface<NodeData, LinkData>>();\n this.listeners.onSelectionEnd?.call(this, nodes, links);\n this.tick();\n }\n\n function onSelectionEnd(event: MouseEvent) {\n if (localSelection) {\n event.stopImmediatePropagation();\n localSelection = false;\n }\n }\n\n this.area.addEventListener(\"mousedown\", onMouseDown.bind(this), {\n signal: this.eventAbortController.signal,\n });\n this.area.addEventListener(\"click\", onSelectionEnd, { signal: this.eventAbortController.signal });\n}\n\nfunction normalizeRect(rect: { x1: number; y1: number; x2: number; y2: number }): {\n x: number;\n y: number;\n width: number;\n height: number;\n} {\n const x = Math.min(rect.x1, rect.x2);\n const y = Math.min(rect.y1, rect.y2);\n const width = Math.abs(rect.x2 - rect.x1);\n const height = Math.abs(rect.y2 - rect.y1);\n return { x, y, width, height };\n}\n\nfunction isNodeInRect<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n node: NodeInterface<NodeData>,\n rect: { x: number; y: number; width: number; height: number },\n cache: Required<NodeOptionsInterface<NodeData, LinkData>> | undefined,\n): boolean {\n const nx = node.x;\n const ny = node.y;\n if (nx == undefined || ny == undefined) return false;\n if (cache?.shape === \"circle\") {\n const r = cache.radius ?? 0;\n const closestX = Math.max(rect.x, Math.min(nx, rect.x + rect.width));\n const closestY = Math.max(rect.y, Math.min(ny, rect.y + rect.height));\n const dx = nx - closestX;\n const dy = ny - closestY;\n return dx * dx + dy * dy <= r * r;\n }\n const hw = (cache?.width ?? 0) / 2;\n const hh = (cache?.height ?? 0) / 2;\n return (\n nx - hw >= rect.x &&\n nx + hw <= rect.x + rect.width &&\n ny - hh >= rect.y &&\n ny + hh <= rect.y + rect.height\n );\n}\n"],"names":[],"mappings":";;;;;;;;;SAIgB,aAAa,GAAA;IAI3B,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;AAElE,IAAA,IAAI,CAAC,WAAW,GAAG,KAAK;AACxB,IAAA,IAAI,CAAC,aAAa,GAAG,IAAI;AACzB,IAAA,IAAI,gBAAgB,GAAG,IAAI,GAAG,EAA2B;AACzD,IAAA,IAAI,gBAAgB,GAAG,IAAI,GAAG,EAAqC;IACnE,IAAI,cAAc,GAAG,KAAK;IAE1B,SAAS,WAAW,CAAwC,KAAiB,EAAA;QAC3E,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ;YAAE;QAC3C,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE;QAClC,KAAK,CAAC,eAAe,EAAE;QACvB,KAAK,CAAC,cAAc,EAAE;AAEtB,QAAA,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC,KAAK,EAAE,IAA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,EAAE,MAAM,IAAI,CAAC,IAAI,CAAC;AACnC,IAAA,QACE,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,CAAC;QACjB,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK;AAC9B,QAAA,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,CAAC;QACjB,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM;AAEnC;;;;"}
1
+ {"version":3,"file":"init-selection.js","sources":["../../../../../src/module/GraphCanvas/slices/init-selection.ts"],"sourcesContent":["import type { GraphCanvas } from \"../GraphCanvas\";\nimport type { LinkInterface, NodeInterface, NodeOptionsInterface } from \"../types\";\n\nexport function initSelection<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.area) throw new Error(\"bad init data\");\n\n this.isSelecting = false;\n this.selectionRect = null;\n let selectedNodesSet = new Set<NodeInterface<NodeData>>();\n let selectedLinksSet = new Set<LinkInterface<NodeData, LinkData>>();\n let localSelection = false;\n\n function onMouseDown(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent) {\n if (event.button !== 0 || !event.shiftKey) return;\n if (!this.area) return;\n event.stopPropagation();\n event.preventDefault();\n\n const [startX, startY] = this.getPointerAreaPosition(event);\n this.isSelecting = true;\n localSelection = true;\n this.selectionRect = { x1: startX, y1: startY, x2: startX, y2: startY };\n selectedNodesSet = new Set<NodeInterface<NodeData>>();\n selectedLinksSet = new Set<LinkInterface<NodeData, LinkData>>();\n const controller = new AbortController();\n this.area.addEventListener(\"mousemove\", onMouseMove.bind(this), {\n signal: controller.signal,\n });\n this.area.addEventListener(\n \"mouseup\",\n () => {\n onMouseUp.call(this, controller);\n },\n {\n signal: controller.signal,\n },\n );\n window.addEventListener(\n \"keyup\",\n (event) => {\n if (event.key === \"Shift\") {\n onMouseUp.call(this, controller);\n }\n },\n { signal: controller.signal },\n );\n }\n\n function onMouseMove(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent) {\n if (!this.isSelecting || !this.selectionRect) return;\n event.stopPropagation();\n const [x, y] = this.getPointerAreaPosition(event);\n this.selectionRect.x2 = x;\n this.selectionRect.y2 = y;\n const rect = normalizeRect(this.selectionRect);\n const newNodes = new Set<NodeInterface<NodeData>>();\n for (let i = 0; i < this.nodes.length; i++) {\n const node = this.nodes[i];\n if (node.x == undefined || node.y == undefined) continue;\n if (node.visible === false) continue;\n const cache = this.nodeOptionsCache[i];\n if (isNodeInRect(node, rect, cache)) {\n newNodes.add(node);\n }\n }\n const newLinks = new Set<LinkInterface<NodeData, LinkData>>();\n for (const link of this.links) {\n const source = link.source as NodeInterface<NodeData>;\n const target = link.target as NodeInterface<NodeData>;\n if (newNodes.has(source) && newNodes.has(target)) {\n newLinks.add(link);\n }\n }\n for (const node of selectedNodesSet) {\n if (!newNodes.has(node)) {\n node._selected = false;\n this.listeners.onSelectionOut?.call(this, node, undefined);\n }\n }\n for (const link of selectedLinksSet) {\n if (!newLinks.has(link)) {\n link._selected = false;\n this.listeners.onSelectionOut?.call(this, undefined, link);\n }\n }\n for (const node of newNodes) {\n if (!selectedNodesSet.has(node)) {\n node._selected = true;\n this.listeners.onSelectionIn?.call(this, node, undefined);\n }\n }\n for (const link of newLinks) {\n if (!selectedLinksSet.has(link)) {\n link._selected = true;\n this.listeners.onSelectionIn?.call(this, undefined, link);\n }\n }\n selectedNodesSet = newNodes;\n selectedLinksSet = newLinks;\n this.draw();\n }\n\n function onMouseUp(this: GraphCanvas<NodeData, LinkData>, controller: AbortController) {\n controller.abort();\n if (!this.isSelecting) return;\n const nodes = Array.from(selectedNodesSet);\n const links = Array.from(selectedLinksSet);\n for (const node of nodes) {\n node._selected = false;\n }\n for (const link of links) {\n link._selected = false;\n }\n this.isSelecting = false;\n this.selectionRect = null;\n selectedNodesSet = new Set<NodeInterface<NodeData>>();\n selectedLinksSet = new Set<LinkInterface<NodeData, LinkData>>();\n this.listeners.onSelectionEnd?.call(this, nodes, links);\n this.tick();\n }\n\n function onSelectionEnd(event: MouseEvent) {\n if (localSelection) {\n event.stopImmediatePropagation();\n localSelection = false;\n }\n }\n\n this.area.addEventListener(\"mousedown\", onMouseDown.bind(this), {\n signal: this.eventAbortController.signal,\n });\n this.area.addEventListener(\"click\", onSelectionEnd, { signal: this.eventAbortController.signal });\n}\n\nfunction normalizeRect(rect: { x1: number; y1: number; x2: number; y2: number }): {\n x: number;\n y: number;\n width: number;\n height: number;\n} {\n const x = Math.min(rect.x1, rect.x2);\n const y = Math.min(rect.y1, rect.y2);\n const width = Math.abs(rect.x2 - rect.x1);\n const height = Math.abs(rect.y2 - rect.y1);\n return { x, y, width, height };\n}\n\nfunction isNodeInRect<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n node: NodeInterface<NodeData>,\n rect: { x: number; y: number; width: number; height: number },\n cache: Required<NodeOptionsInterface<NodeData, LinkData>> | undefined,\n): boolean {\n const nx = node.x;\n const ny = node.y;\n if (nx == undefined || ny == undefined) return false;\n if (cache?.shape === \"circle\") {\n const r = cache.radius ?? 0;\n const closestX = Math.max(rect.x, Math.min(nx, rect.x + rect.width));\n const closestY = Math.max(rect.y, Math.min(ny, rect.y + rect.height));\n const dx = nx - closestX;\n const dy = ny - closestY;\n return dx * dx + dy * dy <= r * r;\n }\n const hw = (cache?.width ?? 0) / 2;\n const hh = (cache?.height ?? 0) / 2;\n return (\n nx - hw >= rect.x &&\n nx + hw <= rect.x + rect.width &&\n ny - hh >= rect.y &&\n ny + hh <= rect.y + rect.height\n );\n}\n"],"names":[],"mappings":"SAGgB,aAAa,GAAA;IAI3B,IAAI,CAAC,IAAI,CAAC,IAAI;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;AAEhD,IAAA,IAAI,CAAC,WAAW,GAAG,KAAK;AACxB,IAAA,IAAI,CAAC,aAAa,GAAG,IAAI;AACzB,IAAA,IAA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AG,IAAI,CAAC,MAAM,CAAC,CAAC;AACrE,QAAA,MAAM,EAAE,GAAG,EAAE,GAAG,QAAQ;AACxB,QAAA,MAAM,EAAE,GAAG,EAAE,GAAG,QAAQ;QACxB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;;IAEnC,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC;IAClC,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,IAAI,CAAC;AACnC,IAAA,QACE,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,CAAC;QACjB,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK;AAC9B,QAAA,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,CAAC;QACjB,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM;AAEnC;;;;"}
package/lib/index.d.ts CHANGED
@@ -392,7 +392,6 @@ declare class GraphCanvas<NodeData extends Record<string, unknown>, LinkData ext
392
392
  protected simulation: GraphCanvasSimulation<NodeData, LinkData> | undefined;
393
393
  protected areaTransform: ZoomTransform;
394
394
  protected _translateExtent: [[number, number], [number, number]] | undefined;
395
- protected areaRect: DOMRect | undefined;
396
395
  protected draw: (this: GraphCanvas<NodeData, LinkData>) => void;
397
396
  protected eventAbortController: AbortController;
398
397
  protected cachedNodeText: (string[] | undefined)[];
@@ -417,6 +416,7 @@ declare class GraphCanvas<NodeData extends Record<string, unknown>, LinkData ext
417
416
  x2: number;
418
417
  y2: number;
419
418
  } | null;
419
+ protected areaRect: DOMRect | undefined;
420
420
  protected get simulationWorking(): boolean;
421
421
  constructor({ links, nodes, root, forceSettings, linkSettings, listeners, nodeSettings, graphSettings, highlightSettings, }: GraphCanvasInterface<NodeData, LinkData>);
422
422
  get dpi(): number;
@@ -434,6 +434,7 @@ declare class GraphCanvas<NodeData extends Record<string, unknown>, LinkData ext
434
434
  stop: () => void;
435
435
  create: () => void;
436
436
  destroy: () => void;
437
+ protected getPointerAreaPosition: (event: MouseEvent | TouchEvent) => number[];
437
438
  protected clearHTMLElements: () => void;
438
439
  protected updateSimulation: (precompute?: boolean) => void;
439
440
  protected clearState: () => void;
@@ -497,7 +498,7 @@ interface GraphBounds {
497
498
  }
498
499
  declare function computeGraphBounds<NodeData extends Record<string, unknown>>(nodes: NodeInterface<NodeData>[]): GraphBounds | null;
499
500
 
500
- declare function pointerGetter(mouseEvent: MouseEvent | TouchEvent, areaRect: DOMRect, areaTransform: ZoomTransform): number[];
501
+ declare function pointerGetter(mouseEvent: MouseEvent | TouchEvent, areaRect: DOMRect | undefined, areaTransform: ZoomTransform): number[];
501
502
 
502
503
  declare function dragPlaceCoefficientGetter<NodeData extends Record<string, unknown>>(node: NodeInterface<NodeData>, pointerX: number, pointerY: number): number | undefined;
503
504
 
@@ -507,12 +508,11 @@ declare function linkIterationExtractor<NodeData extends Record<string, unknown>
507
508
  declare function linkIterationExtractor<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>, Result extends string | number | boolean | Record<string, unknown> | unknown[]>(link: LinkInterface<NodeData, LinkData>, i: number, links: LinkInterface<NodeData, LinkData>[], state: GraphCanvas<NodeData, LinkData>, option: LinkIterationPropsInterface<NodeData, LinkData, Result> | Result, optionConstantGetter: LinkIterationPropsInterface<NodeData, LinkData, Required<Result>> | Required<Result>): Required<Result>;
508
509
 
509
510
  type NodeByPointerGetterOptions<NodeData extends Record<string, unknown>> = {
510
- mouseEvent: MouseEvent | TouchEvent;
511
- areaRect: DOMRect | undefined;
512
- areaTransform: ZoomTransform;
511
+ pointerX: number;
512
+ pointerY: number;
513
513
  nodes: NodeInterface<NodeData>[];
514
514
  };
515
- declare function nodeByPointerGetter<NodeData extends Record<string, unknown>>({ areaRect, areaTransform, mouseEvent, nodes, }: NodeByPointerGetterOptions<NodeData>): NodeInterface<NodeData> | undefined;
515
+ declare function nodeByPointerGetter<NodeData extends Record<string, unknown>>({ pointerX, pointerY, nodes, }: NodeByPointerGetterOptions<NodeData>): NodeInterface<NodeData> | undefined;
516
516
 
517
517
  declare function nodeIterationExtractor<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>, Result extends string | number | boolean | Record<string, unknown> | unknown[] | undefined | null>(node: NodeInterface<NodeData>, i: number, nodes: NodeInterface<NodeData>[], state: GraphCanvas<NodeData, LinkData>, option: NodeIterationPropsInterface<NodeData, LinkData, Result> | Result, optionConstantGetter: undefined): Result;
518
518
  declare function nodeIterationExtractor<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>, Result extends string | number | boolean | Record<string, unknown> | unknown[] | undefined | null>(node: NodeInterface<NodeData>, i: number, nodes: NodeInterface<NodeData>[], state: GraphCanvas<NodeData, LinkData>, option: NodeIterationPropsInterface<NodeData, LinkData, Result> | Result, optionConstantGetter: NodeIterationPropsInterface<NodeData, LinkData, Result> | Result): Required<Result>;
@@ -553,14 +553,13 @@ declare function getParticlePosition(opts: GetParticlePositionOptions): void;
553
553
  declare function approximateQuadraticBezierLength(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): number;
554
554
 
555
555
  type LinkByPointerGetterOptions<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
556
- mouseEvent: MouseEvent | TouchEvent;
557
- areaRect: DOMRect | undefined;
558
- areaTransform: ZoomTransform;
556
+ pointerX: number;
557
+ pointerY: number;
559
558
  links: LinkInterface<NodeData, LinkData>[];
560
559
  linkHoverExtraZone: number;
561
560
  curve: boolean;
562
561
  };
563
- declare function linkByPointerGetter<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>({ areaRect, areaTransform, mouseEvent, links, linkHoverExtraZone, curve, }: LinkByPointerGetterOptions<NodeData, LinkData>): LinkInterface<NodeData, LinkData> | undefined;
562
+ declare function linkByPointerGetter<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>({ pointerX, pointerY, links, linkHoverExtraZone, curve, }: LinkByPointerGetterOptions<NodeData, LinkData>): LinkInterface<NodeData, LinkData> | undefined;
564
563
 
565
564
  type NodeHighlightOptions<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
566
565
  nodeOptions: Required<NodeOptionsInterface<NodeData, LinkData>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krainovsd/graph",
3
- "version": "0.14.0-beta.4",
3
+ "version": "0.14.0-beta.6",
4
4
  "description": "Krainov graph",
5
5
  "type": "module",
6
6
  "author": "KrainovSD <denislosev48@gmail.com>",