@tsparticles/interaction-external-grab 3.0.0-alpha.0 → 3.0.0-beta.0

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/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  # tsParticles External Grab Interaction
4
4
 
5
- [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-interaction-external-grab/badge)](https://www.jsdelivr.com/package/npm/tsparticles-interaction-external-grab)
6
- [![npmjs](https://badge.fury.io/js/tsparticles-interaction-external-grab.svg)](https://www.npmjs.com/package/tsparticles-interaction-external-grab)
7
- [![npmjs](https://img.shields.io/npm/dt/tsparticles-interaction-external-grab)](https://www.npmjs.com/package/tsparticles-interaction-external-grab) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/interaction-external-grab/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/interaction-external-grab)
6
+ [![npmjs](https://badge.fury.io/js/@tsparticles/interaction-external-grab.svg)](https://www.npmjs.com/package/@tsparticles/interaction-external-grab)
7
+ [![npmjs](https://img.shields.io/npm/dt/@tsparticles/interaction-external-grab)](https://www.npmjs.com/package/@tsparticles/interaction-external-grab) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
8
 
9
9
  [tsParticles](https://github.com/matteobruni/tsparticles) interaction plugin for grab effect around mouse or HTML
10
10
  elements.
@@ -27,14 +27,16 @@ loadExternalGrabInteraction;
27
27
  Once the scripts are loaded you can set up `tsParticles` and the interaction plugin like this:
28
28
 
29
29
  ```javascript
30
- loadExternalGrabInteraction(tsParticles);
31
-
32
- tsParticles.load({
33
- id: "tsparticles",
34
- options: {
35
- /* options */
36
- },
37
- });
30
+ (async () => {
31
+ await loadExternalGrabInteraction(tsParticles);
32
+
33
+ await tsParticles.load({
34
+ id: "tsparticles",
35
+ options: {
36
+ /* options */
37
+ },
38
+ });
39
+ })();
38
40
  ```
39
41
 
40
42
  ### ESM / CommonJS
@@ -42,29 +44,33 @@ tsParticles.load({
42
44
  This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
43
45
 
44
46
  ```shell
45
- $ npm install tsparticles-interaction-external-grab
47
+ $ npm install @tsparticles/interaction-external-grab
46
48
  ```
47
49
 
48
50
  or
49
51
 
50
52
  ```shell
51
- $ yarn add tsparticles-interaction-external-grab
53
+ $ yarn add @tsparticles/interaction-external-grab
52
54
  ```
53
55
 
54
56
  Then you need to import it in the app, like this:
55
57
 
56
58
  ```javascript
57
- const { tsParticles } = require("tsparticles-engine");
58
- const { loadExternalGrabInteraction } = require("tsparticles-interaction-external-grab");
59
+ const { tsParticles } = require("@tsparticles/engine");
60
+ const { loadExternalGrabInteraction } = require("@tsparticles/interaction-external-grab");
59
61
 
60
- loadExternalGrabInteraction(tsParticles);
62
+ (async () => {
63
+ await loadExternalGrabInteraction(tsParticles);
64
+ })();
61
65
  ```
62
66
 
63
67
  or
64
68
 
65
69
  ```javascript
66
- import { tsParticles } from "tsparticles-engine";
67
- import { loadExternalGrabInteraction } from "tsparticles-interaction-external-grab";
70
+ import { tsParticles } from "@tsparticles/engine";
71
+ import { loadExternalGrabInteraction } from "@tsparticles/interaction-external-grab";
68
72
 
69
- loadExternalGrabInteraction(tsParticles);
73
+ (async () => {
74
+ await loadExternalGrabInteraction(tsParticles);
75
+ })();
70
76
  ```
@@ -1,18 +1,6 @@
1
- import { ExternalInteractorBase, drawLine, getDistance, getLinkColor, getLinkRandomColor, getStyleFromRgb, isInArray, mouseMoveEvent, } from "@tsparticles/engine";
1
+ import { ExternalInteractorBase, getDistance, getLinkColor, getLinkRandomColor, isInArray, mouseMoveEvent, } from "@tsparticles/engine";
2
2
  import { Grab } from "./Options/Classes/Grab";
3
- export function drawGrabLine(context, width, begin, end, colorLine, opacity) {
4
- drawLine(context, begin, end);
5
- context.strokeStyle = getStyleFromRgb(colorLine, opacity);
6
- context.lineWidth = width;
7
- context.stroke();
8
- }
9
- function drawGrab(container, particle, lineColor, opacity, mousePos) {
10
- container.canvas.draw((ctx) => {
11
- var _a;
12
- const beginPos = particle.getPosition();
13
- drawGrabLine(ctx, (_a = particle.retina.linksWidth) !== null && _a !== void 0 ? _a : 0, beginPos, mousePos, lineColor, opacity);
14
- });
15
- }
3
+ import { drawGrab } from "./Utils";
16
4
  export class Grabber extends ExternalInteractorBase {
17
5
  constructor(container) {
18
6
  super(container);
@@ -27,7 +15,6 @@ export class Grabber extends ExternalInteractorBase {
27
15
  container.retina.grabModeDistance = grab.distance * container.retina.pixelRatio;
28
16
  }
29
17
  async interact() {
30
- var _a, _b;
31
18
  const container = this.container, options = container.actualOptions, interactivity = options.interactivity;
32
19
  if (!interactivity.modes.grab ||
33
20
  !interactivity.events.onHover.enable ||
@@ -52,21 +39,20 @@ export class Grabber extends ExternalInteractorBase {
52
39
  if (opacityLine <= 0) {
53
40
  continue;
54
41
  }
55
- const optColor = (_a = grabLineOptions.color) !== null && _a !== void 0 ? _a : (_b = particle.options.links) === null || _b === void 0 ? void 0 : _b.color;
42
+ const optColor = grabLineOptions.color ?? particle.options.links?.color;
56
43
  if (!container.particles.grabLineColor && optColor) {
57
44
  const linksOptions = interactivity.modes.grab.links;
58
45
  container.particles.grabLineColor = getLinkRandomColor(optColor, linksOptions.blink, linksOptions.consent);
59
46
  }
60
47
  const colorLine = getLinkColor(particle, undefined, container.particles.grabLineColor);
61
48
  if (!colorLine) {
62
- return;
49
+ continue;
63
50
  }
64
51
  drawGrab(container, particle, colorLine, opacityLine, mousePos);
65
52
  }
66
53
  }
67
54
  isEnabled(particle) {
68
- var _a;
69
- const container = this.container, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity).events;
55
+ const container = this.container, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
70
56
  return events.onHover.enable && !!mouse.position && isInArray("grab", events.onHover.mode);
71
57
  }
72
58
  loadModeOptions(options, ...sources) {
@@ -74,7 +60,7 @@ export class Grabber extends ExternalInteractorBase {
74
60
  options.grab = new Grab();
75
61
  }
76
62
  for (const source of sources) {
77
- options.grab.load(source === null || source === void 0 ? void 0 : source.grab);
63
+ options.grab.load(source?.grab);
78
64
  }
79
65
  }
80
66
  reset() {
@@ -17,13 +17,12 @@ export class Grab {
17
17
  this.links = value;
18
18
  }
19
19
  load(data) {
20
- var _a, _b;
21
20
  if (!data) {
22
21
  return;
23
22
  }
24
23
  if (data.distance !== undefined) {
25
24
  this.distance = data.distance;
26
25
  }
27
- this.links.load((_b = (_a = data.links) !== null && _a !== void 0 ? _a : data.lineLinked) !== null && _b !== void 0 ? _b : data.line_linked);
26
+ this.links.load(data.links ?? data.lineLinked ?? data.line_linked);
28
27
  }
29
28
  }
@@ -0,0 +1,13 @@
1
+ import { drawLine, getStyleFromRgb } from "@tsparticles/engine";
2
+ export function drawGrabLine(context, width, begin, end, colorLine, opacity) {
3
+ drawLine(context, begin, end);
4
+ context.strokeStyle = getStyleFromRgb(colorLine, opacity);
5
+ context.lineWidth = width;
6
+ context.stroke();
7
+ }
8
+ export function drawGrab(container, particle, lineColor, opacity, mousePos) {
9
+ container.canvas.draw((ctx) => {
10
+ const beginPos = particle.getPosition();
11
+ drawGrabLine(ctx, particle.retina.linksWidth ?? 0, beginPos, mousePos, lineColor, opacity);
12
+ });
13
+ }
package/browser/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Grabber } from "./Grabber";
2
- export async function loadExternalGrabInteraction(engine) {
3
- await engine.addInteractor("externalGrab", (container) => new Grabber(container));
2
+ export async function loadExternalGrabInteraction(engine, refresh = true) {
3
+ await engine.addInteractor("externalGrab", (container) => new Grabber(container), refresh);
4
4
  }
5
5
  export * from "./Options/Classes/Grab";
6
6
  export * from "./Options/Classes/GrabLinks";
package/cjs/Grabber.js CHANGED
@@ -1,31 +1,9 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Grabber = exports.drawGrabLine = void 0;
3
+ exports.Grabber = void 0;
13
4
  const engine_1 = require("@tsparticles/engine");
14
5
  const Grab_1 = require("./Options/Classes/Grab");
15
- function drawGrabLine(context, width, begin, end, colorLine, opacity) {
16
- (0, engine_1.drawLine)(context, begin, end);
17
- context.strokeStyle = (0, engine_1.getStyleFromRgb)(colorLine, opacity);
18
- context.lineWidth = width;
19
- context.stroke();
20
- }
21
- exports.drawGrabLine = drawGrabLine;
22
- function drawGrab(container, particle, lineColor, opacity, mousePos) {
23
- container.canvas.draw((ctx) => {
24
- var _a;
25
- const beginPos = particle.getPosition();
26
- drawGrabLine(ctx, (_a = particle.retina.linksWidth) !== null && _a !== void 0 ? _a : 0, beginPos, mousePos, lineColor, opacity);
27
- });
28
- }
6
+ const Utils_1 = require("./Utils");
29
7
  class Grabber extends engine_1.ExternalInteractorBase {
30
8
  constructor(container) {
31
9
  super(container);
@@ -39,49 +17,45 @@ class Grabber extends engine_1.ExternalInteractorBase {
39
17
  }
40
18
  container.retina.grabModeDistance = grab.distance * container.retina.pixelRatio;
41
19
  }
42
- interact() {
43
- var _a, _b;
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const container = this.container, options = container.actualOptions, interactivity = options.interactivity;
46
- if (!interactivity.modes.grab ||
47
- !interactivity.events.onHover.enable ||
48
- container.interactivity.status !== engine_1.mouseMoveEvent) {
49
- return;
20
+ async interact() {
21
+ const container = this.container, options = container.actualOptions, interactivity = options.interactivity;
22
+ if (!interactivity.modes.grab ||
23
+ !interactivity.events.onHover.enable ||
24
+ container.interactivity.status !== engine_1.mouseMoveEvent) {
25
+ return;
26
+ }
27
+ const mousePos = container.interactivity.mouse.position;
28
+ if (!mousePos) {
29
+ return;
30
+ }
31
+ const distance = container.retina.grabModeDistance;
32
+ if (!distance || distance < 0) {
33
+ return;
34
+ }
35
+ const query = container.particles.quadTree.queryCircle(mousePos, distance, (p) => this.isEnabled(p));
36
+ for (const particle of query) {
37
+ const pos = particle.getPosition(), pointDistance = (0, engine_1.getDistance)(pos, mousePos);
38
+ if (pointDistance > distance) {
39
+ continue;
50
40
  }
51
- const mousePos = container.interactivity.mouse.position;
52
- if (!mousePos) {
53
- return;
41
+ const grabLineOptions = interactivity.modes.grab.links, lineOpacity = grabLineOptions.opacity, opacityLine = lineOpacity - (pointDistance * lineOpacity) / distance;
42
+ if (opacityLine <= 0) {
43
+ continue;
54
44
  }
55
- const distance = container.retina.grabModeDistance;
56
- if (!distance || distance < 0) {
57
- return;
45
+ const optColor = grabLineOptions.color ?? particle.options.links?.color;
46
+ if (!container.particles.grabLineColor && optColor) {
47
+ const linksOptions = interactivity.modes.grab.links;
48
+ container.particles.grabLineColor = (0, engine_1.getLinkRandomColor)(optColor, linksOptions.blink, linksOptions.consent);
58
49
  }
59
- const query = container.particles.quadTree.queryCircle(mousePos, distance, (p) => this.isEnabled(p));
60
- for (const particle of query) {
61
- const pos = particle.getPosition(), pointDistance = (0, engine_1.getDistance)(pos, mousePos);
62
- if (pointDistance > distance) {
63
- continue;
64
- }
65
- const grabLineOptions = interactivity.modes.grab.links, lineOpacity = grabLineOptions.opacity, opacityLine = lineOpacity - (pointDistance * lineOpacity) / distance;
66
- if (opacityLine <= 0) {
67
- continue;
68
- }
69
- const optColor = (_a = grabLineOptions.color) !== null && _a !== void 0 ? _a : (_b = particle.options.links) === null || _b === void 0 ? void 0 : _b.color;
70
- if (!container.particles.grabLineColor && optColor) {
71
- const linksOptions = interactivity.modes.grab.links;
72
- container.particles.grabLineColor = (0, engine_1.getLinkRandomColor)(optColor, linksOptions.blink, linksOptions.consent);
73
- }
74
- const colorLine = (0, engine_1.getLinkColor)(particle, undefined, container.particles.grabLineColor);
75
- if (!colorLine) {
76
- return;
77
- }
78
- drawGrab(container, particle, colorLine, opacityLine, mousePos);
50
+ const colorLine = (0, engine_1.getLinkColor)(particle, undefined, container.particles.grabLineColor);
51
+ if (!colorLine) {
52
+ continue;
79
53
  }
80
- });
54
+ (0, Utils_1.drawGrab)(container, particle, colorLine, opacityLine, mousePos);
55
+ }
81
56
  }
82
57
  isEnabled(particle) {
83
- var _a;
84
- const container = this.container, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity).events;
58
+ const container = this.container, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
85
59
  return events.onHover.enable && !!mouse.position && (0, engine_1.isInArray)("grab", events.onHover.mode);
86
60
  }
87
61
  loadModeOptions(options, ...sources) {
@@ -89,7 +63,7 @@ class Grabber extends engine_1.ExternalInteractorBase {
89
63
  options.grab = new Grab_1.Grab();
90
64
  }
91
65
  for (const source of sources) {
92
- options.grab.load(source === null || source === void 0 ? void 0 : source.grab);
66
+ options.grab.load(source?.grab);
93
67
  }
94
68
  }
95
69
  reset() {
@@ -20,14 +20,13 @@ class Grab {
20
20
  this.links = value;
21
21
  }
22
22
  load(data) {
23
- var _a, _b;
24
23
  if (!data) {
25
24
  return;
26
25
  }
27
26
  if (data.distance !== undefined) {
28
27
  this.distance = data.distance;
29
28
  }
30
- this.links.load((_b = (_a = data.links) !== null && _a !== void 0 ? _a : data.lineLinked) !== null && _b !== void 0 ? _b : data.line_linked);
29
+ this.links.load(data.links ?? data.lineLinked ?? data.line_linked);
31
30
  }
32
31
  }
33
32
  exports.Grab = Grab;
package/cjs/Utils.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.drawGrab = exports.drawGrabLine = void 0;
4
+ const engine_1 = require("@tsparticles/engine");
5
+ function drawGrabLine(context, width, begin, end, colorLine, opacity) {
6
+ (0, engine_1.drawLine)(context, begin, end);
7
+ context.strokeStyle = (0, engine_1.getStyleFromRgb)(colorLine, opacity);
8
+ context.lineWidth = width;
9
+ context.stroke();
10
+ }
11
+ exports.drawGrabLine = drawGrabLine;
12
+ function drawGrab(container, particle, lineColor, opacity, mousePos) {
13
+ container.canvas.draw((ctx) => {
14
+ const beginPos = particle.getPosition();
15
+ drawGrabLine(ctx, particle.retina.linksWidth ?? 0, beginPos, mousePos, lineColor, opacity);
16
+ });
17
+ }
18
+ exports.drawGrab = drawGrab;
package/cjs/index.js CHANGED
@@ -13,22 +13,11 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
16
  Object.defineProperty(exports, "__esModule", { value: true });
26
17
  exports.loadExternalGrabInteraction = void 0;
27
18
  const Grabber_1 = require("./Grabber");
28
- function loadExternalGrabInteraction(engine) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- yield engine.addInteractor("externalGrab", (container) => new Grabber_1.Grabber(container));
31
- });
19
+ async function loadExternalGrabInteraction(engine, refresh = true) {
20
+ await engine.addInteractor("externalGrab", (container) => new Grabber_1.Grabber(container), refresh);
32
21
  }
33
22
  exports.loadExternalGrabInteraction = loadExternalGrabInteraction;
34
23
  __exportStar(require("./Options/Classes/Grab"), exports);
package/esm/Grabber.js CHANGED
@@ -1,18 +1,6 @@
1
- import { ExternalInteractorBase, drawLine, getDistance, getLinkColor, getLinkRandomColor, getStyleFromRgb, isInArray, mouseMoveEvent, } from "@tsparticles/engine";
1
+ import { ExternalInteractorBase, getDistance, getLinkColor, getLinkRandomColor, isInArray, mouseMoveEvent, } from "@tsparticles/engine";
2
2
  import { Grab } from "./Options/Classes/Grab";
3
- export function drawGrabLine(context, width, begin, end, colorLine, opacity) {
4
- drawLine(context, begin, end);
5
- context.strokeStyle = getStyleFromRgb(colorLine, opacity);
6
- context.lineWidth = width;
7
- context.stroke();
8
- }
9
- function drawGrab(container, particle, lineColor, opacity, mousePos) {
10
- container.canvas.draw((ctx) => {
11
- var _a;
12
- const beginPos = particle.getPosition();
13
- drawGrabLine(ctx, (_a = particle.retina.linksWidth) !== null && _a !== void 0 ? _a : 0, beginPos, mousePos, lineColor, opacity);
14
- });
15
- }
3
+ import { drawGrab } from "./Utils";
16
4
  export class Grabber extends ExternalInteractorBase {
17
5
  constructor(container) {
18
6
  super(container);
@@ -27,7 +15,6 @@ export class Grabber extends ExternalInteractorBase {
27
15
  container.retina.grabModeDistance = grab.distance * container.retina.pixelRatio;
28
16
  }
29
17
  async interact() {
30
- var _a, _b;
31
18
  const container = this.container, options = container.actualOptions, interactivity = options.interactivity;
32
19
  if (!interactivity.modes.grab ||
33
20
  !interactivity.events.onHover.enable ||
@@ -52,21 +39,20 @@ export class Grabber extends ExternalInteractorBase {
52
39
  if (opacityLine <= 0) {
53
40
  continue;
54
41
  }
55
- const optColor = (_a = grabLineOptions.color) !== null && _a !== void 0 ? _a : (_b = particle.options.links) === null || _b === void 0 ? void 0 : _b.color;
42
+ const optColor = grabLineOptions.color ?? particle.options.links?.color;
56
43
  if (!container.particles.grabLineColor && optColor) {
57
44
  const linksOptions = interactivity.modes.grab.links;
58
45
  container.particles.grabLineColor = getLinkRandomColor(optColor, linksOptions.blink, linksOptions.consent);
59
46
  }
60
47
  const colorLine = getLinkColor(particle, undefined, container.particles.grabLineColor);
61
48
  if (!colorLine) {
62
- return;
49
+ continue;
63
50
  }
64
51
  drawGrab(container, particle, colorLine, opacityLine, mousePos);
65
52
  }
66
53
  }
67
54
  isEnabled(particle) {
68
- var _a;
69
- const container = this.container, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity).events;
55
+ const container = this.container, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
70
56
  return events.onHover.enable && !!mouse.position && isInArray("grab", events.onHover.mode);
71
57
  }
72
58
  loadModeOptions(options, ...sources) {
@@ -74,7 +60,7 @@ export class Grabber extends ExternalInteractorBase {
74
60
  options.grab = new Grab();
75
61
  }
76
62
  for (const source of sources) {
77
- options.grab.load(source === null || source === void 0 ? void 0 : source.grab);
63
+ options.grab.load(source?.grab);
78
64
  }
79
65
  }
80
66
  reset() {
@@ -17,13 +17,12 @@ export class Grab {
17
17
  this.links = value;
18
18
  }
19
19
  load(data) {
20
- var _a, _b;
21
20
  if (!data) {
22
21
  return;
23
22
  }
24
23
  if (data.distance !== undefined) {
25
24
  this.distance = data.distance;
26
25
  }
27
- this.links.load((_b = (_a = data.links) !== null && _a !== void 0 ? _a : data.lineLinked) !== null && _b !== void 0 ? _b : data.line_linked);
26
+ this.links.load(data.links ?? data.lineLinked ?? data.line_linked);
28
27
  }
29
28
  }
package/esm/Utils.js ADDED
@@ -0,0 +1,13 @@
1
+ import { drawLine, getStyleFromRgb } from "@tsparticles/engine";
2
+ export function drawGrabLine(context, width, begin, end, colorLine, opacity) {
3
+ drawLine(context, begin, end);
4
+ context.strokeStyle = getStyleFromRgb(colorLine, opacity);
5
+ context.lineWidth = width;
6
+ context.stroke();
7
+ }
8
+ export function drawGrab(container, particle, lineColor, opacity, mousePos) {
9
+ container.canvas.draw((ctx) => {
10
+ const beginPos = particle.getPosition();
11
+ drawGrabLine(ctx, particle.retina.linksWidth ?? 0, beginPos, mousePos, lineColor, opacity);
12
+ });
13
+ }
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Grabber } from "./Grabber";
2
- export async function loadExternalGrabInteraction(engine) {
3
- await engine.addInteractor("externalGrab", (container) => new Grabber(container));
2
+ export async function loadExternalGrabInteraction(engine, refresh = true) {
3
+ await engine.addInteractor("externalGrab", (container) => new Grabber(container), refresh);
4
4
  }
5
5
  export * from "./Options/Classes/Grab";
6
6
  export * from "./Options/Classes/GrabLinks";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/interaction-external-grab",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.0-beta.0",
4
4
  "description": "tsParticles grab external interaction",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -73,10 +73,11 @@
73
73
  "unpkg": "tsparticles.interaction.external.grab.min.js",
74
74
  "module": "esm/index.js",
75
75
  "types": "types/index.d.ts",
76
+ "sideEffects": false,
77
+ "dependencies": {
78
+ "@tsparticles/engine": "^3.0.0-beta.0"
79
+ },
76
80
  "publishConfig": {
77
81
  "access": "public"
78
- },
79
- "dependencies": {
80
- "@tsparticles/engine": "^3.0.0-alpha.0"
81
82
  }
82
- }
83
+ }