@tsparticles/interaction-external-grab 3.0.0-alpha.1 → 3.0.0-beta.1
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 +25 -19
- package/browser/Grabber.js +7 -21
- package/browser/Options/Classes/Grab.js +2 -3
- package/browser/Utils.js +13 -0
- package/browser/index.js +7 -7
- package/browser/package.json +1 -0
- package/cjs/Grabber.js +38 -64
- package/cjs/Options/Classes/Grab.js +3 -4
- package/cjs/Utils.js +18 -0
- package/cjs/index.js +7 -18
- package/cjs/package.json +1 -0
- package/esm/Grabber.js +7 -21
- package/esm/Options/Classes/Grab.js +2 -3
- package/esm/Utils.js +13 -0
- package/esm/index.js +7 -7
- package/esm/package.json +1 -0
- package/package.json +19 -6
- package/report.html +4 -4
- package/tsparticles.interaction.external.grab.js +17 -18
- package/tsparticles.interaction.external.grab.min.js +1 -1
- package/tsparticles.interaction.external.grab.min.js.LICENSE.txt +1 -8
- package/types/Grabber.d.ts +2 -4
- package/types/Options/Classes/Grab.d.ts +2 -2
- package/types/Options/Classes/GrabLinks.d.ts +2 -3
- package/types/Options/Classes/GrabOptions.d.ts +1 -1
- package/types/Options/Interfaces/IGrab.d.ts +1 -1
- package/types/Types.d.ts +14 -4
- package/types/Utils.d.ts +4 -0
- package/types/index.d.ts +5 -5
- package/umd/Grabber.js +10 -25
- package/umd/Options/Classes/Grab.js +4 -5
- package/umd/Utils.js +28 -0
- package/umd/index.js +8 -8
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v3.0.0-
|
|
7
|
+
* v3.0.0-beta.1
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -91,9 +91,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
91
91
|
|
|
92
92
|
// EXPORTS
|
|
93
93
|
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
Grab: () => (/* reexport */ Grab),
|
|
95
|
+
GrabLinks: () => (/* reexport */ GrabLinks),
|
|
96
|
+
loadExternalGrabInteraction: () => (/* binding */ loadExternalGrabInteraction)
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
@@ -144,18 +144,16 @@ class Grab {
|
|
|
144
144
|
this.links = value;
|
|
145
145
|
}
|
|
146
146
|
load(data) {
|
|
147
|
-
var _a, _b;
|
|
148
147
|
if (!data) {
|
|
149
148
|
return;
|
|
150
149
|
}
|
|
151
150
|
if (data.distance !== undefined) {
|
|
152
151
|
this.distance = data.distance;
|
|
153
152
|
}
|
|
154
|
-
this.links.load(
|
|
153
|
+
this.links.load(data.links ?? data.lineLinked ?? data.line_linked);
|
|
155
154
|
}
|
|
156
155
|
}
|
|
157
|
-
;// CONCATENATED MODULE: ./dist/browser/
|
|
158
|
-
|
|
156
|
+
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
159
157
|
|
|
160
158
|
function drawGrabLine(context, width, begin, end, colorLine, opacity) {
|
|
161
159
|
(0,engine_root_window_.drawLine)(context, begin, end);
|
|
@@ -165,11 +163,14 @@ function drawGrabLine(context, width, begin, end, colorLine, opacity) {
|
|
|
165
163
|
}
|
|
166
164
|
function drawGrab(container, particle, lineColor, opacity, mousePos) {
|
|
167
165
|
container.canvas.draw(ctx => {
|
|
168
|
-
var _a;
|
|
169
166
|
const beginPos = particle.getPosition();
|
|
170
|
-
drawGrabLine(ctx,
|
|
167
|
+
drawGrabLine(ctx, particle.retina.linksWidth ?? 0, beginPos, mousePos, lineColor, opacity);
|
|
171
168
|
});
|
|
172
169
|
}
|
|
170
|
+
;// CONCATENATED MODULE: ./dist/browser/Grabber.js
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
173
174
|
class Grabber extends engine_root_window_.ExternalInteractorBase {
|
|
174
175
|
constructor(container) {
|
|
175
176
|
super(container);
|
|
@@ -184,7 +185,6 @@ class Grabber extends engine_root_window_.ExternalInteractorBase {
|
|
|
184
185
|
container.retina.grabModeDistance = grab.distance * container.retina.pixelRatio;
|
|
185
186
|
}
|
|
186
187
|
async interact() {
|
|
187
|
-
var _a, _b;
|
|
188
188
|
const container = this.container,
|
|
189
189
|
options = container.actualOptions,
|
|
190
190
|
interactivity = options.interactivity;
|
|
@@ -212,23 +212,22 @@ class Grabber extends engine_root_window_.ExternalInteractorBase {
|
|
|
212
212
|
if (opacityLine <= 0) {
|
|
213
213
|
continue;
|
|
214
214
|
}
|
|
215
|
-
const optColor =
|
|
215
|
+
const optColor = grabLineOptions.color ?? particle.options.links?.color;
|
|
216
216
|
if (!container.particles.grabLineColor && optColor) {
|
|
217
217
|
const linksOptions = interactivity.modes.grab.links;
|
|
218
218
|
container.particles.grabLineColor = (0,engine_root_window_.getLinkRandomColor)(optColor, linksOptions.blink, linksOptions.consent);
|
|
219
219
|
}
|
|
220
220
|
const colorLine = (0,engine_root_window_.getLinkColor)(particle, undefined, container.particles.grabLineColor);
|
|
221
221
|
if (!colorLine) {
|
|
222
|
-
|
|
222
|
+
continue;
|
|
223
223
|
}
|
|
224
224
|
drawGrab(container, particle, colorLine, opacityLine, mousePos);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
isEnabled(particle) {
|
|
228
|
-
var _a;
|
|
229
228
|
const container = this.container,
|
|
230
229
|
mouse = container.interactivity.mouse,
|
|
231
|
-
events = (
|
|
230
|
+
events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
|
|
232
231
|
return events.onHover.enable && !!mouse.position && (0,engine_root_window_.isInArray)("grab", events.onHover.mode);
|
|
233
232
|
}
|
|
234
233
|
loadModeOptions(options, ...sources) {
|
|
@@ -236,15 +235,15 @@ class Grabber extends engine_root_window_.ExternalInteractorBase {
|
|
|
236
235
|
options.grab = new Grab();
|
|
237
236
|
}
|
|
238
237
|
for (const source of sources) {
|
|
239
|
-
options.grab.load(source
|
|
238
|
+
options.grab.load(source?.grab);
|
|
240
239
|
}
|
|
241
240
|
}
|
|
242
241
|
reset() {}
|
|
243
242
|
}
|
|
244
243
|
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
245
244
|
|
|
246
|
-
async function loadExternalGrabInteraction(engine) {
|
|
247
|
-
await engine.addInteractor("externalGrab", container => new Grabber(container));
|
|
245
|
+
async function loadExternalGrabInteraction(engine, refresh = true) {
|
|
246
|
+
await engine.addInteractor("externalGrab", container => new Grabber(container), refresh);
|
|
248
247
|
}
|
|
249
248
|
|
|
250
249
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.interaction.external.grab.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var i="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var n in i)("object"==typeof exports?exports:t)[n]=i[n]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},i={};function n(t){var o=i[t];if(void 0!==o)return o.exports;var r=i[t]={exports:{}};return e[t](r,r.exports,n),r.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{Grab:()=>i,GrabLinks:()=>e,loadExternalGrabInteraction:()=>a});var t=n(533);class e{constructor(){this.blink=!1,this.consent=!1,this.opacity=1}load(e){e&&(void 0!==e.blink&&(this.blink=e.blink),void 0!==e.color&&(this.color=t.OptionsColor.create(this.color,e.color)),void 0!==e.consent&&(this.consent=e.consent),void 0!==e.opacity&&(this.opacity=e.opacity))}}class i{constructor(){this.distance=100,this.links=new e}get lineLinked(){return this.links}set lineLinked(t){this.links=t}get line_linked(){return this.links}set line_linked(t){this.links=t}load(t){
|
|
2
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var i="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var n in i)("object"==typeof exports?exports:t)[n]=i[n]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},i={};function n(t){var o=i[t];if(void 0!==o)return o.exports;var r=i[t]={exports:{}};return e[t](r,r.exports,n),r.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{Grab:()=>i,GrabLinks:()=>e,loadExternalGrabInteraction:()=>a});var t=n(533);class e{constructor(){this.blink=!1,this.consent=!1,this.opacity=1}load(e){e&&(void 0!==e.blink&&(this.blink=e.blink),void 0!==e.color&&(this.color=t.OptionsColor.create(this.color,e.color)),void 0!==e.consent&&(this.consent=e.consent),void 0!==e.opacity&&(this.opacity=e.opacity))}}class i{constructor(){this.distance=100,this.links=new e}get lineLinked(){return this.links}set lineLinked(t){this.links=t}get line_linked(){return this.links}set line_linked(t){this.links=t}load(t){t&&(void 0!==t.distance&&(this.distance=t.distance),this.links.load(t.links??t.lineLinked??t.line_linked))}}function r(e,i,n,o,r){e.canvas.draw((e=>{const s=i.getPosition();!function(e,i,n,o,r,s){(0,t.drawLine)(e,n,o),e.strokeStyle=(0,t.getStyleFromRgb)(r,s),e.lineWidth=i,e.stroke()}(e,i.retina.linksWidth??0,s,r,n,o)}))}class s extends t.ExternalInteractorBase{constructor(t){super(t)}clear(){}init(){const t=this.container,e=t.actualOptions.interactivity.modes.grab;e&&(t.retina.grabModeDistance=e.distance*t.retina.pixelRatio)}async interact(){const e=this.container,i=e.actualOptions.interactivity;if(!i.modes.grab||!i.events.onHover.enable||e.interactivity.status!==t.mouseMoveEvent)return;const n=e.interactivity.mouse.position;if(!n)return;const o=e.retina.grabModeDistance;if(!o||o<0)return;const s=e.particles.quadTree.queryCircle(n,o,(t=>this.isEnabled(t)));for(const a of s){const s=a.getPosition(),c=(0,t.getDistance)(s,n);if(c>o)continue;const l=i.modes.grab.links,d=l.opacity,p=d-c*d/o;if(p<=0)continue;const u=l.color??a.options.links?.color;if(!e.particles.grabLineColor&&u){const n=i.modes.grab.links;e.particles.grabLineColor=(0,t.getLinkRandomColor)(u,n.blink,n.consent)}const b=(0,t.getLinkColor)(a,void 0,e.particles.grabLineColor);b&&r(e,a,b,p,n)}}isEnabled(e){const i=this.container,n=i.interactivity.mouse,o=(e?.interactivity??i.actualOptions.interactivity).events;return o.onHover.enable&&!!n.position&&(0,t.isInArray)("grab",o.onHover.mode)}loadModeOptions(t,...e){t.grab||(t.grab=new i);for(const i of e)t.grab.load(i?.grab)}reset(){}}async function a(t,e=!0){await t.addInteractor("externalGrab",(t=>new s(t)),e)}})(),o})()));
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Author : Matteo Bruni
|
|
3
|
-
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
-
* Demo / Generator : https://particles.js.org/
|
|
5
|
-
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
-
* How to use? : Check the GitHub README
|
|
7
|
-
* v3.0.0-alpha.1
|
|
8
|
-
*/
|
|
1
|
+
/*! tsParticles Grab External Interaction v3.0.0-beta.1 by Matteo Bruni */
|
package/types/Grabber.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { ExternalInteractorBase } from "@tsparticles/engine";
|
|
2
|
-
import type { GrabContainer, GrabMode, IGrabMode } from "./Types";
|
|
3
|
-
import type { ICoordinates, IModes, IRgb, Modes, Particle, RecursivePartial } from "@tsparticles/engine";
|
|
4
|
-
export declare function drawGrabLine(context: CanvasRenderingContext2D, width: number, begin: ICoordinates, end: ICoordinates, colorLine: IRgb, opacity: number): void;
|
|
1
|
+
import { ExternalInteractorBase, type IModes, type Modes, type Particle, type RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { GrabContainer, GrabMode, IGrabMode } from "./Types.js";
|
|
5
3
|
export declare class Grabber extends ExternalInteractorBase<GrabContainer> {
|
|
6
4
|
constructor(container: GrabContainer);
|
|
7
5
|
clear(): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
|
|
2
|
-
import { GrabLinks } from "./GrabLinks";
|
|
3
|
-
import type { IGrab } from "../Interfaces/IGrab";
|
|
2
|
+
import { GrabLinks } from "./GrabLinks.js";
|
|
3
|
+
import type { IGrab } from "../Interfaces/IGrab.js";
|
|
4
4
|
export declare class Grab implements IGrab, IOptionLoader<IGrab> {
|
|
5
5
|
distance: number;
|
|
6
6
|
links: GrabLinks;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { IGrabLinks } from "../Interfaces/IGrabLinks";
|
|
3
|
-
import { OptionsColor } from "@tsparticles/engine";
|
|
1
|
+
import { type IOptionLoader, OptionsColor, type RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { IGrabLinks } from "../Interfaces/IGrabLinks.js";
|
|
4
3
|
export declare class GrabLinks implements IGrabLinks, IOptionLoader<IGrabLinks> {
|
|
5
4
|
blink: boolean;
|
|
6
5
|
color?: OptionsColor;
|
package/types/Types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Container, IRgb } from "@tsparticles/engine";
|
|
2
|
-
import type { Grab } from "./Options/Classes/Grab";
|
|
3
|
-
import type { GrabOptions } from "./Options/Classes/GrabOptions";
|
|
4
|
-
import type { IGrab } from "./Options/Interfaces/IGrab";
|
|
1
|
+
import type { Container, IRgb, OptionsColor, Particle } from "@tsparticles/engine";
|
|
2
|
+
import type { Grab } from "./Options/Classes/Grab.js";
|
|
3
|
+
import type { GrabOptions } from "./Options/Classes/GrabOptions.js";
|
|
4
|
+
import type { IGrab } from "./Options/Interfaces/IGrab.js";
|
|
5
5
|
export type IGrabMode = {
|
|
6
6
|
grab: IGrab;
|
|
7
7
|
};
|
|
@@ -17,3 +17,13 @@ export type GrabContainer = Container & {
|
|
|
17
17
|
grabModeDistance?: number;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
+
export type LinkParticle = Particle & {
|
|
21
|
+
options: {
|
|
22
|
+
links?: {
|
|
23
|
+
color?: OptionsColor;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
retina: {
|
|
27
|
+
linksWidth?: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
package/types/Utils.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GrabContainer, LinkParticle } from "./Types.js";
|
|
2
|
+
import { type ICoordinates, type IRgb } from "@tsparticles/engine";
|
|
3
|
+
export declare function drawGrabLine(context: CanvasRenderingContext2D, width: number, begin: ICoordinates, end: ICoordinates, colorLine: IRgb, opacity: number): void;
|
|
4
|
+
export declare function drawGrab(container: GrabContainer, particle: LinkParticle, lineColor: IRgb, opacity: number, mousePos: ICoordinates): void;
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Engine } from "@tsparticles/engine";
|
|
2
|
-
export declare function loadExternalGrabInteraction(engine: Engine): Promise<void>;
|
|
3
|
-
export * from "./Options/Classes/Grab";
|
|
4
|
-
export * from "./Options/Classes/GrabLinks";
|
|
5
|
-
export * from "./Options/Interfaces/IGrab";
|
|
6
|
-
export * from "./Options/Interfaces/IGrabLinks";
|
|
2
|
+
export declare function loadExternalGrabInteraction(engine: Engine, refresh?: boolean): Promise<void>;
|
|
3
|
+
export * from "./Options/Classes/Grab.js";
|
|
4
|
+
export * from "./Options/Classes/GrabLinks.js";
|
|
5
|
+
export * from "./Options/Interfaces/IGrab.js";
|
|
6
|
+
export * from "./Options/Interfaces/IGrabLinks.js";
|
package/umd/Grabber.js
CHANGED
|
@@ -4,28 +4,15 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Grab"], factory);
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Grab.js", "./Utils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Grabber =
|
|
12
|
+
exports.Grabber = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
const
|
|
15
|
-
|
|
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
|
-
}
|
|
14
|
+
const Grab_js_1 = require("./Options/Classes/Grab.js");
|
|
15
|
+
const Utils_js_1 = require("./Utils.js");
|
|
29
16
|
class Grabber extends engine_1.ExternalInteractorBase {
|
|
30
17
|
constructor(container) {
|
|
31
18
|
super(container);
|
|
@@ -40,7 +27,6 @@
|
|
|
40
27
|
container.retina.grabModeDistance = grab.distance * container.retina.pixelRatio;
|
|
41
28
|
}
|
|
42
29
|
async interact() {
|
|
43
|
-
var _a, _b;
|
|
44
30
|
const container = this.container, options = container.actualOptions, interactivity = options.interactivity;
|
|
45
31
|
if (!interactivity.modes.grab ||
|
|
46
32
|
!interactivity.events.onHover.enable ||
|
|
@@ -65,29 +51,28 @@
|
|
|
65
51
|
if (opacityLine <= 0) {
|
|
66
52
|
continue;
|
|
67
53
|
}
|
|
68
|
-
const optColor =
|
|
54
|
+
const optColor = grabLineOptions.color ?? particle.options.links?.color;
|
|
69
55
|
if (!container.particles.grabLineColor && optColor) {
|
|
70
56
|
const linksOptions = interactivity.modes.grab.links;
|
|
71
57
|
container.particles.grabLineColor = (0, engine_1.getLinkRandomColor)(optColor, linksOptions.blink, linksOptions.consent);
|
|
72
58
|
}
|
|
73
59
|
const colorLine = (0, engine_1.getLinkColor)(particle, undefined, container.particles.grabLineColor);
|
|
74
60
|
if (!colorLine) {
|
|
75
|
-
|
|
61
|
+
continue;
|
|
76
62
|
}
|
|
77
|
-
drawGrab(container, particle, colorLine, opacityLine, mousePos);
|
|
63
|
+
(0, Utils_js_1.drawGrab)(container, particle, colorLine, opacityLine, mousePos);
|
|
78
64
|
}
|
|
79
65
|
}
|
|
80
66
|
isEnabled(particle) {
|
|
81
|
-
|
|
82
|
-
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;
|
|
67
|
+
const container = this.container, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
|
|
83
68
|
return events.onHover.enable && !!mouse.position && (0, engine_1.isInArray)("grab", events.onHover.mode);
|
|
84
69
|
}
|
|
85
70
|
loadModeOptions(options, ...sources) {
|
|
86
71
|
if (!options.grab) {
|
|
87
|
-
options.grab = new
|
|
72
|
+
options.grab = new Grab_js_1.Grab();
|
|
88
73
|
}
|
|
89
74
|
for (const source of sources) {
|
|
90
|
-
options.grab.load(source
|
|
75
|
+
options.grab.load(source?.grab);
|
|
91
76
|
}
|
|
92
77
|
}
|
|
93
78
|
reset() {
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./GrabLinks"], factory);
|
|
7
|
+
define(["require", "exports", "./GrabLinks.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Grab = void 0;
|
|
13
|
-
const
|
|
13
|
+
const GrabLinks_js_1 = require("./GrabLinks.js");
|
|
14
14
|
class Grab {
|
|
15
15
|
constructor() {
|
|
16
16
|
this.distance = 100;
|
|
17
|
-
this.links = new
|
|
17
|
+
this.links = new GrabLinks_js_1.GrabLinks();
|
|
18
18
|
}
|
|
19
19
|
get lineLinked() {
|
|
20
20
|
return this.links;
|
|
@@ -29,14 +29,13 @@
|
|
|
29
29
|
this.links = value;
|
|
30
30
|
}
|
|
31
31
|
load(data) {
|
|
32
|
-
var _a, _b;
|
|
33
32
|
if (!data) {
|
|
34
33
|
return;
|
|
35
34
|
}
|
|
36
35
|
if (data.distance !== undefined) {
|
|
37
36
|
this.distance = data.distance;
|
|
38
37
|
}
|
|
39
|
-
this.links.load(
|
|
38
|
+
this.links.load(data.links ?? data.lineLinked ?? data.line_linked);
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
exports.Grab = Grab;
|
package/umd/Utils.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.drawGrab = exports.drawGrabLine = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
function drawGrabLine(context, width, begin, end, colorLine, opacity) {
|
|
15
|
+
(0, engine_1.drawLine)(context, begin, end);
|
|
16
|
+
context.strokeStyle = (0, engine_1.getStyleFromRgb)(colorLine, opacity);
|
|
17
|
+
context.lineWidth = width;
|
|
18
|
+
context.stroke();
|
|
19
|
+
}
|
|
20
|
+
exports.drawGrabLine = drawGrabLine;
|
|
21
|
+
function drawGrab(container, particle, lineColor, opacity, mousePos) {
|
|
22
|
+
container.canvas.draw((ctx) => {
|
|
23
|
+
const beginPos = particle.getPosition();
|
|
24
|
+
drawGrabLine(ctx, particle.retina.linksWidth ?? 0, beginPos, mousePos, lineColor, opacity);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.drawGrab = drawGrab;
|
|
28
|
+
});
|
package/umd/index.js
CHANGED
|
@@ -18,19 +18,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
if (v !== undefined) module.exports = v;
|
|
19
19
|
}
|
|
20
20
|
else if (typeof define === "function" && define.amd) {
|
|
21
|
-
define(["require", "exports", "./Grabber", "./Options/Classes/Grab", "./Options/Classes/GrabLinks", "./Options/Interfaces/IGrab", "./Options/Interfaces/IGrabLinks"], factory);
|
|
21
|
+
define(["require", "exports", "./Grabber.js", "./Options/Classes/Grab.js", "./Options/Classes/GrabLinks.js", "./Options/Interfaces/IGrab.js", "./Options/Interfaces/IGrabLinks.js"], factory);
|
|
22
22
|
}
|
|
23
23
|
})(function (require, exports) {
|
|
24
24
|
"use strict";
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.loadExternalGrabInteraction = void 0;
|
|
27
|
-
const
|
|
28
|
-
async function loadExternalGrabInteraction(engine) {
|
|
29
|
-
await engine.addInteractor("externalGrab", (container) => new
|
|
27
|
+
const Grabber_js_1 = require("./Grabber.js");
|
|
28
|
+
async function loadExternalGrabInteraction(engine, refresh = true) {
|
|
29
|
+
await engine.addInteractor("externalGrab", (container) => new Grabber_js_1.Grabber(container), refresh);
|
|
30
30
|
}
|
|
31
31
|
exports.loadExternalGrabInteraction = loadExternalGrabInteraction;
|
|
32
|
-
__exportStar(require("./Options/Classes/Grab"), exports);
|
|
33
|
-
__exportStar(require("./Options/Classes/GrabLinks"), exports);
|
|
34
|
-
__exportStar(require("./Options/Interfaces/IGrab"), exports);
|
|
35
|
-
__exportStar(require("./Options/Interfaces/IGrabLinks"), exports);
|
|
32
|
+
__exportStar(require("./Options/Classes/Grab.js"), exports);
|
|
33
|
+
__exportStar(require("./Options/Classes/GrabLinks.js"), exports);
|
|
34
|
+
__exportStar(require("./Options/Interfaces/IGrab.js"), exports);
|
|
35
|
+
__exportStar(require("./Options/Interfaces/IGrabLinks.js"), exports);
|
|
36
36
|
});
|