@tsparticles/interaction-external-slow 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.
@@ -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-alpha.1
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
- "Slow": () => (/* reexport */ Slow),
95
- "loadExternalSlowInteraction": () => (/* binding */ loadExternalSlowInteraction)
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 = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity).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 === null || source === void 0 ? void 0 : source.slow);
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
- slow = options.interactivity.modes.slow;
162
- if (!slow || !radius || radius < 0 || !mousePos) {
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 = slow.factor;
169
- if (dist <= radius) {
170
- particle.slow.inRange = true;
171
- particle.slow.factor = proximityFactor / slowFactor;
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){var o;const r=this.container,i=r.interactivity.mouse,n=(null!==(o=null==e?void 0:e.interactivity)&&void 0!==o?o:r.actualOptions.interactivity).events;return n.onHover.enable&&!!i.position&&(0,t.isInArray)("slow",n.onHover.mode)}loadModeOptions(t,...o){t.slow||(t.slow=new e);for(const e of o)t.slow.load(null==e?void 0: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(),l=(0,t.getDistance)(i,a),c=l/n,d=s.factor;l<=n&&(e.slow.inRange=!0,e.slow.factor=c/d)}}async function n(t){await t.addInteractor("externalSlow",(t=>new o(t)))}})(),i})()));
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.1 by Matteo Bruni */
@@ -1,5 +1,5 @@
1
1
  import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
2
- import type { ISlow } from "../Interfaces/ISlow";
2
+ import type { ISlow } from "../Interfaces/ISlow.js";
3
3
  export declare class Slow implements ISlow, IOptionLoader<ISlow> {
4
4
  factor: number;
5
5
  radius: number;
@@ -1,5 +1,5 @@
1
1
  import type { Options } from "@tsparticles/engine";
2
- import type { SlowMode } from "../../Types";
2
+ import type { SlowMode } from "../../Types.js";
3
3
  export type SlowOptions = Options & {
4
4
  interactivity: {
5
5
  modes: SlowMode;
package/types/Slower.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { ExternalInteractorBase } from "@tsparticles/engine";
2
- import type { IDelta, IModes, Modes, Particle, RecursivePartial } from "@tsparticles/engine";
3
- import type { ISlowMode, SlowContainer, SlowMode } from "./Types";
1
+ import { ExternalInteractorBase, type IDelta, type IModes, type Modes, type Particle, type RecursivePartial } from "@tsparticles/engine";
2
+ import type { ISlowMode, SlowContainer, SlowMode } from "./Types.js";
4
3
  export declare class Slower extends ExternalInteractorBase<SlowContainer> {
5
4
  constructor(container: SlowContainer);
6
5
  clear(particle: Particle, delta: IDelta, force?: boolean): void;
package/types/Types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Container } from "@tsparticles/engine";
2
- import type { ISlow } from "./Options/Interfaces/ISlow";
3
- import type { Slow } from "./Options/Classes/Slow";
4
- import type { SlowOptions } from "./Options/Classes/SlowOptions";
2
+ import type { ISlow } from "./Options/Interfaces/ISlow.js";
3
+ import type { Slow } from "./Options/Classes/Slow.js";
4
+ import type { SlowOptions } from "./Options/Classes/SlowOptions.js";
5
5
  export type ISlowMode = {
6
6
  slow: ISlow;
7
7
  };
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>;
3
- export * from "./Options/Classes/Slow";
4
- export * from "./Options/Interfaces/ISlow";
2
+ export declare function loadExternalSlowInteraction(engine: Engine, refresh?: boolean): Promise<void>;
3
+ export * from "./Options/Classes/Slow.js";
4
+ export * from "./Options/Interfaces/ISlow.js";
package/umd/Slower.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/Slow"], factory);
7
+ define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Slow.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Slower = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
- const Slow_1 = require("./Options/Classes/Slow");
14
+ const Slow_js_1 = require("./Options/Classes/Slow.js");
15
15
  class Slower extends engine_1.ExternalInteractorBase {
16
16
  constructor(container) {
17
17
  super(container);
@@ -32,29 +32,29 @@
32
32
  async interact() {
33
33
  }
34
34
  isEnabled(particle) {
35
- var _a;
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) {
40
39
  if (!options.slow) {
41
- options.slow = new Slow_1.Slow();
40
+ options.slow = new Slow_js_1.Slow();
42
41
  }
43
42
  for (const source of sources) {
44
- options.slow.load(source === null || source === void 0 ? void 0 : source.slow);
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, slow = options.interactivity.modes.slow;
50
- if (!slow || !radius || radius < 0 || !mousePos) {
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 = slow.factor;
54
- if (dist <= radius) {
55
- particle.slow.inRange = true;
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
@@ -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", "./Slower", "./Options/Classes/Slow", "./Options/Interfaces/ISlow"], factory);
21
+ define(["require", "exports", "./Slower.js", "./Options/Classes/Slow.js", "./Options/Interfaces/ISlow.js"], factory);
22
22
  }
23
23
  })(function (require, exports) {
24
24
  "use strict";
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.loadExternalSlowInteraction = void 0;
27
- const Slower_1 = require("./Slower");
28
- async function loadExternalSlowInteraction(engine) {
29
- await engine.addInteractor("externalSlow", (container) => new Slower_1.Slower(container));
27
+ const Slower_js_1 = require("./Slower.js");
28
+ async function loadExternalSlowInteraction(engine, refresh = true) {
29
+ await engine.addInteractor("externalSlow", (container) => new Slower_js_1.Slower(container), refresh);
30
30
  }
31
31
  exports.loadExternalSlowInteraction = loadExternalSlowInteraction;
32
- __exportStar(require("./Options/Classes/Slow"), exports);
33
- __exportStar(require("./Options/Interfaces/ISlow"), exports);
32
+ __exportStar(require("./Options/Classes/Slow.js"), exports);
33
+ __exportStar(require("./Options/Interfaces/ISlow.js"), exports);
34
34
  });