@tsparticles/interaction-external-slow 3.0.0-alpha.1 → 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 +25 -19
- package/browser/Slower.js +10 -10
- package/browser/index.js +2 -2
- package/cjs/Slower.js +10 -21
- package/cjs/index.js +2 -13
- package/esm/Slower.js +10 -10
- package/esm/index.js +2 -2
- package/package.json +6 -5
- package/report.html +4 -4
- package/tsparticles.interaction.external.slow.js +17 -14
- package/tsparticles.interaction.external.slow.min.js +1 -1
- package/tsparticles.interaction.external.slow.min.js.LICENSE.txt +1 -8
- package/types/Slower.d.ts +1 -2
- package/types/index.d.ts +1 -1
- package/umd/Slower.js +9 -9
- package/umd/index.js +2 -2
|
@@ -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.0
|
|
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
|
+
Slow: () => (/* reexport */ Slow),
|
|
95
|
+
loadExternalSlowInteraction: () => (/* binding */ loadExternalSlowInteraction)
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
@@ -138,10 +138,9 @@ class Slower extends engine_root_window_.ExternalInteractorBase {
|
|
|
138
138
|
}
|
|
139
139
|
async interact() {}
|
|
140
140
|
isEnabled(particle) {
|
|
141
|
-
var _a;
|
|
142
141
|
const container = this.container,
|
|
143
142
|
mouse = container.interactivity.mouse,
|
|
144
|
-
events = (
|
|
143
|
+
events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
|
|
145
144
|
return events.onHover.enable && !!mouse.position && (0,engine_root_window_.isInArray)("slow", events.onHover.mode);
|
|
146
145
|
}
|
|
147
146
|
loadModeOptions(options, ...sources) {
|
|
@@ -149,7 +148,7 @@ class Slower extends engine_root_window_.ExternalInteractorBase {
|
|
|
149
148
|
options.slow = new Slow();
|
|
150
149
|
}
|
|
151
150
|
for (const source of sources) {
|
|
152
|
-
options.slow.load(source
|
|
151
|
+
options.slow.load(source?.slow);
|
|
153
152
|
}
|
|
154
153
|
}
|
|
155
154
|
reset(particle) {
|
|
@@ -158,24 +157,28 @@ class Slower extends engine_root_window_.ExternalInteractorBase {
|
|
|
158
157
|
options = container.actualOptions,
|
|
159
158
|
mousePos = container.interactivity.mouse.position,
|
|
160
159
|
radius = container.retina.slowModeRadius,
|
|
161
|
-
|
|
162
|
-
if (!
|
|
160
|
+
slowOptions = options.interactivity.modes.slow;
|
|
161
|
+
if (!slowOptions || !radius || radius < 0 || !mousePos) {
|
|
163
162
|
return;
|
|
164
163
|
}
|
|
165
164
|
const particlePos = particle.getPosition(),
|
|
166
165
|
dist = (0,engine_root_window_.getDistance)(mousePos, particlePos),
|
|
167
166
|
proximityFactor = dist / radius,
|
|
168
|
-
slowFactor =
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
167
|
+
slowFactor = slowOptions.factor,
|
|
168
|
+
{
|
|
169
|
+
slow
|
|
170
|
+
} = particle;
|
|
171
|
+
if (dist > radius) {
|
|
172
|
+
return;
|
|
172
173
|
}
|
|
174
|
+
slow.inRange = true;
|
|
175
|
+
slow.factor = proximityFactor / slowFactor;
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
178
|
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
176
179
|
|
|
177
|
-
async function loadExternalSlowInteraction(engine) {
|
|
178
|
-
await engine.addInteractor("externalSlow", container => new Slower(container));
|
|
180
|
+
async function loadExternalSlowInteraction(engine, refresh = true) {
|
|
181
|
+
await engine.addInteractor("externalSlow", container => new Slower(container), refresh);
|
|
179
182
|
}
|
|
180
183
|
|
|
181
184
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.interaction.external.slow.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 o="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var r in o)("object"==typeof exports?exports:t)[r]=o[r]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},o={};function r(t){var i=o[t];if(void 0!==i)return i.exports;var n=o[t]={exports:{}};return e[t](n,n.exports,r),n.exports}r.d=(t,e)=>{for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{r.r(i),r.d(i,{Slow:()=>e,loadExternalSlowInteraction:()=>n});var t=r(533);class e{constructor(){this.factor=3,this.radius=200}load(t){t&&(void 0!==t.factor&&(this.factor=t.factor),void 0!==t.radius&&(this.radius=t.radius))}}class o extends t.ExternalInteractorBase{constructor(t){super(t)}clear(t,e,o){t.slow.inRange&&!o||(t.slow.factor=1)}init(){const t=this.container,e=t.actualOptions.interactivity.modes.slow;e&&(t.retina.slowModeRadius=e.radius*t.retina.pixelRatio)}async interact(){}isEnabled(e){
|
|
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 o="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var r in o)("object"==typeof exports?exports:t)[r]=o[r]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},o={};function r(t){var i=o[t];if(void 0!==i)return i.exports;var n=o[t]={exports:{}};return e[t](n,n.exports,r),n.exports}r.d=(t,e)=>{for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{r.r(i),r.d(i,{Slow:()=>e,loadExternalSlowInteraction:()=>n});var t=r(533);class e{constructor(){this.factor=3,this.radius=200}load(t){t&&(void 0!==t.factor&&(this.factor=t.factor),void 0!==t.radius&&(this.radius=t.radius))}}class o extends t.ExternalInteractorBase{constructor(t){super(t)}clear(t,e,o){t.slow.inRange&&!o||(t.slow.factor=1)}init(){const t=this.container,e=t.actualOptions.interactivity.modes.slow;e&&(t.retina.slowModeRadius=e.radius*t.retina.pixelRatio)}async interact(){}isEnabled(e){const o=this.container,r=o.interactivity.mouse,i=(e?.interactivity??o.actualOptions.interactivity).events;return i.onHover.enable&&!!r.position&&(0,t.isInArray)("slow",i.onHover.mode)}loadModeOptions(t,...o){t.slow||(t.slow=new e);for(const e of o)t.slow.load(e?.slow)}reset(e){e.slow.inRange=!1;const o=this.container,r=o.actualOptions,i=o.interactivity.mouse.position,n=o.retina.slowModeRadius,s=r.interactivity.modes.slow;if(!s||!n||n<0||!i)return;const a=e.getPosition(),c=(0,t.getDistance)(i,a),l=c/n,d=s.factor,{slow:u}=e;c>n||(u.inRange=!0,u.factor=l/d)}}async function n(t,e=!0){await t.addInteractor("externalSlow",(t=>new o(t)),e)}})(),i})()));
|
|
@@ -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 Slow External Interaction v3.0.0-beta.0 by Matteo Bruni */
|
package/types/Slower.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ExternalInteractorBase } from "@tsparticles/engine";
|
|
2
|
-
import type { IDelta, IModes, Modes, Particle, RecursivePartial } from "@tsparticles/engine";
|
|
1
|
+
import { ExternalInteractorBase, type IDelta, type IModes, type Modes, type Particle, type RecursivePartial } from "@tsparticles/engine";
|
|
3
2
|
import type { ISlowMode, SlowContainer, SlowMode } from "./Types";
|
|
4
3
|
export declare class Slower extends ExternalInteractorBase<SlowContainer> {
|
|
5
4
|
constructor(container: SlowContainer);
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Engine } from "@tsparticles/engine";
|
|
2
|
-
export declare function loadExternalSlowInteraction(engine: Engine): Promise<void>;
|
|
2
|
+
export declare function loadExternalSlowInteraction(engine: Engine, refresh?: boolean): Promise<void>;
|
|
3
3
|
export * from "./Options/Classes/Slow";
|
|
4
4
|
export * from "./Options/Interfaces/ISlow";
|
package/umd/Slower.js
CHANGED
|
@@ -32,8 +32,7 @@
|
|
|
32
32
|
async interact() {
|
|
33
33
|
}
|
|
34
34
|
isEnabled(particle) {
|
|
35
|
-
|
|
36
|
-
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;
|
|
35
|
+
const container = this.container, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
|
|
37
36
|
return events.onHover.enable && !!mouse.position && (0, engine_1.isInArray)("slow", events.onHover.mode);
|
|
38
37
|
}
|
|
39
38
|
loadModeOptions(options, ...sources) {
|
|
@@ -41,20 +40,21 @@
|
|
|
41
40
|
options.slow = new Slow_1.Slow();
|
|
42
41
|
}
|
|
43
42
|
for (const source of sources) {
|
|
44
|
-
options.slow.load(source
|
|
43
|
+
options.slow.load(source?.slow);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
reset(particle) {
|
|
48
47
|
particle.slow.inRange = false;
|
|
49
|
-
const container = this.container, options = container.actualOptions, mousePos = container.interactivity.mouse.position, radius = container.retina.slowModeRadius,
|
|
50
|
-
if (!
|
|
48
|
+
const container = this.container, options = container.actualOptions, mousePos = container.interactivity.mouse.position, radius = container.retina.slowModeRadius, slowOptions = options.interactivity.modes.slow;
|
|
49
|
+
if (!slowOptions || !radius || radius < 0 || !mousePos) {
|
|
51
50
|
return;
|
|
52
51
|
}
|
|
53
|
-
const particlePos = particle.getPosition(), dist = (0, engine_1.getDistance)(mousePos, particlePos), proximityFactor = dist / radius, slowFactor =
|
|
54
|
-
if (dist
|
|
55
|
-
|
|
56
|
-
particle.slow.factor = proximityFactor / slowFactor;
|
|
52
|
+
const particlePos = particle.getPosition(), dist = (0, engine_1.getDistance)(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor, { slow } = particle;
|
|
53
|
+
if (dist > radius) {
|
|
54
|
+
return;
|
|
57
55
|
}
|
|
56
|
+
slow.inRange = true;
|
|
57
|
+
slow.factor = proximityFactor / slowFactor;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
exports.Slower = Slower;
|
package/umd/index.js
CHANGED
|
@@ -25,8 +25,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.loadExternalSlowInteraction = void 0;
|
|
27
27
|
const Slower_1 = require("./Slower");
|
|
28
|
-
async function loadExternalSlowInteraction(engine) {
|
|
29
|
-
await engine.addInteractor("externalSlow", (container) => new Slower_1.Slower(container));
|
|
28
|
+
async function loadExternalSlowInteraction(engine, refresh = true) {
|
|
29
|
+
await engine.addInteractor("externalSlow", (container) => new Slower_1.Slower(container), refresh);
|
|
30
30
|
}
|
|
31
31
|
exports.loadExternalSlowInteraction = loadExternalSlowInteraction;
|
|
32
32
|
__exportStar(require("./Options/Classes/Slow"), exports);
|