@neo4j-nvl/interaction-handlers 0.3.4 → 0.3.5

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.
@@ -10,7 +10,7 @@ describe('ClickInteraction', () => {
10
10
  myNVL = new NVL(document.createElement('div'), [
11
11
  { id: '0', x: 100, y: 100 },
12
12
  { id: '1', x: 200, y: 200 }
13
- ], [{ id: '10', from: '0', to: '1' }], { disableWebGL: true, initialZoom: 1, layout: 'free' });
13
+ ], [{ id: '10', from: '0', to: '1' }], { disableWebGL: true, initialZoom: 1, layout: 'free', renderer: 'webgl' });
14
14
  clickInteraction = new ClickInteraction(myNVL, { selectOnClick: true });
15
15
  });
16
16
  afterEach(() => {
@@ -11,7 +11,7 @@ describe('HoverInteraction', () => {
11
11
  myNVL = new NVL(document.createElement('div'), [
12
12
  { id: '0', x: 100, y: 100 },
13
13
  { id: '1', x: 200, y: 200 }
14
- ], [{ id: '10', from: '0', to: '1' }], { disableWebGL: true, initialZoom: 1 });
14
+ ], [{ id: '10', from: '0', to: '1' }], { disableWebGL: true, initialZoom: 1, renderer: 'webgl' });
15
15
  hoverInteraction = new HoverInteraction(myNVL, { drawShadowOnHover: true });
16
16
  hoverInteraction.updateCallback('onHover', callbackMock);
17
17
  });
@@ -103,7 +103,14 @@ describe('LassoInteraction', () => {
103
103
  [390, 10],
104
104
  [500, 100]
105
105
  ]);
106
- expect(res2).toBeFalsy();
106
+ expect(res2).toBeTruthy();
107
+ const res3 = checkIntersection([
108
+ [50, 10],
109
+ [10, 10],
110
+ [10, 50],
111
+ [50, 50]
112
+ ]);
113
+ expect(res3).toBeFalsy();
107
114
  });
108
115
  test('test for point inside polygon utility function', () => {
109
116
  const res1 = checkPointInside(10, 10, [
@@ -24,11 +24,13 @@ export const checkLinesCrossing = (p1, p2, p3, p4) => {
24
24
  */
25
25
  export const checkIntersection = (polygon) => {
26
26
  for (let i = 0; i < polygon.length - 1; i++) {
27
- for (let j = i + 2; j < polygon.length - 1; j++) {
27
+ for (let j = i + 2; j < polygon.length; j++) {
28
28
  const line1p1 = polygon[i] ?? [0, 0];
29
29
  const line1p2 = polygon[i + 1] ?? [0, 0];
30
30
  const line2p1 = polygon[j] ?? [0, 0];
31
- const line2p2 = polygon[j + 1] ?? [0, 0];
31
+ // Handle segment from first to last point
32
+ const jNext = j < polygon.length - 1 ? j + 1 : 0;
33
+ const line2p2 = polygon[jNext] ?? [0, 0];
32
34
  if (checkLinesCrossing(line1p1, line1p2, line2p1, line2p2)) {
33
35
  return true;
34
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-nvl/interaction-handlers",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "license": "SEE LICENSE IN 'LICENSE.txt'",
5
5
  "homepage": "https://neo4j.com/docs/nvl/current/",
6
6
  "description": "Interaction handlers for the Neo4j Visualization Library",
@@ -19,15 +19,15 @@
19
19
  "lib"
20
20
  ],
21
21
  "scripts": {
22
- "build": "tsc",
23
- "watch": "tsc -w",
24
- "test": "jest",
22
+ "build": "yarn global:tsc",
23
+ "watch": "yarn global:tsc -w",
24
+ "test": "yarn global:jest",
25
25
  "prepack": "cp ../../LICENSE.txt ./",
26
26
  "postpack": "rm LICENSE.txt",
27
- "eslint": "eslint ./src/"
27
+ "eslint": "yarn global:eslint ./src/"
28
28
  },
29
29
  "dependencies": {
30
- "@neo4j-nvl/base": "0.3.4",
30
+ "@neo4j-nvl/base": "0.3.5",
31
31
  "concaveman": "^1.2.1",
32
32
  "lodash": "4.17.21"
33
33
  },
@@ -35,14 +35,6 @@
35
35
  "@testing-library/jest-dom": "^5.16.5",
36
36
  "@testing-library/react": "^13.4.0",
37
37
  "@types/concaveman": "1.1.6",
38
- "@types/lodash": "4.14.202",
39
- "eslint": "8.38.0",
40
- "jest": "^29.7.0",
41
- "typescript": "^5.4.5"
42
- },
43
- "peerDependencies": {
44
- "eslint": "*",
45
- "jest": "*",
46
- "typescript": "*"
38
+ "@types/lodash": "4.14.202"
47
39
  }
48
40
  }