@krainovsd/graph 0.10.0-rc5 → 0.10.0-rc7
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.
- package/lib/cjs/index.cjs +1897 -1318
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/constants/force-controls.js +141 -0
- package/lib/esm/constants/force-controls.js.map +1 -0
- package/lib/esm/constants/graph-controls.js +25 -0
- package/lib/esm/constants/graph-controls.js.map +1 -0
- package/lib/esm/constants/highlight-controls.js +452 -0
- package/lib/esm/constants/highlight-controls.js.map +1 -0
- package/lib/esm/constants/link-controls.js +219 -0
- package/lib/esm/constants/link-controls.js.map +1 -0
- package/lib/esm/constants/node-controls.js +345 -0
- package/lib/esm/constants/node-controls.js.map +1 -0
- package/lib/esm/index.js +24 -3
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/lib/fade-rgb.js.map +1 -1
- package/lib/esm/lib/rgb-animation-by-progress.js.map +1 -1
- package/lib/esm/module/GraphCanvas/GraphCanvas.js +16 -27
- package/lib/esm/module/GraphCanvas/GraphCanvas.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/common-settings.js +7 -0
- package/lib/esm/module/GraphCanvas/constants/common-settings.js.map +1 -0
- package/lib/esm/module/GraphCanvas/constants/force-settings.js +28 -0
- package/lib/esm/module/GraphCanvas/constants/force-settings.js.map +1 -0
- package/lib/esm/module/GraphCanvas/constants/graph-settings.js +19 -0
- package/lib/esm/module/GraphCanvas/constants/graph-settings.js.map +1 -0
- package/lib/esm/module/GraphCanvas/constants/highlight-settings.js +62 -0
- package/lib/esm/module/GraphCanvas/constants/highlight-settings.js.map +1 -0
- package/lib/esm/module/GraphCanvas/constants/link-settings.js +31 -0
- package/lib/esm/module/GraphCanvas/constants/link-settings.js.map +1 -0
- package/lib/esm/module/GraphCanvas/constants/node-settings.js +50 -0
- package/lib/esm/module/GraphCanvas/constants/node-settings.js.map +1 -0
- package/lib/esm/module/GraphCanvas/lib/settings/force-settings-getter.js +3 -1
- package/lib/esm/module/GraphCanvas/lib/settings/force-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/graph-settings-getter.js +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/graph-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/highlight-settings-getter.js +13 -0
- package/lib/esm/module/GraphCanvas/lib/settings/highlight-settings-getter.js.map +1 -0
- package/lib/esm/module/GraphCanvas/lib/settings/link-settings-getter.js +13 -11
- package/lib/esm/module/GraphCanvas/lib/settings/link-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js +22 -20
- package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js +8 -4
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/drag-place-coefficient-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/get-particle-position.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js +3 -1
- package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/is-overlaps-node.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/link-by-pointer-getter.js +2 -2
- package/lib/esm/module/GraphCanvas/lib/utils/link-by-pointer-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/link-highlight.js +66 -0
- package/lib/esm/module/GraphCanvas/lib/utils/link-highlight.js.map +1 -0
- package/lib/esm/module/GraphCanvas/lib/utils/link-iteration-extractor.js +2 -3
- package/lib/esm/module/GraphCanvas/lib/utils/link-iteration-extractor.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/node-by-pointer-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/node-highlight.js +115 -0
- package/lib/esm/module/GraphCanvas/lib/utils/node-highlight.js.map +1 -0
- package/lib/esm/module/GraphCanvas/lib/utils/node-iteration-extractor.js +2 -3
- package/lib/esm/module/GraphCanvas/lib/utils/node-iteration-extractor.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/draw-links.js +90 -60
- package/lib/esm/module/GraphCanvas/slices/draw-links.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/draw-nodes.js +214 -135
- package/lib/esm/module/GraphCanvas/slices/draw-nodes.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/draw-text.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-dnd.js +4 -4
- package/lib/esm/module/GraphCanvas/slices/init-dnd.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-draw.js +4 -15
- package/lib/esm/module/GraphCanvas/slices/init-draw.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-pointer.js +17 -17
- package/lib/esm/module/GraphCanvas/slices/init-pointer.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-simulation.js +22 -23
- package/lib/esm/module/GraphCanvas/slices/init-simulation.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-zoom.js +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-zoom.js.map +1 -1
- package/lib/index.d.ts +436 -221
- package/package.json +1 -1
- package/lib/esm/lib/get-controls-info.js +0 -915
- package/lib/esm/lib/get-controls-info.js.map +0 -1
- package/lib/esm/module/GraphCanvas/constants/settings.js +0 -158
- package/lib/esm/module/GraphCanvas/constants/settings.js.map +0 -1
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '@krainovsd/js-helpers';
|
|
2
|
+
import 'd3-array';
|
|
3
|
+
import { LINK_SETTINGS, LINK_OPTIONS } from '../../constants/link-settings.js';
|
|
2
4
|
|
|
3
5
|
function linkSettingsGetter(settings, prevSettings) {
|
|
4
6
|
return { ...(prevSettings ?? LINK_SETTINGS), ...settings };
|
|
5
7
|
}
|
|
6
|
-
function linkOptionsGetter(
|
|
8
|
+
function linkOptionsGetter() {
|
|
7
9
|
return {
|
|
8
10
|
...LINK_OPTIONS,
|
|
9
11
|
drawExtraLink: null,
|
|
10
12
|
drawLink: null,
|
|
11
|
-
color:
|
|
12
|
-
?
|
|
13
|
-
:
|
|
14
|
-
arrowColor:
|
|
15
|
-
?
|
|
16
|
-
:
|
|
17
|
-
width:
|
|
18
|
-
?
|
|
19
|
-
:
|
|
13
|
+
color: this.areaTransform && this.areaTransform.k > this.linkSettings.linkScaleSwitch
|
|
14
|
+
? this.linkSettings.linkColorAfterScaleSwitch
|
|
15
|
+
: this.linkSettings.linkColorBeforeScaleSwitch,
|
|
16
|
+
arrowColor: this.areaTransform && this.areaTransform.k > this.linkSettings.linkScaleSwitch
|
|
17
|
+
? this.linkSettings.linkColorAfterScaleSwitch
|
|
18
|
+
: this.linkSettings.linkColorBeforeScaleSwitch,
|
|
19
|
+
width: this.areaTransform && this.areaTransform.k > this.linkSettings.linkScaleSwitch
|
|
20
|
+
? this.linkSettings.linkWidthAfterScaleSwitch
|
|
21
|
+
: this.linkSettings.linkWidthBeforeScaleSwitch,
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/link-settings-getter.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"link-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/link-settings-getter.ts"],"sourcesContent":["import type { GraphCanvas } from \"../../GraphCanvas\";\nimport { LINK_OPTIONS, LINK_SETTINGS } from \"../../constants\";\nimport type { LinkOptionsInterface, LinkSettingsInterface } from \"../../types\";\n\nexport function linkSettingsGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n settings: LinkSettingsInterface<NodeData, LinkData> | undefined,\n prevSettings?: Required<Omit<LinkSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<LinkSettingsInterface<NodeData, LinkData>, \"options\">,\n): Required<Omit<LinkSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<LinkSettingsInterface<NodeData, LinkData>, \"options\"> {\n return { ...(prevSettings ?? LINK_SETTINGS), ...settings };\n}\n\nexport function linkOptionsGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>): Required<LinkOptionsInterface<NodeData, LinkData>> {\n return {\n ...LINK_OPTIONS,\n drawExtraLink: null,\n drawLink: null,\n color:\n this.areaTransform && this.areaTransform.k > this.linkSettings.linkScaleSwitch\n ? this.linkSettings.linkColorAfterScaleSwitch\n : this.linkSettings.linkColorBeforeScaleSwitch,\n arrowColor:\n this.areaTransform && this.areaTransform.k > this.linkSettings.linkScaleSwitch\n ? this.linkSettings.linkColorAfterScaleSwitch\n : this.linkSettings.linkColorBeforeScaleSwitch,\n width:\n this.areaTransform && this.areaTransform.k > this.linkSettings.linkScaleSwitch\n ? this.linkSettings.linkWidthAfterScaleSwitch\n : this.linkSettings.linkWidthBeforeScaleSwitch,\n };\n}\n"],"names":[],"mappings":";;;;AAIgB,SAAA,kBAAkB,CAIhC,QAA+D,EAC/D,YAC4D,EAAA;IAG5D,OAAO,EAAE,IAAI,YAAY,IAAI,aAAa,CAAC,EAAE,GAAG,QAAQ,EAAE;AAC5D;SAEgB,iBAAiB,GAAA;IAI/B,OAAO;AACL,QAAA,GAAG,YAAY;AACf,QAAA,aAAa,EAAE,IAAI;AACnB,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,KAAK,EACH,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;AAC7D,cAAE,IAAI,CAAC,YAAY,CAAC;AACpB,cAAE,IAAI,CAAC,YAAY,CAAC,0BAA0B;AAClD,QAAA,UAAU,EACR,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;AAC7D,cAAE,IAAI,CAAC,YAAY,CAAC;AACpB,cAAE,IAAI,CAAC,YAAY,CAAC,0BAA0B;AAClD,QAAA,KAAK,EACH,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;AAC7D,cAAE,IAAI,CAAC,YAAY,CAAC;AACpB,cAAE,IAAI,CAAC,YAAY,CAAC,0BAA0B;KACnD;AACH;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { colorGetter } from '../../../../lib/color-getter.js';
|
|
2
2
|
import '@krainovsd/js-helpers';
|
|
3
|
-
import
|
|
3
|
+
import 'd3-array';
|
|
4
|
+
import { NODE_SETTINGS, NODE_OPTIONS } from '../../constants/node-settings.js';
|
|
4
5
|
|
|
5
6
|
function nodeSettingsGetter(settings, prevNodeSettings) {
|
|
6
7
|
return {
|
|
@@ -10,8 +11,8 @@ function nodeSettingsGetter(settings, prevNodeSettings) {
|
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
13
|
const color = colorGetter();
|
|
13
|
-
function nodeOptionsGetter(node
|
|
14
|
-
const { textShiftY, textSize } = nodeTextSizeGetter(
|
|
14
|
+
function nodeOptionsGetter(node) {
|
|
15
|
+
const { textShiftY, textSize } = nodeTextSizeGetter(this.areaTransform, this.nodeSettings);
|
|
15
16
|
return {
|
|
16
17
|
...NODE_OPTIONS,
|
|
17
18
|
nodeDraw: null,
|
|
@@ -19,30 +20,31 @@ function nodeOptionsGetter(node, _, __, state) {
|
|
|
19
20
|
textDraw: null,
|
|
20
21
|
textExtraDraw: null,
|
|
21
22
|
color: color(String(node.group ?? "_DEFAULT")),
|
|
22
|
-
textVisible: Boolean(
|
|
23
|
+
textVisible: Boolean(this.areaTransform.k > this.nodeSettings.textScaleMin),
|
|
23
24
|
text: node.name ?? node.id.toString(),
|
|
24
25
|
textShiftY,
|
|
25
26
|
textSize,
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
|
-
function nodeTextSizeGetter(transform) {
|
|
29
|
-
let textSize =
|
|
30
|
-
let textShiftY =
|
|
29
|
+
function nodeTextSizeGetter(transform, nodeSettings) {
|
|
30
|
+
let textSize = nodeSettings.textSizeMin;
|
|
31
|
+
let textShiftY = nodeSettings.textShiftYMin;
|
|
31
32
|
if (transform) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
COMMON_SETTINGS.nodeTextChangeStepCount;
|
|
36
|
-
const shiftStepCoefficient = (COMMON_SETTINGS.nodeTextShiftYMax - COMMON_SETTINGS.nodeTextShiftYMin) /
|
|
37
|
-
COMMON_SETTINGS.nodeTextChangeStepCount;
|
|
38
|
-
if (transform.k >= COMMON_SETTINGS.nodeTextScaleMax) {
|
|
39
|
-
textSize = COMMON_SETTINGS.nodeTextSizeMin;
|
|
40
|
-
textShiftY = COMMON_SETTINGS.nodeTextShiftYMin;
|
|
33
|
+
if (transform.k >= nodeSettings.textScaleMax) {
|
|
34
|
+
textSize = nodeSettings.textSizeMax;
|
|
35
|
+
textShiftY = nodeSettings.textShiftYMax;
|
|
41
36
|
}
|
|
42
|
-
else if (transform.k >
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
else if (transform.k > nodeSettings.textScaleMin) {
|
|
38
|
+
textSize =
|
|
39
|
+
nodeSettings.textSizeMin +
|
|
40
|
+
((transform.k - nodeSettings.textScaleMin) *
|
|
41
|
+
(nodeSettings.textSizeMax - nodeSettings.textSizeMin)) /
|
|
42
|
+
(nodeSettings.textScaleMax - nodeSettings.textScaleMin);
|
|
43
|
+
textShiftY =
|
|
44
|
+
nodeSettings.textShiftYMin +
|
|
45
|
+
((transform.k - nodeSettings.textScaleMin) *
|
|
46
|
+
(nodeSettings.textShiftYMax - nodeSettings.textShiftYMin)) /
|
|
47
|
+
(nodeSettings.textScaleMax - nodeSettings.textScaleMin);
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
return { textSize, textShiftY };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/node-settings-getter.ts"],"sourcesContent":["import type { ZoomTransform } from \"d3-zoom\";\nimport { colorGetter } from \"@/lib\";\nimport type {
|
|
1
|
+
{"version":3,"file":"node-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/node-settings-getter.ts"],"sourcesContent":["import type { ZoomTransform } from \"d3-zoom\";\nimport { colorGetter } from \"@/lib\";\nimport type { GraphCanvas } from \"../../GraphCanvas\";\nimport { NODE_OPTIONS, NODE_SETTINGS } from \"../../constants\";\nimport type { NodeInterface, NodeOptionsInterface, NodeSettingsInterface } from \"../../types\";\n\nexport function nodeSettingsGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n settings: NodeSettingsInterface<NodeData, LinkData> | undefined,\n prevNodeSettings?: Required<Omit<NodeSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<NodeSettingsInterface<NodeData, LinkData>, \"options\">,\n): Required<Omit<NodeSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<NodeSettingsInterface<NodeData, LinkData>, \"options\"> {\n return {\n ...(prevNodeSettings ?? NODE_SETTINGS),\n idGetter: nodeIdGetter,\n ...settings,\n };\n}\n\nconst color = colorGetter();\n\nexport function nodeOptionsGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n this: GraphCanvas<NodeData, LinkData>,\n node: NodeInterface<NodeData>,\n): Required<NodeOptionsInterface<NodeData, LinkData>> {\n const { textShiftY, textSize } = nodeTextSizeGetter(this.areaTransform, this.nodeSettings);\n\n return {\n ...NODE_OPTIONS,\n nodeDraw: null,\n nodeExtraDraw: null,\n textDraw: null,\n textExtraDraw: null,\n color: color(String(node.group ?? \"_DEFAULT\")),\n textVisible: Boolean(this.areaTransform.k > this.nodeSettings.textScaleMin),\n text: node.name ?? node.id.toString(),\n textShiftY,\n textSize,\n };\n}\n\nexport function nodeTextSizeGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n transform: ZoomTransform | undefined,\n nodeSettings: Required<Omit<NodeSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<NodeSettingsInterface<NodeData, LinkData>, \"options\">,\n) {\n let textSize: number = nodeSettings.textSizeMin;\n let textShiftY: number = nodeSettings.textShiftYMin;\n\n if (transform) {\n if (transform.k >= nodeSettings.textScaleMax) {\n textSize = nodeSettings.textSizeMax;\n textShiftY = nodeSettings.textShiftYMax;\n } else if (transform.k > nodeSettings.textScaleMin) {\n textSize =\n nodeSettings.textSizeMin +\n ((transform.k - nodeSettings.textScaleMin) *\n (nodeSettings.textSizeMax - nodeSettings.textSizeMin)) /\n (nodeSettings.textScaleMax - nodeSettings.textScaleMin);\n\n textShiftY =\n nodeSettings.textShiftYMin +\n ((transform.k - nodeSettings.textScaleMin) *\n (nodeSettings.textShiftYMax - nodeSettings.textShiftYMin)) /\n (nodeSettings.textScaleMax - nodeSettings.textScaleMin);\n }\n }\n\n return { textSize, textShiftY };\n}\n\nexport type NodeRadiusGetterOptions = {\n linkCount: number | undefined;\n radiusFlexible: boolean;\n radiusCoefficient: number;\n radiusFactor: number;\n radiusInitial: number;\n};\n\nexport function nodeRadiusGetter({\n radiusFlexible,\n radiusInitial,\n linkCount,\n radiusCoefficient,\n radiusFactor,\n}: NodeRadiusGetterOptions) {\n return (\n (radiusFlexible && linkCount ? linkCount / radiusCoefficient : 0) * radiusFactor + radiusInitial\n );\n}\n\nexport type NodeSizeGetterOptions = {\n linkCount: number | undefined;\n sizeFlexible: boolean;\n sizeCoefficient: number;\n sizeFactor: number;\n widthInitial: number;\n heightInitial: number;\n};\n\nexport function nodeSizeGetter({\n heightInitial,\n linkCount,\n sizeCoefficient,\n sizeFactor,\n sizeFlexible,\n widthInitial,\n}: NodeSizeGetterOptions) {\n let additionalSizeCoefficient = 1;\n if (sizeFlexible && linkCount != undefined) {\n additionalSizeCoefficient += (linkCount / sizeCoefficient) * sizeFactor;\n }\n\n return {\n width: widthInitial * additionalSizeCoefficient,\n height: heightInitial * additionalSizeCoefficient,\n additionalSizeCoefficient,\n };\n}\n\nexport function nodeIdGetter<NodeData extends Record<string, unknown>>(\n node: NodeInterface<NodeData>,\n) {\n return node.id;\n}\n"],"names":[],"mappings":";;;;;AAMgB,SAAA,kBAAkB,CAIhC,QAA+D,EAC/D,gBAC4D,EAAA;IAG5D,OAAO;AACL,QAAA,IAAI,gBAAgB,IAAI,aAAa,CAAC;AACtC,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,GAAG,QAAQ;KACZ;AACH;AAEA,MAAM,KAAK,GAAG,WAAW,EAAE;AAErB,SAAU,iBAAiB,CAK/B,IAA6B,EAAA;AAE7B,IAAA,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC;IAE1F,OAAO;AACL,QAAA,GAAG,YAAY;AACf,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,aAAa,EAAE,IAAI;AACnB,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,aAAa,EAAE,IAAI;QACnB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,UAAU,CAAC,CAAC;AAC9C,QAAA,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;QAC3E,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE;QACrC,UAAU;QACV,QAAQ;KACT;AACH;AAEgB,SAAA,kBAAkB,CAIhC,SAAoC,EACpC,YAC4D,EAAA;AAE5D,IAAA,IAAI,QAAQ,GAAW,YAAY,CAA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;;IAGzE,OAAO;QACL,KAAK,EAAE,YAAY,GAAG,yBAAyB;QAC/C,MAAM,EAAE,aAAa,GAAG,yBAAyB;QACjD,yBAAyB;KAC1B;AACH;AAEM,SAAU,YAAY,CAC1B,IAA6B,EAAA;IAE7B,OAAO,IAAI,CAAC,EAAE;AAChB;;;;"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { COMMON_SETTINGS } from '../../constants/settings.js';
|
|
1
|
+
import { COMMON_SETTINGS } from '../../constants/common-settings.js';
|
|
2
|
+
import '@krainovsd/js-helpers';
|
|
3
|
+
import 'd3-array';
|
|
2
4
|
|
|
5
|
+
/* eslint-disable id-length */
|
|
3
6
|
function calculateLinkPositionByNode(link, arrowSize = 0) {
|
|
4
7
|
const source = link.source;
|
|
5
8
|
const target = link.target;
|
|
@@ -40,7 +43,8 @@ function getLinkPoint(opts) {
|
|
|
40
43
|
nodePoint = getCircleIntersection({
|
|
41
44
|
x: opts.node.x,
|
|
42
45
|
y: opts.node.y,
|
|
43
|
-
radius: opts.node._radius ?? COMMON_SETTINGS.nodeRadius
|
|
46
|
+
radius: (opts.node._radius ?? COMMON_SETTINGS.nodeRadius) +
|
|
47
|
+
(opts.node._borderWidth ? opts.node._borderWidth / 2 : 0),
|
|
44
48
|
oppositeX: opts.oppositeNode.x,
|
|
45
49
|
oppositeY: opts.oppositeNode.y,
|
|
46
50
|
arrowSize: opts.arrowSize,
|
|
@@ -53,8 +57,8 @@ function getLinkPoint(opts) {
|
|
|
53
57
|
arrowSize: opts.arrowSize,
|
|
54
58
|
x: opts.node.x,
|
|
55
59
|
y: opts.node.y,
|
|
56
|
-
height: opts.node._height ?? COMMON_SETTINGS.nodeSize,
|
|
57
|
-
width: opts.node._width ?? COMMON_SETTINGS.nodeSize,
|
|
60
|
+
height: (opts.node._height ?? COMMON_SETTINGS.nodeSize) + (opts.node._borderWidth ?? 0),
|
|
61
|
+
width: (opts.node._width ?? COMMON_SETTINGS.nodeSize) + (opts.node._borderWidth ?? 0),
|
|
58
62
|
oppositeX: opts.oppositeNode.x,
|
|
59
63
|
oppositeY: opts.oppositeNode.y,
|
|
60
64
|
borderRadius: opts.node._shape === "text" ? 0 : (opts.node._borderRadius ?? 0),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-link-position-by-node.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/calculate-link-position-by-node.ts"],"sourcesContent":["/* eslint-disable id-length */\nimport type { LinkInterface, NodeInterface } from \"@/types\";\nimport { COMMON_SETTINGS } from \"../../constants\";\n\ntype Point = {\n x: number;\n y: number;\n};\n\nexport function calculateLinkPositionByNode<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(link: LinkInterface<NodeData, LinkData>, arrowSize = 0) {\n const source = link.source;\n const target = link.target;\n\n if (typeof source != \"object\" || typeof target != \"object\") return null;\n\n const sourcePoint = getLinkPoint({\n arrowSize: 0,\n node: source,\n oppositeNode: target,\n });\n const targetPoint = getLinkPoint({\n arrowSize: arrowSize > 0 ? arrowSize * 0.85 : 0,\n node: target,\n oppositeNode: source,\n });\n\n if (!sourcePoint || !targetPoint) return null;\n\n const distance =\n targetPoint && sourcePoint\n ? Math.sqrt((targetPoint.x - sourcePoint.x) ** 2 + (targetPoint.y - sourcePoint.y) ** 2)\n : 0;\n\n return {\n x1: sourcePoint.x,\n y1: sourcePoint.y,\n x2: targetPoint.x,\n y2: targetPoint.y,\n distance,\n };\n}\n\ntype GetLinkPointProps<NodeData extends Record<string, unknown>> = {\n arrowSize: number;\n node: NodeInterface<NodeData>;\n oppositeNode: NodeInterface<NodeData>;\n};\nfunction getLinkPoint<NodeData extends Record<string, unknown>>(opts: GetLinkPointProps<NodeData>) {\n if (\n opts.node.x == undefined ||\n opts.node.y == undefined ||\n opts.oppositeNode.x == undefined ||\n opts.oppositeNode.y == undefined\n )\n return null;\n\n let nodePoint: Point;\n switch (opts.node._shape) {\n case \"circle\": {\n nodePoint = getCircleIntersection({\n x: opts.node.x,\n y: opts.node.y,\n radius: opts.node._radius ?? COMMON_SETTINGS.nodeRadius,\n oppositeX: opts.oppositeNode.x,\n oppositeY: opts.oppositeNode.y,\n arrowSize: opts.arrowSize,\n });\n break;\n }\n case \"square\":\n case \"text\": {\n nodePoint = getRectangleIntersection({\n arrowSize: opts.arrowSize,\n x: opts.node.x,\n y: opts.node.y,\n height: opts.node._height ?? COMMON_SETTINGS.nodeSize,\n width: opts.node._width ?? COMMON_SETTINGS.nodeSize,\n oppositeX: opts.oppositeNode.x,\n oppositeY: opts.oppositeNode.y,\n borderRadius: opts.node._shape === \"text\" ? 0 : (opts.node._borderRadius ?? 0),\n });\n break;\n }\n default: {\n nodePoint = getCircleIntersection({\n x: opts.node.x,\n y: opts.node.y,\n radius: opts.node._radius ?? COMMON_SETTINGS.nodeRadius,\n oppositeX: opts.oppositeNode.x,\n oppositeY: opts.oppositeNode.y,\n arrowSize: opts.arrowSize,\n });\n }\n }\n\n return nodePoint;\n}\n\ntype GetCircleIntersection = {\n x: number;\n y: number;\n radius: number;\n oppositeX: number;\n oppositeY: number;\n arrowSize: number;\n};\n\nfunction getCircleIntersection(opts: GetCircleIntersection): Point {\n const dx = opts.oppositeX - opts.x;\n const dy = opts.oppositeY - opts.y;\n const dr = Math.sqrt(dx * dx + dy * dy);\n\n const radius = opts.radius + opts.arrowSize;\n\n return {\n x: opts.x + (dx * radius) / dr,\n y: opts.y + (dy * radius) / dr,\n };\n}\n\ntype GetRectangleIntersection = {\n x: number;\n y: number;\n width: number;\n height: number;\n oppositeX: number;\n oppositeY: number;\n arrowSize: number;\n borderRadius: number;\n};\n\nfunction getRectangleIntersection(opts: GetRectangleIntersection): Point {\n const halfWidth = opts.width / 2;\n const halfHeight = opts.height / 2;\n\n const dx = opts.oppositeX - opts.x;\n const dy = opts.oppositeY - opts.y;\n\n let relX: number, relY: number;\n\n if (Math.abs(dx) <= halfWidth && Math.abs(dy) <= halfHeight) {\n const distToRight = halfWidth - dx;\n const distToLeft = halfWidth + dx;\n const distToTop = halfHeight - dy;\n const distToBottom = halfHeight + dy;\n\n const minDist = Math.min(distToRight, distToLeft, distToTop, distToBottom);\n\n relX = minDist === distToRight ? halfWidth : minDist === distToLeft ? -halfWidth : dx;\n relY = minDist === distToTop ? halfHeight : minDist === distToBottom ? -halfHeight : dy;\n } else {\n const absDx = Math.abs(dx);\n const absDy = Math.abs(dy);\n\n if (halfWidth * absDy < halfHeight * absDx) {\n relX = dx > 0 ? halfWidth : -halfWidth;\n relY = (relX * dy) / dx;\n if (Math.abs(relY) > halfHeight) {\n relY = dy > 0 ? halfHeight : -halfHeight;\n relX = (relY * dx) / dy;\n }\n } else {\n relY = dy > 0 ? halfHeight : -halfHeight;\n relX = (relY * dx) / dy;\n if (Math.abs(relX) > halfWidth) {\n relX = dx > 0 ? halfWidth : -halfWidth;\n relY = (relX * dy) / dx;\n }\n }\n }\n\n if (opts.borderRadius != undefined) {\n const { x, y } = squareRadiusFix(relX, relY, halfWidth, halfHeight, opts.borderRadius);\n if (x != undefined) relX = x;\n if (y != undefined) relY = y;\n }\n\n if (opts.arrowSize > 0) {\n const edgeDist = Math.sqrt(relX * relX + relY * relY);\n const scale = (edgeDist + opts.arrowSize) / edgeDist;\n relX *= scale;\n relY *= scale;\n }\n\n return {\n x: opts.x + relX,\n y: opts.y + relY,\n };\n}\n\n// eslint-disable-next-line no-warning-comments\n// TODO: Need upgrade\nfunction squareRadiusFix(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n borderRadius: number,\n) {\n const epsilon = 1e-6;\n const absX = Math.abs(relX);\n const absY = Math.abs(relY);\n\n let side: string | null = null;\n if (absX >= halfWidth - epsilon) {\n side = relX > 0 ? \"right\" : \"left\";\n } else if (absY >= halfHeight - epsilon) {\n side = relY > 0 ? \"top\" : \"bottom\";\n }\n\n if (side) {\n const topBound = halfHeight - borderRadius;\n const bottomBound = -topBound;\n const rightBound = halfWidth - borderRadius;\n const leftBound = -rightBound;\n\n switch (side) {\n case \"right\":\n if (relY > topBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"right-top\");\n } else if (relY < bottomBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"right-bottom\");\n }\n break;\n case \"left\":\n if (relY > topBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"left-top\");\n } else if (relY < bottomBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"left-bottom\");\n }\n break;\n case \"top\":\n if (relX > rightBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"top-right\");\n } else if (relX < leftBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"top-left\");\n }\n break;\n case \"bottom\":\n if (relX > rightBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"bottom-right\");\n } else if (relX < leftBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"bottom-left\");\n }\n break;\n default:\n break;\n }\n }\n\n return { x: undefined, y: undefined };\n}\n\nfunction checkIntersection(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n r: number,\n corner: Parameters<typeof intersectWithCircle>[5],\n) {\n const intersect = intersectWithCircle(relX, relY, halfWidth, halfHeight, r, corner);\n\n return intersect ?? { x: undefined, y: undefined };\n}\n\nfunction intersectWithCircle(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n r: number,\n corner:\n | \"right-top\"\n | \"right-bottom\"\n | \"left-top\"\n | \"left-bottom\"\n | \"top-right\"\n | \"top-left\"\n | \"bottom-right\"\n | \"bottom-left\",\n) {\n switch (corner) {\n case \"top-right\":\n corner = \"right-top\";\n break;\n case \"bottom-right\":\n corner = \"right-bottom\";\n break;\n case \"top-left\":\n corner = \"left-top\";\n break;\n case \"bottom-left\":\n corner = \"left-bottom\";\n break;\n default:\n break;\n }\n\n let cx: number, cy: number;\n switch (corner) {\n case \"right-top\":\n cx = halfWidth - r;\n cy = halfHeight - r;\n break;\n case \"right-bottom\":\n cx = halfWidth - r;\n cy = -halfHeight + r;\n break;\n case \"left-top\":\n cx = -halfWidth + r;\n cy = halfHeight - r;\n break;\n case \"left-bottom\":\n cx = -halfWidth + r;\n cy = -halfHeight + r;\n break;\n default:\n return null;\n }\n\n const a = relX ** 2 + relY ** 2;\n if (a === 0) return null;\n\n const b = -2 * (relX * cx + relY * cy);\n const c = cx ** 2 + cy ** 2 - r ** 2;\n const discriminant = b ** 2 - 4 * a * c;\n\n if (discriminant < 0) return null;\n const sqrtD = Math.sqrt(discriminant);\n\n const t2 = (-b - sqrtD) / (2 * a);\n const t1 = (-b + sqrtD) / (2 * a);\n const t = t2 > 0 ? t2 : t1 > 0 ? t1 : null;\n\n if (t === null || t >= 1) return null;\n\n const x = t * relX;\n const y = t * relY;\n\n let valid = false;\n switch (corner) {\n case \"right-top\":\n valid = x >= cx && y >= cy;\n break;\n case \"right-bottom\":\n valid = x >= cx && y <= cy;\n break;\n case \"left-top\":\n valid = x <= cx && y >= cy;\n break;\n case \"left-bottom\":\n valid = x <= cx && y <= cy;\n break;\n default:\n break;\n }\n\n return valid ? { x, y } : null;\n}\n"],"names":[],"mappings":";;SASgB,2BAA2B,CAGzC,IAAuC,EAAE,SAAS,GAAG,CAAC,EAAA;AACtD,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM;AAC1B,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM;IAE1B,IAAI,OAAO,MAAM,IAAI,QAAQ,IAAI,OAAO,MAAM,IAAI,QAAQ;AAAE,QAAA,OAAO,IAAI;IAEvE,MAAM,WAAW,GAAG,YAAY,CAAC;AAC/B,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,YAAY,EAAE,MAAM;AACrB,KAAA,CAAC;IACF,MAAM,WAAW,GAAG,YAAY,CAAC;AAC/B,QAAA,SAAS,EAAE,SAAS,GAAG,CAAC,GAAG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,WAAW;YACd,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,cAAc;YACjB,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,UAAU;YACb,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,aAAa;YAChB,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;;AAKJ,IAAA,OAAO,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI;AAChC;;;;"}
|
|
1
|
+
{"version":3,"file":"calculate-link-position-by-node.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/calculate-link-position-by-node.ts"],"sourcesContent":["/* eslint-disable id-length */\nimport { COMMON_SETTINGS } from \"../../constants\";\nimport type { LinkInterface, NodeInterface } from \"../../types\";\n\ntype Point = {\n x: number;\n y: number;\n};\n\nexport function calculateLinkPositionByNode<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(link: LinkInterface<NodeData, LinkData>, arrowSize = 0) {\n const source = link.source;\n const target = link.target;\n\n if (typeof source != \"object\" || typeof target != \"object\") return null;\n\n const sourcePoint = getLinkPoint({\n arrowSize: 0,\n node: source,\n oppositeNode: target,\n });\n const targetPoint = getLinkPoint({\n arrowSize: arrowSize > 0 ? arrowSize * 0.85 : 0,\n node: target,\n oppositeNode: source,\n });\n\n if (!sourcePoint || !targetPoint) return null;\n\n const distance =\n targetPoint && sourcePoint\n ? Math.sqrt((targetPoint.x - sourcePoint.x) ** 2 + (targetPoint.y - sourcePoint.y) ** 2)\n : 0;\n\n return {\n x1: sourcePoint.x,\n y1: sourcePoint.y,\n x2: targetPoint.x,\n y2: targetPoint.y,\n distance,\n };\n}\n\ntype GetLinkPointProps<NodeData extends Record<string, unknown>> = {\n arrowSize: number;\n node: NodeInterface<NodeData>;\n oppositeNode: NodeInterface<NodeData>;\n};\nfunction getLinkPoint<NodeData extends Record<string, unknown>>(opts: GetLinkPointProps<NodeData>) {\n if (\n opts.node.x == undefined ||\n opts.node.y == undefined ||\n opts.oppositeNode.x == undefined ||\n opts.oppositeNode.y == undefined\n )\n return null;\n\n let nodePoint: Point;\n switch (opts.node._shape) {\n case \"circle\": {\n nodePoint = getCircleIntersection({\n x: opts.node.x,\n y: opts.node.y,\n radius:\n (opts.node._radius ?? COMMON_SETTINGS.nodeRadius) +\n (opts.node._borderWidth ? opts.node._borderWidth / 2 : 0),\n oppositeX: opts.oppositeNode.x,\n oppositeY: opts.oppositeNode.y,\n arrowSize: opts.arrowSize,\n });\n break;\n }\n case \"square\":\n case \"text\": {\n nodePoint = getRectangleIntersection({\n arrowSize: opts.arrowSize,\n x: opts.node.x,\n y: opts.node.y,\n height: (opts.node._height ?? COMMON_SETTINGS.nodeSize) + (opts.node._borderWidth ?? 0),\n width: (opts.node._width ?? COMMON_SETTINGS.nodeSize) + (opts.node._borderWidth ?? 0),\n oppositeX: opts.oppositeNode.x,\n oppositeY: opts.oppositeNode.y,\n borderRadius: opts.node._shape === \"text\" ? 0 : (opts.node._borderRadius ?? 0),\n });\n break;\n }\n default: {\n nodePoint = getCircleIntersection({\n x: opts.node.x,\n y: opts.node.y,\n radius: opts.node._radius ?? COMMON_SETTINGS.nodeRadius,\n oppositeX: opts.oppositeNode.x,\n oppositeY: opts.oppositeNode.y,\n arrowSize: opts.arrowSize,\n });\n }\n }\n\n return nodePoint;\n}\n\ntype GetCircleIntersection = {\n x: number;\n y: number;\n radius: number;\n oppositeX: number;\n oppositeY: number;\n arrowSize: number;\n};\n\nfunction getCircleIntersection(opts: GetCircleIntersection): Point {\n const dx = opts.oppositeX - opts.x;\n const dy = opts.oppositeY - opts.y;\n const dr = Math.sqrt(dx * dx + dy * dy);\n\n const radius = opts.radius + opts.arrowSize;\n\n return {\n x: opts.x + (dx * radius) / dr,\n y: opts.y + (dy * radius) / dr,\n };\n}\n\ntype GetRectangleIntersection = {\n x: number;\n y: number;\n width: number;\n height: number;\n oppositeX: number;\n oppositeY: number;\n arrowSize: number;\n borderRadius: number;\n};\n\nfunction getRectangleIntersection(opts: GetRectangleIntersection): Point {\n const halfWidth = opts.width / 2;\n const halfHeight = opts.height / 2;\n\n const dx = opts.oppositeX - opts.x;\n const dy = opts.oppositeY - opts.y;\n\n let relX: number, relY: number;\n\n if (Math.abs(dx) <= halfWidth && Math.abs(dy) <= halfHeight) {\n const distToRight = halfWidth - dx;\n const distToLeft = halfWidth + dx;\n const distToTop = halfHeight - dy;\n const distToBottom = halfHeight + dy;\n\n const minDist = Math.min(distToRight, distToLeft, distToTop, distToBottom);\n\n relX = minDist === distToRight ? halfWidth : minDist === distToLeft ? -halfWidth : dx;\n relY = minDist === distToTop ? halfHeight : minDist === distToBottom ? -halfHeight : dy;\n } else {\n const absDx = Math.abs(dx);\n const absDy = Math.abs(dy);\n\n if (halfWidth * absDy < halfHeight * absDx) {\n relX = dx > 0 ? halfWidth : -halfWidth;\n relY = (relX * dy) / dx;\n if (Math.abs(relY) > halfHeight) {\n relY = dy > 0 ? halfHeight : -halfHeight;\n relX = (relY * dx) / dy;\n }\n } else {\n relY = dy > 0 ? halfHeight : -halfHeight;\n relX = (relY * dx) / dy;\n if (Math.abs(relX) > halfWidth) {\n relX = dx > 0 ? halfWidth : -halfWidth;\n relY = (relX * dy) / dx;\n }\n }\n }\n\n if (opts.borderRadius != undefined) {\n const { x, y } = squareRadiusFix(relX, relY, halfWidth, halfHeight, opts.borderRadius);\n if (x != undefined) relX = x;\n if (y != undefined) relY = y;\n }\n\n if (opts.arrowSize > 0) {\n const edgeDist = Math.sqrt(relX * relX + relY * relY);\n const scale = (edgeDist + opts.arrowSize) / edgeDist;\n relX *= scale;\n relY *= scale;\n }\n\n return {\n x: opts.x + relX,\n y: opts.y + relY,\n };\n}\n\n// eslint-disable-next-line no-warning-comments\n// TODO: Need upgrade\nfunction squareRadiusFix(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n borderRadius: number,\n) {\n const epsilon = 1e-6;\n const absX = Math.abs(relX);\n const absY = Math.abs(relY);\n\n let side: string | null = null;\n if (absX >= halfWidth - epsilon) {\n side = relX > 0 ? \"right\" : \"left\";\n } else if (absY >= halfHeight - epsilon) {\n side = relY > 0 ? \"top\" : \"bottom\";\n }\n\n if (side) {\n const topBound = halfHeight - borderRadius;\n const bottomBound = -topBound;\n const rightBound = halfWidth - borderRadius;\n const leftBound = -rightBound;\n\n switch (side) {\n case \"right\":\n if (relY > topBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"right-top\");\n } else if (relY < bottomBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"right-bottom\");\n }\n break;\n case \"left\":\n if (relY > topBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"left-top\");\n } else if (relY < bottomBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"left-bottom\");\n }\n break;\n case \"top\":\n if (relX > rightBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"top-right\");\n } else if (relX < leftBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"top-left\");\n }\n break;\n case \"bottom\":\n if (relX > rightBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"bottom-right\");\n } else if (relX < leftBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"bottom-left\");\n }\n break;\n default:\n break;\n }\n }\n\n return { x: undefined, y: undefined };\n}\n\nfunction checkIntersection(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n r: number,\n corner: Parameters<typeof intersectWithCircle>[5],\n) {\n const intersect = intersectWithCircle(relX, relY, halfWidth, halfHeight, r, corner);\n\n return intersect ?? { x: undefined, y: undefined };\n}\n\nfunction intersectWithCircle(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n r: number,\n corner:\n | \"right-top\"\n | \"right-bottom\"\n | \"left-top\"\n | \"left-bottom\"\n | \"top-right\"\n | \"top-left\"\n | \"bottom-right\"\n | \"bottom-left\",\n) {\n switch (corner) {\n case \"top-right\":\n corner = \"right-top\";\n break;\n case \"bottom-right\":\n corner = \"right-bottom\";\n break;\n case \"top-left\":\n corner = \"left-top\";\n break;\n case \"bottom-left\":\n corner = \"left-bottom\";\n break;\n default:\n break;\n }\n\n let cx: number, cy: number;\n switch (corner) {\n case \"right-top\":\n cx = halfWidth - r;\n cy = halfHeight - r;\n break;\n case \"right-bottom\":\n cx = halfWidth - r;\n cy = -halfHeight + r;\n break;\n case \"left-top\":\n cx = -halfWidth + r;\n cy = halfHeight - r;\n break;\n case \"left-bottom\":\n cx = -halfWidth + r;\n cy = -halfHeight + r;\n break;\n default:\n return null;\n }\n\n const a = relX ** 2 + relY ** 2;\n if (a === 0) return null;\n\n const b = -2 * (relX * cx + relY * cy);\n const c = cx ** 2 + cy ** 2 - r ** 2;\n const discriminant = b ** 2 - 4 * a * c;\n\n if (discriminant < 0) return null;\n const sqrtD = Math.sqrt(discriminant);\n\n const t2 = (-b - sqrtD) / (2 * a);\n const t1 = (-b + sqrtD) / (2 * a);\n const t = t2 > 0 ? t2 : t1 > 0 ? t1 : null;\n\n if (t === null || t >= 1) return null;\n\n const x = t * relX;\n const y = t * relY;\n\n let valid = false;\n switch (corner) {\n case \"right-top\":\n valid = x >= cx && y >= cy;\n break;\n case \"right-bottom\":\n valid = x >= cx && y <= cy;\n break;\n case \"left-top\":\n valid = x <= cx && y >= cy;\n break;\n case \"left-bottom\":\n valid = x <= cx && y <= cy;\n break;\n default:\n break;\n }\n\n return valid ? { x, y } : null;\n}\n"],"names":[],"mappings":";;;;AAAA;SASgB,2BAA2B,CAGzC,IAAuC,EAAE,SAAS,GAAG,CAAC,EAAA;AACtD,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM;AAC1B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,OAAO,IAAI;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;AAErC,IAAA,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC;AACjC,IAAA,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI;AAE1C,IAAA,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,IAAI;AAErC,IAAA,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI;AAClB,IAAA,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI;IAElB,IAAI,KAAK,GAAG,KAAK;IACjB,QAAQ,MAAM;AACZ,QAAA,KAAK,WAAW;YACd,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,cAAc;YACjB,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,UAAU;YACb,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,aAAa;YAChB,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;;AAKJ,IAAA,OAAO,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI;AAChC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drag-place-coefficient-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/drag-place-coefficient-getter.ts"],"sourcesContent":["import type { NodeInterface } from \"
|
|
1
|
+
{"version":3,"file":"drag-place-coefficient-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/drag-place-coefficient-getter.ts"],"sourcesContent":["import type { NodeInterface } from \"../../types\";\nimport { isOverlapsNode } from \"./is-overlaps-node\";\n\nexport function dragPlaceCoefficientGetter<NodeData extends Record<string, unknown>>(\n node: NodeInterface<NodeData>,\n pointerX: number,\n pointerY: number,\n): number | undefined {\n if (!node.x || !node.y) return undefined;\n\n if (isOverlapsNode(node, pointerX, pointerY, undefined)) return node.index;\n}\n"],"names":[],"mappings":";;SAGgB,0BAA0B,CACxC,IAA6B,EAC7B,QAAgB,EAChB,QAAgB,EAAA;IAEhB,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAE,QAAA,OAAO,SAAS;IAExC,IAAI,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK;AAC5E;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-particle-position.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/get-particle-position.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"get-particle-position.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/get-particle-position.ts"],"sourcesContent":["import type { LinkParticle } from \"../../types\";\n\ntype GetParticlePositionOptions = {\n particle: LinkParticle;\n xStart: number;\n yStart: number;\n xEnd: number;\n yEnd: number;\n totalSteps: number;\n totalCount: number;\n distance: number;\n};\n\nexport function getParticlePosition(opts: GetParticlePositionOptions) {\n const prevStepDifference = opts.particle.step - (opts.particle.prev?.step ?? 0);\n const nextStepDifference = (opts.particle.next?.step ?? 0) - opts.particle.step;\n\n const needWait =\n opts.particle.next &&\n opts.particle.next.step > opts.particle.step &&\n nextStepDifference <= opts.distance;\n const needSpeed =\n opts.particle.prev &&\n opts.particle.prev.step !== 0 &&\n opts.particle.prev.step < opts.particle.step &&\n prevStepDifference < opts.distance;\n\n if (opts.particle.step === 0 && needWait) {\n opts.particle.x = undefined;\n opts.particle.y = undefined;\n\n return;\n }\n\n const remainingSteps = opts.totalSteps - opts.particle.step;\n const progress = opts.particle.step / opts.totalSteps;\n\n if (remainingSteps <= 0) {\n opts.particle.x = opts.xEnd;\n opts.particle.y = opts.yEnd;\n opts.particle.step = 0;\n\n return;\n }\n\n const dx = opts.xEnd - opts.xStart;\n const dy = opts.yEnd - opts.yStart;\n\n const newX = opts.xStart + dx * progress;\n const newY = opts.yStart + dy * progress;\n\n opts.particle.x = newX;\n opts.particle.y = newY;\n\n if (needSpeed) {\n opts.particle.step += prevStepDifference <= 3 ? prevStepDifference : 3;\n } else {\n opts.particle.step++;\n }\n}\n"],"names":[],"mappings":"AAaM,SAAU,mBAAmB,CAAC,IAAgC,EAAA;AAClE,IAAA,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC;AAC/E,IAAA,MAAM,kBAAkB,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI;AAE/E,IAAA,MAAM,QAAQ,GACZ,IAAI,CAAC,QAAQ,CAAC,IAAI;QAClB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI;AAC5C,QAAA,kBAAkB,IAAI,IAAI,CAAC,QAAQ;AACrC,IAAA,MAAM,SAAS,GACb,IAAI,CAAC,QAAQ,CAAC,IAAI;AAClB,QAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI;AAC5C,QAAA,kBAAkB,GAAG,IAAI,CAAC,QAAQ;IAEpC,IAAI,IAAI,CAAC,QA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"sourcesContent":["import type { ZoomTransform } from \"d3-zoom\";\nimport
|
|
1
|
+
{"version":3,"file":"is-node-visible.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/is-node-visible.ts"],"sourcesContent":["import type { ZoomTransform } from \"d3-zoom\";\nimport { COMMON_SETTINGS } from \"../../constants\";\nimport type { NodeInterface } from \"../../types\";\n\ntype IsNodeVisibleOptions<NodeData extends Record<string, unknown>> = {\n width: number;\n height: number;\n transform: ZoomTransform;\n node: NodeInterface<NodeData>;\n};\n\nconst ADDITIONAL_VIEWPORT = 10;\n\nexport function isNodeVisible<NodeData extends Record<string, unknown>>(\n opts: IsNodeVisibleOptions<NodeData>,\n) {\n const left = -opts.transform.x / opts.transform.k;\n const right = (opts.width - opts.transform.x) / opts.transform.k;\n const top = -opts.transform.y / opts.transform.k;\n const bottom = (opts.height - opts.transform.y) / opts.transform.k;\n\n if (opts.node.x == undefined || opts.node.y == undefined) return false;\n\n switch (opts.node._shape) {\n case \"circle\": {\n const radius = opts.node._radius ?? COMMON_SETTINGS.nodeRadius;\n\n return (\n left < opts.node.x + radius + ADDITIONAL_VIEWPORT &&\n opts.node.x - radius - ADDITIONAL_VIEWPORT < right &&\n top < opts.node.y + radius + ADDITIONAL_VIEWPORT &&\n opts.node.y - radius - ADDITIONAL_VIEWPORT < bottom\n );\n }\n case \"square\":\n case \"text\": {\n const width = opts.node._width ?? COMMON_SETTINGS.nodeSize;\n const height = opts.node._height ?? COMMON_SETTINGS.nodeSize;\n\n return (\n left < opts.node.x + width + ADDITIONAL_VIEWPORT &&\n opts.node.x - width - ADDITIONAL_VIEWPORT < right &&\n top < opts.node.y + height + ADDITIONAL_VIEWPORT &&\n opts.node.y - height - ADDITIONAL_VIEWPORT < bottom\n );\n }\n default: {\n const radius = opts.node._radius ?? COMMON_SETTINGS.nodeRadius;\n\n return (\n left < opts.node.x + radius + ADDITIONAL_VIEWPORT &&\n opts.node.x - radius - ADDITIONAL_VIEWPORT < right &&\n top < opts.node.y + radius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A,KAAK,QAAQ;QACb,KAAK,MAAM,EAAE;YACX,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,eAAe,CAAC,QAAQ;YAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,eAAe,CAAC,QAAQ;YAE5D,QACE,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,mBAAmB;gBAChD,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,mBAAmB,GAAG,KAAK;gBACjD,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG,mBAAmB;gBAChD,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG,mBAAmB,GAAG,MAAM;;QAGvD,SAAS;YACP,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,eAAe,CAAC,UAAU;YAE9D,QACE,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG,mBAAmB;gBACjD,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG,mBAAmB,GAAG,KAAK;gBAClD,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG,mBAAmB;gBAChD,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG,mBAAmB,GAAG,MAAM;;;AAI3D;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-overlaps-node.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/is-overlaps-node.ts"],"sourcesContent":["import type { NodeInterface } from \"
|
|
1
|
+
{"version":3,"file":"is-overlaps-node.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/is-overlaps-node.ts"],"sourcesContent":["import type { NodeInterface } from \"../../types\";\n\nexport function isOverlapsNode<NodeData extends Record<string, unknown>>(\n node: NodeInterface<NodeData>,\n pointerX: number,\n pointerY: number,\n radius: number | undefined,\n) {\n if (node.x == undefined || node.y == undefined) return false;\n\n switch (node._shape) {\n case \"circle\": {\n const nodeRadius = node._radius ?? radius ?? 5;\n const isOverX = node.x - nodeRadius <= pointerX && pointerX <= node.x + nodeRadius;\n const isOverY = node.y - nodeRadius <= pointerY && pointerY <= node.y + nodeRadius;\n\n return isOverX && isOverY;\n }\n case \"square\":\n case \"text\": {\n const width = node._width ?? 5;\n const height = node._height ?? 5;\n const borderRadius = node._borderRadius ?? 0;\n const overlaps =\n Math.abs(pointerX - node.x) <= width / 2 && Math.abs(pointerY - node.y) <= height / 2;\n\n if (node._shape !== \"text\" && borderRadius != undefined && borderRadius > 0 && overlaps) {\n return isCursorOverRoundedRect(\n pointerX,\n pointerY,\n node.x,\n node.y,\n width / 2,\n height / 2,\n borderRadius,\n );\n }\n\n return overlaps;\n }\n default: {\n const nodeRadius = node._radius ?? radius ?? 5;\n const isOverX = node.x - nodeRadius <= pointerX && pointerX <= node.x + nodeRadius;\n const isOverY = node.y - nodeRadius <= pointerY && pointerY <= node.y + nodeRadius;\n\n return isOverX && isOverY;\n }\n }\n}\n\nfunction isCursorOverRoundedRect(\n pointerX: number,\n pointerY: number,\n x: number,\n y: number,\n halfWidth: number,\n halfHeight: number,\n borderRadius: number,\n) {\n const left = x - halfWidth;\n const right = x + halfWidth;\n const top = y - halfHeight;\n const bottom = y + halfHeight;\n\n if (pointerX < left + borderRadius && pointerY < top + borderRadius) {\n const dx = pointerX - (left + borderRadius);\n const dy = pointerY - (top + borderRadius);\n\n return dx * dx + dy * dy <= borderRadius * borderRadius;\n } else if (pointerX > right - borderRadius && pointerY < top + borderRadius) {\n const dx = pointerX - (right - borderRadius);\n const dy = pointerY - (top + borderRadius);\n\n return dx * dx + dy * dy <= borderRadius * borderRadius;\n } else if (pointerX < left + borderRadius && pointerY > bottom - borderRadius) {\n const dx = pointerX - (left + borderRadius);\n const dy = pointerY - (bottom - borderRadius);\n\n return dx * dx + dy * dy <= borderRadius * borderRadius;\n } else if (pointerX > right - borderRadius && pointerY > bottom - borderRadius) {\n const dx = pointerX - (right - borderRadius);\n const dy = pointerY - (bottom - borderRadius);\n\n return dx * dx + dy * dy <= borderRadius * borderRadius;\n }\n\n return true;\n}\n"],"names":[],"mappings":"AAEM,SAAU,cAAc,CAC5B,IAA6B,EAC7B,QAAgB,EAChB,QAAgB,EAChB,MAA0B,EAAA;IAE1B,IAAI,IAAI,CAAC,CAAC,IAAI,SAAS,IAAI,IAAI,CAAC,CAAC,IAAI,SAAS;AAAE,QAAA,OAAO,KAAK;AAE5D,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,QAAQ,EAAE;YACb,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,IAAI,MAAM,IAAI,CAAC;AAC9C,YAAA,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,GAAG,UAAU,IAAI,QAAQ,IAAI,QAAQ,IAAI,IAAI,CAAC,CAAC,GAAG,UAAU;AAClF,YAAA,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,GAAG,UAAU,IAAI,QAAQ,IAAI,QAAQ,IAAI,IAAI,CAAC,CAAC,GAAG,UAAU;YAElF,OAAO,OAAO,IAAI,OAAO;;AAE3B,QAAA,KAAK,QAAQ;QACb,KAAK,MAAM,EAAE;AACX,YAAA,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC;AAC9B,YAAA,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,IAAI,CAAC;AAChC,YAAA,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,IAAI,CAAC;AAC5C,YAAA,MAAM,QAAQ,GACZ,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,GAAG,CAAC;AAEvF,YAAA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EAAE,IAAI,YAAY,GAAG,YAAY;;AAClD,SAAA,IAAI,QAAQ,GAAG,KAAK,GAAG,YAAY,IAAI,QAAQ,GAAG,GAAG,GAAG,YAAY,EAAE;QAC3E,MAAM,EAAE,GAAG,QAAQ,IAAI,KAAK,GAAG,YAAY,CAAC;QAC5C,MAAM,EAAE,GAAG,QAAQ,IAAI,GAAG,GAAG,YAAY,CAAC;QAE1C,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,YAAY,GAAG,YAAY;;AAClD,SAAA,IAAI,QAAQ,GAAG,IAAI,GAAG,YAAY,IAAI,QAAQ,GAAG,MAAM,GAAG,YAAY,EAAE;QAC7E,MAAM,EAAE,GAAG,QAAQ,IAAI,IAAI,GAAG,YAAY,CAAC;QAC3C,MAAM,EAAE,GAAG,QAAQ,IAAI,MAAM,GAAG,YAAY,CAAC;QAE7C,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,YAAY,GAAG,YAAY;;AAClD,SAAA,IAAI,QAAQ,GAAG,KAAK,GAAG,YAAY,IAAI,QAAQ,GAAG,MAAM,GAAG,YAAY,EAAE;QAC9E,MAAM,EAAE,GAAG,QAAQ,IAAI,KAAK,GAAG,YAAY,CAAC;QAC5C,MAAM,EAAE,GAAG,QAAQ,IAAI,MAAM,GAAG,YAAY,CAAC;QAE7C,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,YAAY,GAAG,YAAY;;AAGzD,IAAA,OAAO,IAAI;AACb;;;;"}
|
|
@@ -3,12 +3,12 @@ import { greatest } from 'd3-array';
|
|
|
3
3
|
import { pointerGetter } from './pointer-getter.js';
|
|
4
4
|
|
|
5
5
|
/* eslint-disable id-length */
|
|
6
|
-
function linkByPointerGetter({ areaRect, areaTransform, mouseEvent, links,
|
|
6
|
+
function linkByPointerGetter({ areaRect, areaTransform, mouseEvent, links, linkHoverExtraZone, }) {
|
|
7
7
|
if (!areaRect)
|
|
8
8
|
return undefined;
|
|
9
9
|
const [pointerX, pointerY] = pointerGetter(mouseEvent, areaRect, areaTransform);
|
|
10
10
|
return greatest(links, (link) => {
|
|
11
|
-
if (isNearLink(pointerX, pointerY, link,
|
|
11
|
+
if (isNearLink(pointerX, pointerY, link, linkHoverExtraZone))
|
|
12
12
|
return link.index;
|
|
13
13
|
});
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-by-pointer-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/link-by-pointer-getter.ts"],"sourcesContent":["/* eslint-disable id-length */\nimport { isObject } from \"@krainovsd/js-helpers\";\nimport { greatest } from \"d3-array\";\nimport type { ZoomTransform } from \"d3-zoom\";\nimport type { LinkInterface } from \"
|
|
1
|
+
{"version":3,"file":"link-by-pointer-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/link-by-pointer-getter.ts"],"sourcesContent":["/* eslint-disable id-length */\nimport { isObject } from \"@krainovsd/js-helpers\";\nimport { greatest } from \"d3-array\";\nimport type { ZoomTransform } from \"d3-zoom\";\nimport type { LinkInterface } from \"../../types\";\nimport { pointerGetter } from \"./pointer-getter\";\n\nexport type LinkByPointerGetterOptions<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n> = {\n mouseEvent: MouseEvent | TouchEvent;\n areaRect: DOMRect | undefined;\n areaTransform: ZoomTransform;\n links: LinkInterface<NodeData, LinkData>[];\n linkHoverExtraZone: number;\n};\n\nexport function linkByPointerGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>({\n areaRect,\n areaTransform,\n mouseEvent,\n links,\n linkHoverExtraZone,\n}: LinkByPointerGetterOptions<NodeData, LinkData>): LinkInterface<NodeData, LinkData> | undefined {\n if (!areaRect) return undefined;\n\n const [pointerX, pointerY] = pointerGetter(mouseEvent, areaRect, areaTransform);\n\n return greatest(links, (link) => {\n if (isNearLink(pointerX, pointerY, link, linkHoverExtraZone)) return link.index;\n });\n}\n\nfunction isNearLink<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(mouseX: number, mouseY: number, link: LinkInterface<NodeData, LinkData>, threshold = 2) {\n if (!isObject(link.source) || !isObject(link.target)) return false;\n\n const x1 = link.source.x as number;\n const y1 = link.source.y as number;\n const x2 = link.target.x as number;\n const y2 = link.target.y as number;\n\n const distance = distanceToLine(mouseX, mouseY, x1, y1, x2, y2);\n\n return distance <= threshold;\n}\n\nfunction distanceToLine(x: number, y: number, x1: number, y1: number, x2: number, y2: number) {\n const A = x - x1;\n const B = y - y1;\n const C = x2 - x1;\n const D = y2 - y1;\n\n const dot = A * C + B * D;\n const lenSq = C * C + D * D;\n let param = -1;\n\n if (lenSq !== 0) {\n param = dot / lenSq;\n }\n\n let xx, yy;\n\n if (param < 0) {\n xx = x1;\n yy = y1;\n } else if (param > 1) {\n xx = x2;\n yy = y2;\n } else {\n xx = x1 + param * C;\n yy = y1 + param * D;\n }\n\n const dx = x - xx;\n const dy = y - yy;\n\n return Math.sqrt(dx * dx + dy * dy);\n}\n"],"names":[],"mappings":";;;;AAAA;AAkBgB,SAAA,mBAAmB,CAGjC,EACA,QAAQ,EACR,aAAa,EACb,UAAU,EACV,KAAK,EACL,kBAAkB,GAC6B,EAAA;AAC/C,IAAA,IAAI,CAAC,QAAQ;AAAE,QAAA,OAAO,SAAS;AAE/B,IAAA,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,aAAa,CAAC;AAE/E,IAAA,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,KAAI;QAC9B,IAAI,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,kBAAkB,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK;AACjF,KAAC,CAAC;AACJ;AAEA,SAAS,UAAU,CAGjB,MAAc,EAAE,MAAc,EAAE,IAAuC,EAAE,SAAS,GA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K,GAAG,CAAC,EAAE;QACpB,EAAE,GAAG,EAAE;QACP,EAAE,GAAG,EAAE;;SACF;AACL,QAAA,EAAE,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC;AACnB,QAAA,EAAE,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC;;AAGrB,IAAA,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE;AACjB,IAAA,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE;AAEjB,IAAA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACrC;;;;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { colorToRgb } from '../../../../lib/color-to-rgb.js';
|
|
2
|
+
import { extractRgb } from '../../../../lib/extract-rgb.js';
|
|
3
|
+
import { rgbAnimationByProgress } from '../../../../lib/rgb-animation-by-progress.js';
|
|
4
|
+
import { animationByProgress } from './animation-by-progress.js';
|
|
5
|
+
|
|
6
|
+
function linkHighlight(opts) {
|
|
7
|
+
const arrowVisible = opts.arrow && !opts.arrowByHighlight;
|
|
8
|
+
let arrowAlpha = opts.arrowByHighlight ? 0 : opts.linkOptions.arrowAlpha;
|
|
9
|
+
let color = opts.linkOptions.color;
|
|
10
|
+
let width = opts.linkOptions.width;
|
|
11
|
+
let arrowColor = opts.linkOptions.arrowColor;
|
|
12
|
+
let arrowSize = opts.linkOptions.arrowSize;
|
|
13
|
+
let arrowBorderWidth = opts.linkOptions.arrowBorderWidth;
|
|
14
|
+
let arrowBorderColor = opts.linkOptions.arrowBorderColor;
|
|
15
|
+
if (opts.arrow && opts.arrowByHighlight) {
|
|
16
|
+
/** Highlighted */
|
|
17
|
+
arrowAlpha = animationByProgress(0, opts.linkOptions.arrowAlpha, opts.highlightProgress);
|
|
18
|
+
}
|
|
19
|
+
if (opts.highlightForLinkColor) {
|
|
20
|
+
/** Color */
|
|
21
|
+
const colorRgb = extractRgb(colorToRgb(color));
|
|
22
|
+
const colorRgbHighlight = extractRgb(colorToRgb(opts.highlightForLinkColor));
|
|
23
|
+
if (colorRgb && colorRgbHighlight) {
|
|
24
|
+
const colorFadeAnimation = rgbAnimationByProgress(colorRgb, colorRgbHighlight, opts.highlightProgress);
|
|
25
|
+
color = `rgb(${colorFadeAnimation.r}, ${colorFadeAnimation.g}, ${colorFadeAnimation.b})`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (opts.highlightForArrowColor && arrowVisible) {
|
|
29
|
+
/** Arrow Color */
|
|
30
|
+
const colorRgb = extractRgb(colorToRgb(arrowColor));
|
|
31
|
+
const colorRgbHighlight = extractRgb(colorToRgb(opts.highlightForArrowColor));
|
|
32
|
+
if (colorRgb && colorRgbHighlight) {
|
|
33
|
+
const colorFadeAnimation = rgbAnimationByProgress(colorRgb, colorRgbHighlight, opts.highlightProgress);
|
|
34
|
+
arrowColor = `rgb(${colorFadeAnimation.r}, ${colorFadeAnimation.g}, ${colorFadeAnimation.b})`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (opts.highlightForArrowBorderColor && arrowVisible) {
|
|
38
|
+
/** Arrow Border Color */
|
|
39
|
+
const colorRgb = extractRgb(colorToRgb(arrowBorderColor));
|
|
40
|
+
const colorRgbHighlight = extractRgb(colorToRgb(opts.highlightForArrowBorderColor));
|
|
41
|
+
if (colorRgb && colorRgbHighlight) {
|
|
42
|
+
const colorFadeAnimation = rgbAnimationByProgress(colorRgb, colorRgbHighlight, opts.highlightProgress);
|
|
43
|
+
arrowBorderColor = `rgb(${colorFadeAnimation.r}, ${colorFadeAnimation.g}, ${colorFadeAnimation.b})`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
width = animationByProgress(width, opts.highlightForLinkSizeAdditional, opts.highlightProgress);
|
|
47
|
+
if (arrowVisible) {
|
|
48
|
+
arrowSize = animationByProgress(arrowSize, opts.highlightForArrowSizeAdditional, opts.highlightProgress);
|
|
49
|
+
arrowBorderWidth = animationByProgress(arrowBorderWidth, opts.highlightForArrowBorderSizingAdditional, opts.highlightProgress);
|
|
50
|
+
}
|
|
51
|
+
return { arrowAlpha, color, width, arrowColor, arrowSize, arrowBorderWidth, arrowBorderColor };
|
|
52
|
+
}
|
|
53
|
+
function linkFade(opts) {
|
|
54
|
+
let alpha = opts.linkOptions.alpha;
|
|
55
|
+
let arrowAlpha = opts.arrowByHighlight ? 0 : opts.linkOptions.arrowAlpha;
|
|
56
|
+
const alphaMin = opts.highlightForLinkFadingMin < alpha ? opts.highlightForLinkFadingMin : alpha;
|
|
57
|
+
alpha = animationByProgress(alphaMin, alpha - alphaMin, 1 - opts.highlightProgress);
|
|
58
|
+
if (opts.arrow && !opts.arrowByHighlight) {
|
|
59
|
+
const arrowAlphaMin = opts.highlightForArrowFadingMin < arrowAlpha ? opts.highlightForArrowFadingMin : arrowAlpha;
|
|
60
|
+
arrowAlpha = animationByProgress(arrowAlphaMin, arrowAlpha - arrowAlphaMin, 1 - opts.highlightProgress);
|
|
61
|
+
}
|
|
62
|
+
return { alpha, arrowAlpha };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { linkFade, linkHighlight };
|
|
66
|
+
//# sourceMappingURL=link-highlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-highlight.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/link-highlight.ts"],"sourcesContent":["import { colorToRgb, extractRgb, rgbAnimationByProgress } from \"@/lib\";\nimport type { LinkOptionsInterface } from \"../../types\";\nimport { animationByProgress } from \"./animation-by-progress\";\n\ntype LinkHighlightOptions<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n> = {\n linkOptions: Required<LinkOptionsInterface<NodeData, LinkData>>;\n highlightProgress: number;\n arrow: boolean;\n arrowByHighlight: boolean;\n highlightForArrowBorderSizingAdditional: number;\n highlightForArrowBorderColor: string | null;\n highlightForArrowColor: string | null;\n highlightForArrowSizeAdditional: number;\n highlightForLinkColor: string | null;\n highlightForLinkSizeAdditional: number;\n};\n\nexport function linkHighlight<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(opts: LinkHighlightOptions<NodeData, LinkData>) {\n const arrowVisible = opts.arrow && !opts.arrowByHighlight;\n\n let arrowAlpha = opts.arrowByHighlight ? 0 : opts.linkOptions.arrowAlpha;\n let color = opts.linkOptions.color;\n let width = opts.linkOptions.width;\n let arrowColor = opts.linkOptions.arrowColor;\n let arrowSize = opts.linkOptions.arrowSize;\n let arrowBorderWidth = opts.linkOptions.arrowBorderWidth;\n let arrowBorderColor = opts.linkOptions.arrowBorderColor;\n\n if (opts.arrow && opts.arrowByHighlight) {\n /** Highlighted */\n arrowAlpha = animationByProgress(0, opts.linkOptions.arrowAlpha, opts.highlightProgress);\n }\n\n if (opts.highlightForLinkColor) {\n /** Color */\n const colorRgb = extractRgb(colorToRgb(color));\n const colorRgbHighlight = extractRgb(colorToRgb(opts.highlightForLinkColor));\n if (colorRgb && colorRgbHighlight) {\n const colorFadeAnimation = rgbAnimationByProgress(\n colorRgb,\n colorRgbHighlight,\n opts.highlightProgress,\n );\n color = `rgb(${colorFadeAnimation.r}, ${colorFadeAnimation.g}, ${colorFadeAnimation.b})`;\n }\n }\n if (opts.highlightForArrowColor && arrowVisible) {\n /** Arrow Color */\n const colorRgb = extractRgb(colorToRgb(arrowColor));\n const colorRgbHighlight = extractRgb(colorToRgb(opts.highlightForArrowColor));\n if (colorRgb && colorRgbHighlight) {\n const colorFadeAnimation = rgbAnimationByProgress(\n colorRgb,\n colorRgbHighlight,\n opts.highlightProgress,\n );\n arrowColor = `rgb(${colorFadeAnimation.r}, ${colorFadeAnimation.g}, ${colorFadeAnimation.b})`;\n }\n }\n if (opts.highlightForArrowBorderColor && arrowVisible) {\n /** Arrow Border Color */\n const colorRgb = extractRgb(colorToRgb(arrowBorderColor));\n const colorRgbHighlight = extractRgb(colorToRgb(opts.highlightForArrowBorderColor));\n if (colorRgb && colorRgbHighlight) {\n const colorFadeAnimation = rgbAnimationByProgress(\n colorRgb,\n colorRgbHighlight,\n opts.highlightProgress,\n );\n arrowBorderColor = `rgb(${colorFadeAnimation.r}, ${colorFadeAnimation.g}, ${colorFadeAnimation.b})`;\n }\n }\n\n width = animationByProgress(width, opts.highlightForLinkSizeAdditional, opts.highlightProgress);\n if (arrowVisible) {\n arrowSize = animationByProgress(\n arrowSize,\n opts.highlightForArrowSizeAdditional,\n opts.highlightProgress,\n );\n arrowBorderWidth = animationByProgress(\n arrowBorderWidth,\n opts.highlightForArrowBorderSizingAdditional,\n opts.highlightProgress,\n );\n }\n\n return { arrowAlpha, color, width, arrowColor, arrowSize, arrowBorderWidth, arrowBorderColor };\n}\n\ntype LinkFadeOptions<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n> = {\n linkOptions: Required<LinkOptionsInterface<NodeData, LinkData>>;\n highlightProgress: number;\n arrow: boolean;\n arrowByHighlight: boolean;\n highlightForLinkFadingMin: number;\n highlightForArrowFadingMin: number;\n};\n\nexport function linkFade<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(opts: LinkFadeOptions<NodeData, LinkData>) {\n let alpha = opts.linkOptions.alpha;\n let arrowAlpha = opts.arrowByHighlight ? 0 : opts.linkOptions.arrowAlpha;\n\n const alphaMin = opts.highlightForLinkFadingMin < alpha ? opts.highlightForLinkFadingMin : alpha;\n alpha = animationByProgress(alphaMin, alpha - alphaMin, 1 - opts.highlightProgress);\n if (opts.arrow && !opts.arrowByHighlight) {\n const arrowAlphaMin =\n opts.highlightForArrowFadingMin < arrowAlpha ? opts.highlightForArrowFadingMin : arrowAlpha;\n arrowAlpha = animationByProgress(\n arrowAlphaMin,\n arrowAlpha - arrowAlphaMin,\n 1 - opts.highlightProgress,\n );\n }\n\n return { alpha, arrowAlpha };\n}\n"],"names":[],"mappings":";;;;;AAoBM,SAAU,aAAa,CAG3B,IAA8C,EAAA;IAC9C,MAAM,YAAY,GAAG,IAAI,C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AAmB,CACpC,gBAAgB,EAChB,IAAI,CAAC,uCAAuC,EAC5C,IAAI,CAAC,iBAAiB,CACvB;;AAGH,IAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE;AAChG;AAcM,SAAU,QAAQ,CAGtB,IAAyC,EAAA;AACzC,IAAA,IAAI,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK;AAClC,IAAA,IAAI,UAAU,GAAG,IAAI,CAAC,gBAAgB,GAAG,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU;AAExE,IAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,yBAAyB,GAAG,KAAK,GAAG,IAAI,CAAC,yBAAyB,GAAG,KAAK;AAChG,IAAA,KAAK,GAAG,mBAAmB,CAAC,QAAQ,EAAE,KAAK,GAAG,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC;IACnF,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;AACxC,QAAA,MAAM,aAAa,GACjB,IAAI,CAAC,0BAA0B,GAAG,UAAU,GAAG,IAAI,CAAC,0BAA0B,GAAG,UAAU;AAC7F,QAAA,UAAU,GAAG,mBAAmB,CAC9B,aAAa,EACb,UAAU,GAAG,aAAa,EAC1B,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAC3B;;AAGH,IAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE;AAC9B;;;;"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { checkType } from '../../../../lib/check-type.js';
|
|
2
2
|
import '@krainovsd/js-helpers';
|
|
3
|
-
import 'd3-array';
|
|
4
3
|
|
|
5
4
|
function linkIterationExtractor(link, i, links, state, option, optionConstantGetter) {
|
|
6
5
|
let customOptions;
|
|
7
6
|
let constantOptions;
|
|
8
7
|
if (typeof option === "function")
|
|
9
|
-
customOptions = option(link, i, links
|
|
8
|
+
customOptions = option.call(state, link, i, links);
|
|
10
9
|
else
|
|
11
10
|
customOptions = option;
|
|
12
11
|
if (customOptions && typeof customOptions === "object" && !Array.isArray(customOptions)) {
|
|
@@ -17,7 +16,7 @@ function linkIterationExtractor(link, i, links, state, option, optionConstantGet
|
|
|
17
16
|
}
|
|
18
17
|
if (optionConstantGetter) {
|
|
19
18
|
if (typeof optionConstantGetter === "function")
|
|
20
|
-
constantOptions = optionConstantGetter(link, i, links
|
|
19
|
+
constantOptions = optionConstantGetter.call(state, link, i, links);
|
|
21
20
|
else
|
|
22
21
|
constantOptions = optionConstantGetter;
|
|
23
22
|
if (constantOptions &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-iteration-extractor.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/link-iteration-extractor.ts"],"sourcesContent":["import { checkType } from \"@/lib\";\nimport type {
|
|
1
|
+
{"version":3,"file":"link-iteration-extractor.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/link-iteration-extractor.ts"],"sourcesContent":["import { checkType } from \"@/lib\";\nimport type { GraphCanvas } from \"../../GraphCanvas\";\nimport type { LinkInterface, LinkIterationPropsInterface } from \"../../types\";\n\nexport function linkIterationExtractor<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n Result extends string | number | boolean | Record<string, unknown> | unknown[],\n>(\n link: LinkInterface<NodeData, LinkData>,\n i: number,\n links: LinkInterface<NodeData, LinkData>[],\n state: GraphCanvas<NodeData, LinkData>,\n option: LinkIterationPropsInterface<NodeData, LinkData, Result> | Result,\n optionConstantGetter: undefined,\n): Result;\n\nexport function linkIterationExtractor<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n Result extends string | number | boolean | Record<string, unknown> | unknown[],\n>(\n link: LinkInterface<NodeData, LinkData>,\n i: number,\n links: LinkInterface<NodeData, LinkData>[],\n state: GraphCanvas<NodeData, LinkData>,\n option: LinkIterationPropsInterface<NodeData, LinkData, Result> | Result,\n optionConstantGetter:\n | LinkIterationPropsInterface<NodeData, LinkData, Required<Result>>\n | Required<Result>,\n): Required<Result>;\n\nexport function linkIterationExtractor<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n Result extends string | number | boolean | Record<string, unknown> | unknown[],\n>(\n link: LinkInterface<NodeData, LinkData>,\n i: number,\n links: LinkInterface<NodeData, LinkData>[],\n state: GraphCanvas<NodeData, LinkData>,\n option: LinkIterationPropsInterface<NodeData, LinkData, Result> | Result,\n optionConstantGetter:\n | LinkIterationPropsInterface<NodeData, LinkData, Required<Result>>\n | Required<Result>\n | undefined,\n): Result {\n let customOptions: Result | undefined;\n let constantOptions: Result | undefined;\n\n if (typeof option === \"function\") customOptions = option.call(state, link, i, links);\n else customOptions = option;\n\n if (customOptions && typeof customOptions === \"object\" && !Array.isArray(customOptions)) {\n for (const key in customOptions) {\n if (customOptions[key] === undefined) delete customOptions[key];\n }\n }\n\n if (optionConstantGetter) {\n if (typeof optionConstantGetter === \"function\")\n constantOptions = optionConstantGetter.call(state, link, i, links);\n else constantOptions = optionConstantGetter;\n\n if (\n constantOptions &&\n typeof constantOptions === \"object\" &&\n !Array.isArray(constantOptions) &&\n checkType<Record<string, unknown> | undefined>(\n customOptions,\n customOptions === undefined ||\n (typeof customOptions === \"object\" && !Array.isArray(customOptions)),\n )\n ) {\n return {\n ...(constantOptions as Record<string, unknown> | undefined),\n ...(customOptions as Record<string, unknown> | undefined),\n } as Result;\n }\n }\n\n return customOptions;\n}\n"],"names":[],"mappings":";;;AAgCgB,SAAA,sBAAsB,CAKpC,IAAuC,EACvC,CAAS,EACT,KAA0C,EAC1C,KAAsC,EACtC,MAAwE,EACxE,oBAGa,EAAA;AAEb,IAAA,IAAI,aAAiC;AACrC,IAAA,IAAI,eAAmC;IAEvC,IAAI,OAAO,MAAM,KAAK,UAAU;AAAE,QAAA,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC;;QAC/E,aAAa,GAAG,MAAM;AAE3B,IAAA,IAAI,aAAa,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;AACvF,QAAA,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE;AAC/B,YAAA,IAAI,aAAa,CAAC,GAAG,CAAC,KAAK,SAAS;AAAE,gBAAA,OAAO,aAAa,CAAC,GAAG,CAAC;;;IAInE,IAAI,oBAAoB,EAAE;QACxB,IAAI,OAAO,oBAAoB,KAAK,UAAU;AAC5C,YAAA,eAAe,GAAG,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC;;YAC/D,eAAe,GAAG,oBAAoB;AAE3C,QAAA,IACE,eAAe;YACf,OAAO,eAAe,KAAK,QAAQ;AACnC,YAAA,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC;AAC/B,YAAA,SAAS,CACP,aAAa,EACb,aAAa,KAAK,SAAS;AACzB,iBAAC,OAAO,aAAa,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CACvE,EACD;YACA,OAAO;AACL,gBAAA,GAAI,eAAuD;AAC3D,gBAAA,GAAI,aAAqD;aAChD;;;AAIf,IAAA,OAAO,aAAa;AACtB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-by-pointer-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/node-by-pointer-getter.ts"],"sourcesContent":["import { greatest } from \"d3-array\";\nimport type { ZoomTransform } from \"d3-zoom\";\nimport type { NodeInterface } from \"
|
|
1
|
+
{"version":3,"file":"node-by-pointer-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/node-by-pointer-getter.ts"],"sourcesContent":["import { greatest } from \"d3-array\";\nimport type { ZoomTransform } from \"d3-zoom\";\nimport type { NodeInterface } from \"../../types\";\nimport { isOverlapsNode } from \"./is-overlaps-node\";\nimport { pointerGetter } from \"./pointer-getter\";\n\nexport type NodeByPointerGetterOptions<NodeData extends Record<string, unknown>> = {\n mouseEvent: MouseEvent | TouchEvent;\n areaRect: DOMRect | undefined;\n areaTransform: ZoomTransform;\n nodes: NodeInterface<NodeData>[];\n};\n\nexport function nodeByPointerGetter<NodeData extends Record<string, unknown>>({\n areaRect,\n areaTransform,\n mouseEvent,\n nodes,\n}: NodeByPointerGetterOptions<NodeData>): NodeInterface<NodeData> | undefined {\n if (!areaRect) return undefined;\n\n const [pointerX, pointerY] = pointerGetter(mouseEvent, areaRect, areaTransform);\n\n return greatest(nodes, (node) => {\n if (isOverlapsNode(node, pointerX, pointerY, undefined)) return node.index;\n });\n}\n"],"names":[],"mappings":";;;;AAaM,SAAU,mBAAmB,CAA2C,EAC5E,QAAQ,EACR,aAAa,EACb,UAAU,EACV,KAAK,GACgC,EAAA;AACrC,IAAA,IAAI,CAAC,QAAQ;AAAE,QAAA,OAAO,SAAS;AAE/B,IAAA,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,aAAa,CAAC;AAE/E,IAAA,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,KAAI;QAC9B,IAAI,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK;AAC5E,KAAC,CAAC;AACJ;;;;"}
|