@tsparticles/interaction-external-trail 3.9.0 → 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/232.min.js +2 -0
- package/232.min.js.LICENSE.txt +1 -0
- package/browser/TrailMaker.js +1 -3
- package/browser/index.js +8 -7
- package/cjs/Options/Classes/Trail.js +4 -8
- package/cjs/Options/Classes/TrailOptions.js +1 -2
- package/cjs/Options/Interfaces/ITrail.js +1 -2
- package/cjs/TrailMaker.js +7 -13
- package/cjs/Types.js +1 -2
- package/cjs/index.js +9 -25
- package/dist_browser_TrailMaker_js.js +30 -0
- package/esm/TrailMaker.js +1 -3
- package/esm/index.js +8 -7
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.interaction.external.trail.js +213 -34
- package/tsparticles.interaction.external.trail.min.js +1 -1
- package/tsparticles.interaction.external.trail.min.js.LICENSE.txt +1 -1
- package/types/index.d.ts +2 -2
- package/umd/TrailMaker.js +1 -3
- package/umd/index.js +32 -8
package/232.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 232.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_interaction_external_trail=this.webpackChunk_tsparticles_interaction_external_trail||[]).push([[232],{232(t,i,e){e.d(i,{TrailMaker:()=>o});var s=e(303),n=e(932);const a="trail";class o extends s.ExternalInteractorBase{constructor(t){super(t),this._delay=0}clear(){}init(){}interact(t){const i=this.container,{interactivity:e}=i;if(!i.retina.reduceFactor)return;const n=i.actualOptions.interactivity.modes.trail;if(!n)return;const a=n.delay*s.millisecondsToSeconds/this.container.retina.reduceFactor;if(this._delay<a&&(this._delay+=t.value),this._delay<a)return;const o=!(n.pauseOnStop&&(e.mouse.position===this._lastPosition||e.mouse.position?.x===this._lastPosition?.x&&e.mouse.position?.y===this._lastPosition?.y)),r=i.interactivity.mouse.position;r?this._lastPosition={...r}:delete this._lastPosition,o&&i.particles.push(n.quantity,i.interactivity.mouse,n.particles),this._delay-=a}isEnabled(t){const i=this.container,e=i.actualOptions,n=i.interactivity.mouse,o=(t?.interactivity??e.interactivity).events;return n.clicking&&n.inside&&!!n.position&&(0,s.isInArray)(a,o.onClick.mode)||n.inside&&!!n.position&&(0,s.isInArray)(a,o.onHover.mode)}loadModeOptions(t,...i){t.trail??=new n.X;for(const e of i)t.trail.load(e?.trail)}reset(){}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Trail External Interaction v4.0.0-alpha.0 by Matteo Bruni */
|
package/browser/TrailMaker.js
CHANGED
|
@@ -48,9 +48,7 @@ export class TrailMaker extends ExternalInteractorBase {
|
|
|
48
48
|
(mouse.inside && !!mouse.position && isInArray(trailMode, events.onHover.mode)));
|
|
49
49
|
}
|
|
50
50
|
loadModeOptions(options, ...sources) {
|
|
51
|
-
|
|
52
|
-
options.trail = new Trail();
|
|
53
|
-
}
|
|
51
|
+
options.trail ??= new Trail();
|
|
54
52
|
for (const source of sources) {
|
|
55
53
|
options.trail.load(source?.trail);
|
|
56
54
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadExternalTrailInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addInteractor("externalTrail", async (container) => {
|
|
5
|
+
const { TrailMaker } = await import("./TrailMaker.js");
|
|
6
|
+
return new TrailMaker(container);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
|
8
10
|
export * from "./Options/Classes/Trail.js";
|
|
9
|
-
export * from "./Options/Interfaces/ITrail.js";
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Trail = void 0;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
class Trail {
|
|
1
|
+
import { deepExtend, isNull, } from "@tsparticles/engine";
|
|
2
|
+
export class Trail {
|
|
6
3
|
constructor() {
|
|
7
4
|
this.delay = 1;
|
|
8
5
|
this.pauseOnStop = false;
|
|
9
6
|
this.quantity = 1;
|
|
10
7
|
}
|
|
11
8
|
load(data) {
|
|
12
|
-
if (
|
|
9
|
+
if (isNull(data)) {
|
|
13
10
|
return;
|
|
14
11
|
}
|
|
15
12
|
if (data.delay !== undefined) {
|
|
@@ -19,11 +16,10 @@ class Trail {
|
|
|
19
16
|
this.quantity = data.quantity;
|
|
20
17
|
}
|
|
21
18
|
if (data.particles !== undefined) {
|
|
22
|
-
this.particles =
|
|
19
|
+
this.particles = deepExtend({}, data.particles);
|
|
23
20
|
}
|
|
24
21
|
if (data.pauseOnStop !== undefined) {
|
|
25
22
|
this.pauseOnStop = data.pauseOnStop;
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
|
-
exports.Trail = Trail;
|
|
@@ -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/TrailMaker.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.TrailMaker = void 0;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const Trail_js_1 = require("./Options/Classes/Trail.js");
|
|
1
|
+
import { ExternalInteractorBase, isInArray, millisecondsToSeconds, } from "@tsparticles/engine";
|
|
2
|
+
import { Trail } from "./Options/Classes/Trail.js";
|
|
6
3
|
const trailMode = "trail";
|
|
7
|
-
class TrailMaker extends
|
|
4
|
+
export class TrailMaker extends ExternalInteractorBase {
|
|
8
5
|
constructor(container) {
|
|
9
6
|
super(container);
|
|
10
7
|
this._delay = 0;
|
|
@@ -22,7 +19,7 @@ class TrailMaker extends engine_1.ExternalInteractorBase {
|
|
|
22
19
|
if (!trailOptions) {
|
|
23
20
|
return;
|
|
24
21
|
}
|
|
25
|
-
const optDelay = (trailOptions.delay *
|
|
22
|
+
const optDelay = (trailOptions.delay * millisecondsToSeconds) / this.container.retina.reduceFactor;
|
|
26
23
|
if (this._delay < optDelay) {
|
|
27
24
|
this._delay += delta.value;
|
|
28
25
|
}
|
|
@@ -47,13 +44,11 @@ class TrailMaker extends engine_1.ExternalInteractorBase {
|
|
|
47
44
|
}
|
|
48
45
|
isEnabled(particle) {
|
|
49
46
|
const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? options.interactivity).events;
|
|
50
|
-
return ((mouse.clicking && mouse.inside && !!mouse.position &&
|
|
51
|
-
(mouse.inside && !!mouse.position &&
|
|
47
|
+
return ((mouse.clicking && mouse.inside && !!mouse.position && isInArray(trailMode, events.onClick.mode)) ||
|
|
48
|
+
(mouse.inside && !!mouse.position && isInArray(trailMode, events.onHover.mode)));
|
|
52
49
|
}
|
|
53
50
|
loadModeOptions(options, ...sources) {
|
|
54
|
-
|
|
55
|
-
options.trail = new Trail_js_1.Trail();
|
|
56
|
-
}
|
|
51
|
+
options.trail ??= new Trail();
|
|
57
52
|
for (const source of sources) {
|
|
58
53
|
options.trail.load(source?.trail);
|
|
59
54
|
}
|
|
@@ -61,4 +56,3 @@ class TrailMaker extends engine_1.ExternalInteractorBase {
|
|
|
61
56
|
reset() {
|
|
62
57
|
}
|
|
63
58
|
}
|
|
64
|
-
exports.TrailMaker = TrailMaker;
|
package/cjs/Types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/index.js
CHANGED
|
@@ -1,26 +1,10 @@
|
|
|
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.loadExternalTrailInteraction = loadExternalTrailInteraction;
|
|
18
|
-
const TrailMaker_js_1 = require("./TrailMaker.js");
|
|
19
|
-
async function loadExternalTrailInteraction(engine, refresh = true) {
|
|
20
|
-
engine.checkVersion("3.9.0");
|
|
21
|
-
await engine.addInteractor("externalTrail", container => {
|
|
22
|
-
return Promise.resolve(new TrailMaker_js_1.TrailMaker(container));
|
|
23
|
-
}, refresh);
|
|
1
|
+
export function loadExternalTrailInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addInteractor("externalTrail", async (container) => {
|
|
5
|
+
const { TrailMaker } = await import("./TrailMaker.js");
|
|
6
|
+
return new TrailMaker(container);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
24
9
|
}
|
|
25
|
-
|
|
26
|
-
__exportStar(require("./Options/Interfaces/ITrail.js"), exports);
|
|
10
|
+
export * from "./Options/Classes/Trail.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
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_trail"] = this["webpackChunk_tsparticles_interaction_external_trail"] || []).push([["dist_browser_TrailMaker_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/TrailMaker.js"
|
|
21
|
+
/*!************************************!*\
|
|
22
|
+
!*** ./dist/browser/TrailMaker.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 */ TrailMaker: () => (/* binding */ TrailMaker)\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_Trail_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Trail.js */ \"./dist/browser/Options/Classes/Trail.js\");\n\n\nconst trailMode = \"trail\";\nclass TrailMaker extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ExternalInteractorBase {\n constructor(container) {\n super(container);\n this._delay = 0;\n }\n clear() {}\n init() {}\n interact(delta) {\n const container = this.container,\n {\n interactivity\n } = container;\n if (!container.retina.reduceFactor) {\n return;\n }\n const options = container.actualOptions,\n trailOptions = options.interactivity.modes.trail;\n if (!trailOptions) {\n return;\n }\n const optDelay = trailOptions.delay * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.millisecondsToSeconds / this.container.retina.reduceFactor;\n if (this._delay < optDelay) {\n this._delay += delta.value;\n }\n if (this._delay < optDelay) {\n return;\n }\n const canEmit = !(trailOptions.pauseOnStop && (interactivity.mouse.position === this._lastPosition || interactivity.mouse.position?.x === this._lastPosition?.x && interactivity.mouse.position?.y === this._lastPosition?.y));\n const mousePos = container.interactivity.mouse.position;\n if (mousePos) {\n this._lastPosition = {\n ...mousePos\n };\n } else {\n delete this._lastPosition;\n }\n if (canEmit) {\n container.particles.push(trailOptions.quantity, container.interactivity.mouse, trailOptions.particles);\n }\n this._delay -= optDelay;\n }\n isEnabled(particle) {\n const container = this.container,\n options = container.actualOptions,\n mouse = container.interactivity.mouse,\n events = (particle?.interactivity ?? options.interactivity).events;\n return mouse.clicking && mouse.inside && !!mouse.position && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(trailMode, events.onClick.mode) || mouse.inside && !!mouse.position && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(trailMode, events.onHover.mode);\n }\n loadModeOptions(options, ...sources) {\n options.trail ??= new _Options_Classes_Trail_js__WEBPACK_IMPORTED_MODULE_1__.Trail();\n for (const source of sources) {\n options.trail.load(source?.trail);\n }\n }\n reset() {}\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-trail/./dist/browser/TrailMaker.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ }
|
|
29
|
+
|
|
30
|
+
}]);
|
package/esm/TrailMaker.js
CHANGED
|
@@ -48,9 +48,7 @@ export class TrailMaker extends ExternalInteractorBase {
|
|
|
48
48
|
(mouse.inside && !!mouse.position && isInArray(trailMode, events.onHover.mode)));
|
|
49
49
|
}
|
|
50
50
|
loadModeOptions(options, ...sources) {
|
|
51
|
-
|
|
52
|
-
options.trail = new Trail();
|
|
53
|
-
}
|
|
51
|
+
options.trail ??= new Trail();
|
|
54
52
|
for (const source of sources) {
|
|
55
53
|
options.trail.load(source?.trail);
|
|
56
54
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadExternalTrailInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addInteractor("externalTrail", async (container) => {
|
|
5
|
+
const { TrailMaker } = await import("./TrailMaker.js");
|
|
6
|
+
return new TrailMaker(container);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
|
8
10
|
export * from "./Options/Classes/Trail.js";
|
|
9
|
-
export * from "./Options/Interfaces/ITrail.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-external-trail",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"description": "tsParticles trail 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
|
}
|