@tsparticles/interaction-external-grab 3.9.1 → 4.0.0-alpha.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/346.min.js +2 -0
- package/346.min.js.LICENSE.txt +1 -0
- package/browser/Grabber.js +1 -3
- package/browser/Utils.js +3 -3
- package/browser/index.js +8 -8
- package/cjs/Grabber.js +11 -17
- package/cjs/Options/Classes/Grab.js +5 -9
- package/cjs/Options/Classes/GrabLinks.js +4 -8
- package/cjs/Options/Classes/GrabOptions.js +1 -2
- package/cjs/Options/Interfaces/IGrab.js +1 -2
- package/cjs/Options/Interfaces/IGrabLinks.js +1 -2
- package/cjs/Types.js +1 -2
- package/cjs/Utils.js +6 -10
- package/cjs/index.js +10 -27
- package/dist_browser_Grabber_js.js +40 -0
- package/esm/Grabber.js +1 -3
- package/esm/Utils.js +3 -3
- package/esm/index.js +8 -8
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.interaction.external.grab.js +217 -48
- package/tsparticles.interaction.external.grab.min.js +1 -1
- package/tsparticles.interaction.external.grab.min.js.LICENSE.txt +1 -1
- package/types/Utils.d.ts +1 -1
- package/types/index.d.ts +3 -3
- package/umd/Grabber.js +1 -3
- package/umd/Utils.js +3 -3
- package/umd/index.js +32 -9
package/346.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 346.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_interaction_external_grab=this.webpackChunk_tsparticles_interaction_external_grab||[]).push([[346],{346(t,n,e){e.d(n,{Grabber:()=>a});var i=e(303),o=e(456);function r(t,n,e,o,r){t.canvas.draw((a=>{const s=n.getPosition();!function(t,n,e,o,r,a,s=!1){(0,i.drawLine)(t,e,o),t.strokeStyle=(0,i.getStyleFromRgb)(r,s,a),t.lineWidth=n,t.stroke()}(a,n.retina.linksWidth??0,s,r,e,o,t.hdr)}))}class a extends i.ExternalInteractorBase{constructor(t,n){super(t),this._engine=n}clear(){}init(){const t=this.container,n=t.actualOptions.interactivity.modes.grab;n&&(t.retina.grabModeDistance=n.distance*t.retina.pixelRatio)}interact(){const t=this.container,n=t.actualOptions.interactivity;if(!n.modes.grab||!n.events.onHover.enable||t.interactivity.status!==i.mouseMoveEvent)return;const e=t.interactivity.mouse.position;if(!e)return;const o=t.retina.grabModeDistance;if(!o||o<0)return;const a=t.particles.quadTree.queryCircle(e,o,(t=>this.isEnabled(t)));for(const s of a){const a=s.getPosition(),c=(0,i.getDistance)(a,e);if(c>o)continue;const l=n.modes.grab.links,b=l.opacity,g=b-c*b/o;if(g<=0)continue;const d=l.color??s.options.links?.color;if(!t.particles.grabLineColor&&d){const e=n.modes.grab.links;t.particles.grabLineColor=(0,i.getLinkRandomColor)(this._engine,d,e.blink,e.consent)}const u=(0,i.getLinkColor)(s,void 0,t.particles.grabLineColor);u&&r(t,s,u,g,e)}}isEnabled(t){const n=this.container,e=n.interactivity.mouse,o=(t?.interactivity??n.actualOptions.interactivity).events;return o.onHover.enable&&!!e.position&&(0,i.isInArray)("grab",o.onHover.mode)}loadModeOptions(t,...n){t.grab??=new o.f;for(const e of n)t.grab.load(e?.grab)}reset(){}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Grab External Interaction v4.0.0-alpha.0 by Matteo Bruni */
|
package/browser/Grabber.js
CHANGED
|
@@ -58,9 +58,7 @@ export class Grabber extends ExternalInteractorBase {
|
|
|
58
58
|
return events.onHover.enable && !!mouse.position && isInArray(grabMode, events.onHover.mode);
|
|
59
59
|
}
|
|
60
60
|
loadModeOptions(options, ...sources) {
|
|
61
|
-
|
|
62
|
-
options.grab = new Grab();
|
|
63
|
-
}
|
|
61
|
+
options.grab ??= new Grab();
|
|
64
62
|
for (const source of sources) {
|
|
65
63
|
options.grab.load(source?.grab);
|
|
66
64
|
}
|
package/browser/Utils.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { drawLine, getStyleFromRgb } from "@tsparticles/engine";
|
|
2
2
|
const defaultWidth = 0;
|
|
3
|
-
export function drawGrabLine(context, width, begin, end, colorLine, opacity) {
|
|
3
|
+
export function drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false) {
|
|
4
4
|
drawLine(context, begin, end);
|
|
5
|
-
context.strokeStyle = getStyleFromRgb(colorLine, opacity);
|
|
5
|
+
context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity);
|
|
6
6
|
context.lineWidth = width;
|
|
7
7
|
context.stroke();
|
|
8
8
|
}
|
|
9
9
|
export function drawGrab(container, particle, lineColor, opacity, mousePos) {
|
|
10
10
|
container.canvas.draw(ctx => {
|
|
11
11
|
const beginPos = particle.getPosition();
|
|
12
|
-
drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity);
|
|
12
|
+
drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity, container.hdr);
|
|
13
13
|
});
|
|
14
14
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadExternalGrabInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addInteractor("externalGrab", async (container) => {
|
|
5
|
+
const { Grabber } = await import("./Grabber.js");
|
|
6
|
+
return new Grabber(container, engine);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
|
8
10
|
export * from "./Options/Classes/Grab.js";
|
|
9
11
|
export * from "./Options/Classes/GrabLinks.js";
|
|
10
|
-
export * from "./Options/Interfaces/IGrab.js";
|
|
11
|
-
export * from "./Options/Interfaces/IGrabLinks.js";
|
package/cjs/Grabber.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const Grab_js_1 = require("./Options/Classes/Grab.js");
|
|
6
|
-
const Utils_js_1 = require("./Utils.js");
|
|
1
|
+
import { ExternalInteractorBase, getDistance, getLinkColor, getLinkRandomColor, isInArray, mouseMoveEvent, } from "@tsparticles/engine";
|
|
2
|
+
import { Grab } from "./Options/Classes/Grab.js";
|
|
3
|
+
import { drawGrab } from "./Utils.js";
|
|
7
4
|
const grabMode = "grab", minDistance = 0, minOpacity = 0;
|
|
8
|
-
class Grabber extends
|
|
5
|
+
export class Grabber extends ExternalInteractorBase {
|
|
9
6
|
constructor(container, engine) {
|
|
10
7
|
super(container);
|
|
11
8
|
this._engine = engine;
|
|
@@ -23,7 +20,7 @@ class Grabber extends engine_1.ExternalInteractorBase {
|
|
|
23
20
|
const container = this.container, options = container.actualOptions, interactivity = options.interactivity;
|
|
24
21
|
if (!interactivity.modes.grab ||
|
|
25
22
|
!interactivity.events.onHover.enable ||
|
|
26
|
-
container.interactivity.status !==
|
|
23
|
+
container.interactivity.status !== mouseMoveEvent) {
|
|
27
24
|
return;
|
|
28
25
|
}
|
|
29
26
|
const mousePos = container.interactivity.mouse.position;
|
|
@@ -36,7 +33,7 @@ class Grabber extends engine_1.ExternalInteractorBase {
|
|
|
36
33
|
}
|
|
37
34
|
const query = container.particles.quadTree.queryCircle(mousePos, distance, p => this.isEnabled(p));
|
|
38
35
|
for (const particle of query) {
|
|
39
|
-
const pos = particle.getPosition(), pointDistance =
|
|
36
|
+
const pos = particle.getPosition(), pointDistance = getDistance(pos, mousePos);
|
|
40
37
|
if (pointDistance > distance) {
|
|
41
38
|
continue;
|
|
42
39
|
}
|
|
@@ -47,23 +44,21 @@ class Grabber extends engine_1.ExternalInteractorBase {
|
|
|
47
44
|
const optColor = grabLineOptions.color ?? particle.options.links?.color;
|
|
48
45
|
if (!container.particles.grabLineColor && optColor) {
|
|
49
46
|
const linksOptions = interactivity.modes.grab.links;
|
|
50
|
-
container.particles.grabLineColor =
|
|
47
|
+
container.particles.grabLineColor = getLinkRandomColor(this._engine, optColor, linksOptions.blink, linksOptions.consent);
|
|
51
48
|
}
|
|
52
|
-
const colorLine =
|
|
49
|
+
const colorLine = getLinkColor(particle, undefined, container.particles.grabLineColor);
|
|
53
50
|
if (!colorLine) {
|
|
54
51
|
continue;
|
|
55
52
|
}
|
|
56
|
-
|
|
53
|
+
drawGrab(container, particle, colorLine, opacityLine, mousePos);
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
56
|
isEnabled(particle) {
|
|
60
57
|
const container = this.container, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
|
|
61
|
-
return events.onHover.enable && !!mouse.position &&
|
|
58
|
+
return events.onHover.enable && !!mouse.position && isInArray(grabMode, events.onHover.mode);
|
|
62
59
|
}
|
|
63
60
|
loadModeOptions(options, ...sources) {
|
|
64
|
-
|
|
65
|
-
options.grab = new Grab_js_1.Grab();
|
|
66
|
-
}
|
|
61
|
+
options.grab ??= new Grab();
|
|
67
62
|
for (const source of sources) {
|
|
68
63
|
options.grab.load(source?.grab);
|
|
69
64
|
}
|
|
@@ -71,4 +66,3 @@ class Grabber extends engine_1.ExternalInteractorBase {
|
|
|
71
66
|
reset() {
|
|
72
67
|
}
|
|
73
68
|
}
|
|
74
|
-
exports.Grabber = Grabber;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const GrabLinks_js_1 = require("./GrabLinks.js");
|
|
6
|
-
class Grab {
|
|
1
|
+
import { isNull } from "@tsparticles/engine";
|
|
2
|
+
import { GrabLinks } from "./GrabLinks.js";
|
|
3
|
+
export class Grab {
|
|
7
4
|
constructor() {
|
|
8
5
|
this.distance = 100;
|
|
9
|
-
this.links = new
|
|
6
|
+
this.links = new GrabLinks();
|
|
10
7
|
}
|
|
11
8
|
load(data) {
|
|
12
|
-
if (
|
|
9
|
+
if (isNull(data)) {
|
|
13
10
|
return;
|
|
14
11
|
}
|
|
15
12
|
if (data.distance !== undefined) {
|
|
@@ -18,4 +15,3 @@ class Grab {
|
|
|
18
15
|
this.links.load(data.links);
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
|
-
exports.Grab = Grab;
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.GrabLinks = void 0;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
class GrabLinks {
|
|
1
|
+
import { OptionsColor, isNull } from "@tsparticles/engine";
|
|
2
|
+
export class GrabLinks {
|
|
6
3
|
constructor() {
|
|
7
4
|
this.blink = false;
|
|
8
5
|
this.consent = false;
|
|
9
6
|
this.opacity = 1;
|
|
10
7
|
}
|
|
11
8
|
load(data) {
|
|
12
|
-
if (
|
|
9
|
+
if (isNull(data)) {
|
|
13
10
|
return;
|
|
14
11
|
}
|
|
15
12
|
if (data.blink !== undefined) {
|
|
16
13
|
this.blink = data.blink;
|
|
17
14
|
}
|
|
18
15
|
if (data.color !== undefined) {
|
|
19
|
-
this.color =
|
|
16
|
+
this.color = OptionsColor.create(this.color, data.color);
|
|
20
17
|
}
|
|
21
18
|
if (data.consent !== undefined) {
|
|
22
19
|
this.consent = data.consent;
|
|
@@ -26,4 +23,3 @@ class GrabLinks {
|
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
|
-
exports.GrabLinks = GrabLinks;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/Types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/Utils.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.drawGrabLine = drawGrabLine;
|
|
4
|
-
exports.drawGrab = drawGrab;
|
|
5
|
-
const engine_1 = require("@tsparticles/engine");
|
|
1
|
+
import { drawLine, getStyleFromRgb } from "@tsparticles/engine";
|
|
6
2
|
const defaultWidth = 0;
|
|
7
|
-
function drawGrabLine(context, width, begin, end, colorLine, opacity) {
|
|
8
|
-
|
|
9
|
-
context.strokeStyle =
|
|
3
|
+
export function drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false) {
|
|
4
|
+
drawLine(context, begin, end);
|
|
5
|
+
context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity);
|
|
10
6
|
context.lineWidth = width;
|
|
11
7
|
context.stroke();
|
|
12
8
|
}
|
|
13
|
-
function drawGrab(container, particle, lineColor, opacity, mousePos) {
|
|
9
|
+
export function drawGrab(container, particle, lineColor, opacity, mousePos) {
|
|
14
10
|
container.canvas.draw(ctx => {
|
|
15
11
|
const beginPos = particle.getPosition();
|
|
16
|
-
drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity);
|
|
12
|
+
drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity, container.hdr);
|
|
17
13
|
});
|
|
18
14
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,28 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.loadExternalGrabInteraction = loadExternalGrabInteraction;
|
|
18
|
-
const Grabber_js_1 = require("./Grabber.js");
|
|
19
|
-
async function loadExternalGrabInteraction(engine, refresh = true) {
|
|
20
|
-
engine.checkVersion("3.9.1");
|
|
21
|
-
await engine.addInteractor("externalGrab", container => {
|
|
22
|
-
return Promise.resolve(new Grabber_js_1.Grabber(container, engine));
|
|
23
|
-
}, refresh);
|
|
1
|
+
export function loadExternalGrabInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addInteractor("externalGrab", async (container) => {
|
|
5
|
+
const { Grabber } = await import("./Grabber.js");
|
|
6
|
+
return new Grabber(container, engine);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
24
9
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
__exportStar(require("./Options/Interfaces/IGrab.js"), exports);
|
|
28
|
-
__exportStar(require("./Options/Interfaces/IGrabLinks.js"), exports);
|
|
10
|
+
export * from "./Options/Classes/Grab.js";
|
|
11
|
+
export * from "./Options/Classes/GrabLinks.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
* v4.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_interaction_external_grab"] = this["webpackChunk_tsparticles_interaction_external_grab"] || []).push([["dist_browser_Grabber_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/Grabber.js"
|
|
21
|
+
/*!*********************************!*\
|
|
22
|
+
!*** ./dist/browser/Grabber.js ***!
|
|
23
|
+
\*********************************/
|
|
24
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
|
+
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Grabber: () => (/* binding */ Grabber)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Options_Classes_Grab_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Grab.js */ \"./dist/browser/Options/Classes/Grab.js\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\n\nconst grabMode = \"grab\",\n minDistance = 0,\n minOpacity = 0;\nclass Grabber extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ExternalInteractorBase {\n constructor(container, engine) {\n super(container);\n this._engine = engine;\n }\n clear() {}\n init() {\n const container = this.container,\n grab = container.actualOptions.interactivity.modes.grab;\n if (!grab) {\n return;\n }\n container.retina.grabModeDistance = grab.distance * container.retina.pixelRatio;\n }\n interact() {\n const container = this.container,\n options = container.actualOptions,\n interactivity = options.interactivity;\n if (!interactivity.modes.grab || !interactivity.events.onHover.enable || container.interactivity.status !== _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.mouseMoveEvent) {\n return;\n }\n const mousePos = container.interactivity.mouse.position;\n if (!mousePos) {\n return;\n }\n const distance = container.retina.grabModeDistance;\n if (!distance || distance < minDistance) {\n return;\n }\n const query = container.particles.quadTree.queryCircle(mousePos, distance, p => this.isEnabled(p));\n for (const particle of query) {\n const pos = particle.getPosition(),\n pointDistance = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistance)(pos, mousePos);\n if (pointDistance > distance) {\n continue;\n }\n const grabLineOptions = interactivity.modes.grab.links,\n lineOpacity = grabLineOptions.opacity,\n opacityLine = lineOpacity - pointDistance * lineOpacity / distance;\n if (opacityLine <= minOpacity) {\n continue;\n }\n const optColor = grabLineOptions.color ?? particle.options.links?.color;\n if (!container.particles.grabLineColor && optColor) {\n const linksOptions = interactivity.modes.grab.links;\n container.particles.grabLineColor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getLinkRandomColor)(this._engine, optColor, linksOptions.blink, linksOptions.consent);\n }\n const colorLine = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getLinkColor)(particle, undefined, container.particles.grabLineColor);\n if (!colorLine) {\n continue;\n }\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__.drawGrab)(container, particle, colorLine, opacityLine, mousePos);\n }\n }\n isEnabled(particle) {\n const container = this.container,\n mouse = container.interactivity.mouse,\n events = (particle?.interactivity ?? container.actualOptions.interactivity).events;\n return events.onHover.enable && !!mouse.position && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(grabMode, events.onHover.mode);\n }\n loadModeOptions(options, ...sources) {\n options.grab ??= new _Options_Classes_Grab_js__WEBPACK_IMPORTED_MODULE_1__.Grab();\n for (const source of sources) {\n options.grab.load(source?.grab);\n }\n }\n reset() {}\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-grab/./dist/browser/Grabber.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/Utils.js"
|
|
31
|
+
/*!*******************************!*\
|
|
32
|
+
!*** ./dist/browser/Utils.js ***!
|
|
33
|
+
\*******************************/
|
|
34
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
+
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ drawGrab: () => (/* binding */ drawGrab),\n/* harmony export */ drawGrabLine: () => (/* binding */ drawGrabLine)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst defaultWidth = 0;\nfunction drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.drawLine)(context, begin, end);\n context.strokeStyle = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromRgb)(colorLine, hdr, opacity);\n context.lineWidth = width;\n context.stroke();\n}\nfunction drawGrab(container, particle, lineColor, opacity, mousePos) {\n container.canvas.draw(ctx => {\n const beginPos = particle.getPosition();\n drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity, container.hdr);\n });\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-grab/./dist/browser/Utils.js?\n}");
|
|
37
|
+
|
|
38
|
+
/***/ }
|
|
39
|
+
|
|
40
|
+
}]);
|
package/esm/Grabber.js
CHANGED
|
@@ -58,9 +58,7 @@ export class Grabber extends ExternalInteractorBase {
|
|
|
58
58
|
return events.onHover.enable && !!mouse.position && isInArray(grabMode, events.onHover.mode);
|
|
59
59
|
}
|
|
60
60
|
loadModeOptions(options, ...sources) {
|
|
61
|
-
|
|
62
|
-
options.grab = new Grab();
|
|
63
|
-
}
|
|
61
|
+
options.grab ??= new Grab();
|
|
64
62
|
for (const source of sources) {
|
|
65
63
|
options.grab.load(source?.grab);
|
|
66
64
|
}
|
package/esm/Utils.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { drawLine, getStyleFromRgb } from "@tsparticles/engine";
|
|
2
2
|
const defaultWidth = 0;
|
|
3
|
-
export function drawGrabLine(context, width, begin, end, colorLine, opacity) {
|
|
3
|
+
export function drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false) {
|
|
4
4
|
drawLine(context, begin, end);
|
|
5
|
-
context.strokeStyle = getStyleFromRgb(colorLine, opacity);
|
|
5
|
+
context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity);
|
|
6
6
|
context.lineWidth = width;
|
|
7
7
|
context.stroke();
|
|
8
8
|
}
|
|
9
9
|
export function drawGrab(container, particle, lineColor, opacity, mousePos) {
|
|
10
10
|
container.canvas.draw(ctx => {
|
|
11
11
|
const beginPos = particle.getPosition();
|
|
12
|
-
drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity);
|
|
12
|
+
drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity, container.hdr);
|
|
13
13
|
});
|
|
14
14
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadExternalGrabInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addInteractor("externalGrab", async (container) => {
|
|
5
|
+
const { Grabber } = await import("./Grabber.js");
|
|
6
|
+
return new Grabber(container, engine);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
|
8
10
|
export * from "./Options/Classes/Grab.js";
|
|
9
11
|
export * from "./Options/Classes/GrabLinks.js";
|
|
10
|
-
export * from "./Options/Interfaces/IGrab.js";
|
|
11
|
-
export * from "./Options/Interfaces/IGrabLinks.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-external-grab",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"description": "tsParticles grab external interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -87,9 +87,10 @@
|
|
|
87
87
|
"./package.json": "./package.json"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@tsparticles/engine": "
|
|
90
|
+
"@tsparticles/engine": "4.0.0-alpha.0"
|
|
91
91
|
},
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
|
94
|
-
}
|
|
94
|
+
},
|
|
95
|
+
"type": "module"
|
|
95
96
|
}
|