@neo4j-nvl/interaction-handlers 0.3.6-e7f05fb1 → 0.3.6-eb8dc47c

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.
@@ -3,7 +3,7 @@ import '@testing-library/jest-dom';
3
3
  import { LassoInteraction, checkIntersection, checkLinesCrossing, checkPointInside } from '../interaction-handlers/lasso-interaction';
4
4
  jest.mock('@neo4j-nvl/layout-workers');
5
5
  const testNodes = [
6
- { id: '0', x: 10, y: 10 },
6
+ { id: '0', x: 25, y: 25 },
7
7
  { id: '1', x: 200, y: 200 }
8
8
  ];
9
9
  const testRels = [{ id: '10', from: '0', to: '1' }];
@@ -35,12 +35,12 @@ describe('LassoInteraction', () => {
35
35
  expect(myNVL.getSelectedNodes()).toHaveLength(0);
36
36
  const gesture1 = [
37
37
  createMouseEvent('mousedown', 0, 0),
38
- createMouseEvent('mousemove', 30, 0),
39
- createMouseEvent('mousemove', 20, 20),
38
+ createMouseEvent('mousemove', 50, 0),
39
+ createMouseEvent('mousemove', 20, 50),
40
40
  createMouseEvent('mouseup', 0, 0)
41
41
  ];
42
42
  const gesture2 = [
43
- createMouseEvent('mousedown', 200, 180),
43
+ createMouseEvent('mousedown', 200, 150),
44
44
  createMouseEvent('mousemove', 210, 210),
45
45
  createMouseEvent('mouseup', 190, 210)
46
46
  ];
@@ -76,6 +76,23 @@ describe('LassoInteraction', () => {
76
76
  resolve();
77
77
  });
78
78
  });
79
+ test('will not start when node is below pointer when dragging', () => {
80
+ lassoInteraction.updateCallback('onLassoStarted', startCallback);
81
+ lassoInteraction.updateCallback('onLassoSelect', selectCallback);
82
+ expect(myNVL.getSelectedNodes()).toHaveLength(0);
83
+ const gesture1 = [
84
+ createMouseEvent('mousedown', 10, 10),
85
+ createMouseEvent('mousemove', 50, 0),
86
+ createMouseEvent('mousemove', 20, 50),
87
+ createMouseEvent('mouseup', 0, 0)
88
+ ];
89
+ const container = myNVL.getContainer();
90
+ gesture1.forEach((e) => container.dispatchEvent(e));
91
+ return new Promise((resolve) => {
92
+ expect(startCallback).not.toHaveBeenCalled();
93
+ resolve();
94
+ });
95
+ });
79
96
  test('test for line crossing utility function', () => {
80
97
  const res1 = checkLinesCrossing([0, 0], [10, 10], [10, 0], [0, 10]);
81
98
  expect(res1).toBeTruthy();
@@ -106,10 +106,10 @@ export class BoxSelectInteraction extends BaseInteraction {
106
106
  }
107
107
  else {
108
108
  this.isBoxSelecting = true;
109
+ this.callCallbackIfRegistered('onBoxStarted', event);
109
110
  if (this.currentOptions.selectOnRelease === true) {
110
111
  this.nvlInstance.deselectAll();
111
112
  }
112
113
  }
113
- this.callCallbackIfRegistered('onBoxStarted', event);
114
114
  }
115
115
  }
@@ -1,4 +1,5 @@
1
1
  import concaveman from 'concaveman';
2
+ import { NODE_EDGE_WIDTH } from '../constants';
2
3
  import { OverlayRenderer } from '../overlay-renderer/overlay-renderer';
3
4
  import { BaseInteraction } from './base';
4
5
  import { getCanvasPosition, getWorldPosition } from './utils';
@@ -87,9 +88,18 @@ export class LassoInteraction extends BaseInteraction {
87
88
  this.addEventListener('mouseleave', this.endLasso, true);
88
89
  }
89
90
  startLasso = (event) => {
90
- this.active = true;
91
- this.points = [getCanvasPosition(this.containerInstance, event)];
92
- this.callCallbackIfRegistered('onLassoStarted', event);
91
+ const hits = this.nvlInstance.getHits(event, ['node'], { hitNodeMarginWidth: NODE_EDGE_WIDTH });
92
+ if (hits.nvlTargets.nodes.length > 0) {
93
+ this.active = false;
94
+ }
95
+ else {
96
+ this.active = true;
97
+ this.points = [getCanvasPosition(this.containerInstance, event)];
98
+ this.callCallbackIfRegistered('onLassoStarted', event);
99
+ if (this.currentOptions.selectOnRelease === true) {
100
+ this.nvlInstance.deselectAll();
101
+ }
102
+ }
93
103
  };
94
104
  handleMouseDown = (event) => {
95
105
  if (event.button === 0 && !this.active) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-nvl/interaction-handlers",
3
- "version": "0.3.6-e7f05fb1",
3
+ "version": "0.3.6-eb8dc47c",
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",
@@ -27,7 +27,7 @@
27
27
  "eslint": "yarn global:eslint ./src/"
28
28
  },
29
29
  "dependencies": {
30
- "@neo4j-nvl/base": "0.3.6-e7f05fb1",
30
+ "@neo4j-nvl/base": "0.3.6-eb8dc47c",
31
31
  "concaveman": "^1.2.1",
32
32
  "lodash": "4.17.21"
33
33
  },