@tsparticles/interaction-external-trail 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/TrailMaker.js +14 -21
- package/browser/index.js +5 -5
- package/browser/package.json +1 -0
- package/cjs/TrailMaker.js +35 -53
- package/cjs/index.js +5 -16
- package/cjs/package.json +1 -0
- package/esm/TrailMaker.js +14 -21
- package/esm/index.js +5 -5
- package/esm/package.json +1 -0
- package/package.json +19 -6
- package/report.html +4 -4
- package/tsparticles.interaction.external.trail.js +17 -21
- package/tsparticles.interaction.external.trail.min.js +1 -1
- package/tsparticles.interaction.external.trail.min.js.LICENSE.txt +1 -8
- package/types/Options/Classes/Trail.d.ts +2 -2
- package/types/Options/Classes/TrailOptions.d.ts +1 -1
- package/types/TrailMaker.d.ts +2 -3
- package/types/Types.d.ts +3 -3
- package/types/index.d.ts +3 -3
- package/umd/TrailMaker.js +15 -22
- package/umd/index.js +6 -6
|
@@ -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,8 +91,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
91
91
|
|
|
92
92
|
// EXPORTS
|
|
93
93
|
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
Trail: () => (/* reexport */ Trail),
|
|
95
|
+
loadExternalTrailInteraction: () => (/* binding */ loadExternalTrailInteraction)
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
@@ -134,12 +134,14 @@ class TrailMaker extends engine_root_window_.ExternalInteractorBase {
|
|
|
134
134
|
clear() {}
|
|
135
135
|
init() {}
|
|
136
136
|
async interact(delta) {
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
const container = this.container,
|
|
138
|
+
{
|
|
139
|
+
interactivity
|
|
140
|
+
} = container;
|
|
141
|
+
if (!container.retina.reduceFactor) {
|
|
139
142
|
return;
|
|
140
143
|
}
|
|
141
|
-
const
|
|
142
|
-
options = container.actualOptions,
|
|
144
|
+
const options = container.actualOptions,
|
|
143
145
|
trailOptions = options.interactivity.modes.trail;
|
|
144
146
|
if (!trailOptions) {
|
|
145
147
|
return;
|
|
@@ -151,16 +153,11 @@ class TrailMaker extends engine_root_window_.ExternalInteractorBase {
|
|
|
151
153
|
if (this._delay < optDelay) {
|
|
152
154
|
return;
|
|
153
155
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
canEmit = false;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (container.interactivity.mouse.position) {
|
|
156
|
+
const canEmit = !(trailOptions.pauseOnStop && (interactivity.mouse.position === this._lastPosition || interactivity.mouse.position?.x === this._lastPosition?.x && interactivity.mouse.position?.y === this._lastPosition?.y));
|
|
157
|
+
const mousePos = container.interactivity.mouse.position;
|
|
158
|
+
if (mousePos) {
|
|
161
159
|
this._lastPosition = {
|
|
162
|
-
|
|
163
|
-
y: container.interactivity.mouse.position.y
|
|
160
|
+
...mousePos
|
|
164
161
|
};
|
|
165
162
|
} else {
|
|
166
163
|
delete this._lastPosition;
|
|
@@ -171,11 +168,10 @@ class TrailMaker extends engine_root_window_.ExternalInteractorBase {
|
|
|
171
168
|
this._delay -= optDelay;
|
|
172
169
|
}
|
|
173
170
|
isEnabled(particle) {
|
|
174
|
-
var _a;
|
|
175
171
|
const container = this.container,
|
|
176
172
|
options = container.actualOptions,
|
|
177
173
|
mouse = container.interactivity.mouse,
|
|
178
|
-
events = (
|
|
174
|
+
events = (particle?.interactivity ?? options.interactivity).events;
|
|
179
175
|
return mouse.clicking && mouse.inside && !!mouse.position && (0,engine_root_window_.isInArray)("trail", events.onClick.mode) || mouse.inside && !!mouse.position && (0,engine_root_window_.isInArray)("trail", events.onHover.mode);
|
|
180
176
|
}
|
|
181
177
|
loadModeOptions(options, ...sources) {
|
|
@@ -183,15 +179,15 @@ class TrailMaker extends engine_root_window_.ExternalInteractorBase {
|
|
|
183
179
|
options.trail = new Trail();
|
|
184
180
|
}
|
|
185
181
|
for (const source of sources) {
|
|
186
|
-
options.trail.load(source
|
|
182
|
+
options.trail.load(source?.trail);
|
|
187
183
|
}
|
|
188
184
|
}
|
|
189
185
|
reset() {}
|
|
190
186
|
}
|
|
191
187
|
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
192
188
|
|
|
193
|
-
async function loadExternalTrailInteraction(engine) {
|
|
194
|
-
await engine.addInteractor("externalTrail", container => new TrailMaker(container));
|
|
189
|
+
async function loadExternalTrailInteraction(engine, refresh = true) {
|
|
190
|
+
await engine.addInteractor("externalTrail", container => new TrailMaker(container), refresh);
|
|
195
191
|
}
|
|
196
192
|
|
|
197
193
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.interaction.external.trail.min.js.LICENSE.txt */
|
|
2
|
-
!function(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 o in i)("object"==typeof exports?exports:t)[o]=i[o]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},i={};function o(t){var r=i[t];if(void 0!==r)return r.exports;var n=i[t]={exports:{}};return e[t](n,n.exports,o),n.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{Trail:()=>e,loadExternalTrailInteraction:()=>n});var t=o(533);class e{constructor(){this.delay=1,this.pauseOnStop=!1,this.quantity=1}load(e){e&&(void 0!==e.delay&&(this.delay=e.delay),void 0!==e.quantity&&(this.quantity=e.quantity),void 0!==e.particles&&(this.particles=(0,t.deepExtend)({},e.particles)),void 0!==e.pauseOnStop&&(this.pauseOnStop=e.pauseOnStop))}}class i extends t.ExternalInteractorBase{constructor(t){super(t),this._delay=0}clear(){}init(){}async interact(t){const e=this.container,{interactivity:i}=e;if(!e.retina.reduceFactor)return;const o=e.actualOptions.interactivity.modes.trail;if(!o)return;const r=1e3*o.delay/this.container.retina.reduceFactor;if(this._delay<r&&(this._delay+=t.value),this._delay<r)return;const n=!(o.pauseOnStop&&(i.mouse.position===this._lastPosition||i.mouse.position?.x===this._lastPosition?.x&&i.mouse.position?.y===this._lastPosition?.y)),s=e.interactivity.mouse.position;s?this._lastPosition={...s}:delete this._lastPosition,n&&e.particles.push(o.quantity,e.interactivity.mouse,o.particles),this._delay-=r}isEnabled(e){const i=this.container,o=i.actualOptions,r=i.interactivity.mouse,n=(e?.interactivity??o.interactivity).events;return r.clicking&&r.inside&&!!r.position&&(0,t.isInArray)("trail",n.onClick.mode)||r.inside&&!!r.position&&(0,t.isInArray)("trail",n.onHover.mode)}loadModeOptions(t,...i){t.trail||(t.trail=new e);for(const e of i)t.trail.load(e?.trail)}reset(){}}async function n(t,e=!0){await t.addInteractor("externalTrail",(t=>new i(t)),e)}})(),r})()));
|
|
@@ -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 Trail External Interaction v3.0.0-beta.1 by Matteo Bruni */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { ITrail } from "../Interfaces/ITrail";
|
|
1
|
+
import { type IOptionLoader, type IParticlesOptions, type RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { ITrail } from "../Interfaces/ITrail.js";
|
|
3
3
|
export declare class Trail implements ITrail, IOptionLoader<ITrail> {
|
|
4
4
|
delay: number;
|
|
5
5
|
particles?: RecursivePartial<IParticlesOptions>;
|
package/types/TrailMaker.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ExternalInteractorBase } from "@tsparticles/engine";
|
|
2
|
-
import type {
|
|
3
|
-
import type { ITrailMode, TrailContainer, TrailMode } from "./Types";
|
|
1
|
+
import { ExternalInteractorBase, type IDelta, type IModes, type Modes, type Particle, type RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { ITrailMode, TrailContainer, TrailMode } from "./Types.js";
|
|
4
3
|
export declare class TrailMaker extends ExternalInteractorBase<TrailContainer> {
|
|
5
4
|
private _delay;
|
|
6
5
|
private _lastPosition?;
|
package/types/Types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Container } from "@tsparticles/engine";
|
|
2
|
-
import type { ITrail } from "./Options/Interfaces/ITrail";
|
|
3
|
-
import type { Trail } from "./Options/Classes/Trail";
|
|
4
|
-
import type { TrailOptions } from "./Options/Classes/TrailOptions";
|
|
2
|
+
import type { ITrail } from "./Options/Interfaces/ITrail.js";
|
|
3
|
+
import type { Trail } from "./Options/Classes/Trail.js";
|
|
4
|
+
import type { TrailOptions } from "./Options/Classes/TrailOptions.js";
|
|
5
5
|
export type ITrailMode = {
|
|
6
6
|
trail: ITrail;
|
|
7
7
|
};
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Engine } from "@tsparticles/engine";
|
|
2
|
-
export declare function loadExternalTrailInteraction(engine: Engine): Promise<void>;
|
|
3
|
-
export * from "./Options/Classes/Trail";
|
|
4
|
-
export * from "./Options/Interfaces/ITrail";
|
|
2
|
+
export declare function loadExternalTrailInteraction(engine: Engine, refresh?: boolean): Promise<void>;
|
|
3
|
+
export * from "./Options/Classes/Trail.js";
|
|
4
|
+
export * from "./Options/Interfaces/ITrail.js";
|
package/umd/TrailMaker.js
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
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/Trail"], factory);
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Trail.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.TrailMaker = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
const
|
|
14
|
+
const Trail_js_1 = require("./Options/Classes/Trail.js");
|
|
15
15
|
class TrailMaker extends engine_1.ExternalInteractorBase {
|
|
16
16
|
constructor(container) {
|
|
17
17
|
super(container);
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
init() {
|
|
23
23
|
}
|
|
24
24
|
async interact(delta) {
|
|
25
|
-
|
|
26
|
-
if (!
|
|
25
|
+
const container = this.container, { interactivity } = container;
|
|
26
|
+
if (!container.retina.reduceFactor) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const options = container.actualOptions, trailOptions = options.interactivity.modes.trail;
|
|
30
30
|
if (!trailOptions) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
@@ -37,19 +37,13 @@
|
|
|
37
37
|
if (this._delay < optDelay) {
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (container.interactivity.mouse.position) {
|
|
49
|
-
this._lastPosition = {
|
|
50
|
-
x: container.interactivity.mouse.position.x,
|
|
51
|
-
y: container.interactivity.mouse.position.y,
|
|
52
|
-
};
|
|
40
|
+
const canEmit = !(trailOptions.pauseOnStop &&
|
|
41
|
+
(interactivity.mouse.position === this._lastPosition ||
|
|
42
|
+
(interactivity.mouse.position?.x === this._lastPosition?.x &&
|
|
43
|
+
interactivity.mouse.position?.y === this._lastPosition?.y)));
|
|
44
|
+
const mousePos = container.interactivity.mouse.position;
|
|
45
|
+
if (mousePos) {
|
|
46
|
+
this._lastPosition = { ...mousePos };
|
|
53
47
|
}
|
|
54
48
|
else {
|
|
55
49
|
delete this._lastPosition;
|
|
@@ -60,17 +54,16 @@
|
|
|
60
54
|
this._delay -= optDelay;
|
|
61
55
|
}
|
|
62
56
|
isEnabled(particle) {
|
|
63
|
-
|
|
64
|
-
const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events;
|
|
57
|
+
const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? options.interactivity).events;
|
|
65
58
|
return ((mouse.clicking && mouse.inside && !!mouse.position && (0, engine_1.isInArray)("trail", events.onClick.mode)) ||
|
|
66
59
|
(mouse.inside && !!mouse.position && (0, engine_1.isInArray)("trail", events.onHover.mode)));
|
|
67
60
|
}
|
|
68
61
|
loadModeOptions(options, ...sources) {
|
|
69
62
|
if (!options.trail) {
|
|
70
|
-
options.trail = new
|
|
63
|
+
options.trail = new Trail_js_1.Trail();
|
|
71
64
|
}
|
|
72
65
|
for (const source of sources) {
|
|
73
|
-
options.trail.load(source
|
|
66
|
+
options.trail.load(source?.trail);
|
|
74
67
|
}
|
|
75
68
|
}
|
|
76
69
|
reset() {
|
package/umd/index.js
CHANGED
|
@@ -18,17 +18,17 @@ 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", "./TrailMaker", "./Options/Classes/Trail", "./Options/Interfaces/ITrail"], factory);
|
|
21
|
+
define(["require", "exports", "./TrailMaker.js", "./Options/Classes/Trail.js", "./Options/Interfaces/ITrail.js"], factory);
|
|
22
22
|
}
|
|
23
23
|
})(function (require, exports) {
|
|
24
24
|
"use strict";
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.loadExternalTrailInteraction = void 0;
|
|
27
|
-
const
|
|
28
|
-
async function loadExternalTrailInteraction(engine) {
|
|
29
|
-
await engine.addInteractor("externalTrail", (container) => new
|
|
27
|
+
const TrailMaker_js_1 = require("./TrailMaker.js");
|
|
28
|
+
async function loadExternalTrailInteraction(engine, refresh = true) {
|
|
29
|
+
await engine.addInteractor("externalTrail", (container) => new TrailMaker_js_1.TrailMaker(container), refresh);
|
|
30
30
|
}
|
|
31
31
|
exports.loadExternalTrailInteraction = loadExternalTrailInteraction;
|
|
32
|
-
__exportStar(require("./Options/Classes/Trail"), exports);
|
|
33
|
-
__exportStar(require("./Options/Interfaces/ITrail"), exports);
|
|
32
|
+
__exportStar(require("./Options/Classes/Trail.js"), exports);
|
|
33
|
+
__exportStar(require("./Options/Interfaces/ITrail.js"), exports);
|
|
34
34
|
});
|