@tsparticles/interaction-external-attract 3.0.0-beta.3 → 3.0.0-beta.5
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/browser/Attractor.js +5 -4
- package/cjs/Attractor.js +5 -4
- package/esm/Attractor.js +5 -4
- package/package.json +3 -3
- package/report.html +4 -22
- package/tsparticles.interaction.external.attract.js +6 -5
- package/tsparticles.interaction.external.attract.min.js +1 -1
- package/tsparticles.interaction.external.attract.min.js.LICENSE.txt +1 -1
- package/umd/Attractor.js +5 -4
|
@@ -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-beta.
|
|
7
|
+
* v3.0.0-beta.5
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -134,6 +134,7 @@ class Attract {
|
|
|
134
134
|
;// CONCATENATED MODULE: ./dist/browser/Attractor.js
|
|
135
135
|
|
|
136
136
|
|
|
137
|
+
const attractMode = "attract";
|
|
137
138
|
class Attractor extends engine_root_window_.ExternalInteractorBase {
|
|
138
139
|
constructor(engine, container) {
|
|
139
140
|
super(container);
|
|
@@ -205,7 +206,7 @@ class Attractor extends engine_root_window_.ExternalInteractorBase {
|
|
|
205
206
|
this.handleClickMode = mode => {
|
|
206
207
|
const options = this.container.actualOptions,
|
|
207
208
|
attract = options.interactivity.modes.attract;
|
|
208
|
-
if (!attract || mode !==
|
|
209
|
+
if (!attract || mode !== attractMode) {
|
|
209
210
|
return;
|
|
210
211
|
}
|
|
211
212
|
if (!container.attract) {
|
|
@@ -254,9 +255,9 @@ class Attractor extends engine_root_window_.ExternalInteractorBase {
|
|
|
254
255
|
hoverMode = events.onHover.mode,
|
|
255
256
|
clickEnabled = events.onClick.enable,
|
|
256
257
|
clickMode = events.onClick.mode;
|
|
257
|
-
if (mouseMoveStatus && hoverEnabled && (0,engine_root_window_.isInArray)(
|
|
258
|
+
if (mouseMoveStatus && hoverEnabled && (0,engine_root_window_.isInArray)(attractMode, hoverMode)) {
|
|
258
259
|
this._hoverAttract();
|
|
259
|
-
} else if (clickEnabled && (0,engine_root_window_.isInArray)(
|
|
260
|
+
} else if (clickEnabled && (0,engine_root_window_.isInArray)(attractMode, clickMode)) {
|
|
260
261
|
this._clickAttract();
|
|
261
262
|
}
|
|
262
263
|
}
|
|
@@ -270,7 +271,7 @@ class Attractor extends engine_root_window_.ExternalInteractorBase {
|
|
|
270
271
|
}
|
|
271
272
|
const hoverMode = events.onHover.mode,
|
|
272
273
|
clickMode = events.onClick.mode;
|
|
273
|
-
return (0,engine_root_window_.isInArray)(
|
|
274
|
+
return (0,engine_root_window_.isInArray)(attractMode, hoverMode) || (0,engine_root_window_.isInArray)(attractMode, clickMode);
|
|
274
275
|
}
|
|
275
276
|
loadModeOptions(options, ...sources) {
|
|
276
277
|
if (!options.attract) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.interaction.external.attract.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 i="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var a in i)("object"==typeof exports?exports:t)[a]=i[a]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},i={};function a(t){var r=i[t];if(void 0!==r)return r.exports;var n=i[t]={exports:{}};return e[t](n,n.exports,a),n.exports}a.d=(t,e)=>{for(var i in e)a.o(e,i)&&!a.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{a.r(r),a.d(r,{Attract:()=>e,loadExternalAttractInteraction:()=>
|
|
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 a in i)("object"==typeof exports?exports:t)[a]=i[a]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},i={};function a(t){var r=i[t];if(void 0!==r)return r.exports;var n=i[t]={exports:{}};return e[t](n,n.exports,a),n.exports}a.d=(t,e)=>{for(var i in e)a.o(e,i)&&!a.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{a.r(r),a.d(r,{Attract:()=>e,loadExternalAttractInteraction:()=>o});var t=a(533);class e{constructor(){this.distance=200,this.duration=.4,this.easing="ease-out-quad",this.factor=1,this.maxSpeed=50,this.speed=1}load(t){t&&(void 0!==t.distance&&(this.distance=t.distance),void 0!==t.duration&&(this.duration=t.duration),void 0!==t.easing&&(this.easing=t.easing),void 0!==t.factor&&(this.factor=t.factor),void 0!==t.maxSpeed&&(this.maxSpeed=t.maxSpeed),void 0!==t.speed&&(this.speed=t.speed))}}const i="attract";class n extends t.ExternalInteractorBase{constructor(e,a){super(a),this._clickAttract=()=>{const e=this.container;e.attract||(e.attract={particles:[]});const{attract:i}=e;if(i.finish||(i.count||(i.count=0),i.count++,i.count===e.particles.count&&(i.finish=!0)),i.clicking){const i=e.interactivity.mouse.clickPosition,a=e.retina.attractModeDistance;if(!a||a<0||!i)return;this._processAttract(i,a,new t.Circle(i.x,i.y,a))}else!1===i.clicking&&(i.particles=[])},this._hoverAttract=()=>{const e=this.container,i=e.interactivity.mouse.position,a=e.retina.attractModeDistance;!a||a<0||!i||this._processAttract(i,a,new t.Circle(i.x,i.y,a))},this._processAttract=(e,i,a)=>{const r=this.container,n=r.actualOptions.interactivity.modes.attract;if(!n)return;const o=r.particles.quadTree.query(a,(t=>this.isEnabled(t)));for(const a of o){const{dx:r,dy:o,distance:c}=(0,t.getDistances)(a.position,e),s=n.speed*n.factor,d=(0,t.clamp)((0,t.getEasing)(n.easing)(1-c/i)*s,0,n.maxSpeed),l=t.Vector.create(0===c?s:r/c*d,0===c?s:o/c*d);a.position.subFrom(l)}},this._engine=e,a.attract||(a.attract={particles:[]}),this.handleClickMode=t=>{const e=this.container.actualOptions.interactivity.modes.attract;if(e&&t===i){a.attract||(a.attract={particles:[]}),a.attract.clicking=!0,a.attract.count=0;for(const t of a.attract.particles)this.isEnabled(t)&&t.velocity.setTo(t.initialVelocity);a.attract.particles=[],a.attract.finish=!1,setTimeout((()=>{a.destroyed||(a.attract||(a.attract={particles:[]}),a.attract.clicking=!1)}),1e3*e.duration)}}}clear(){}init(){const t=this.container,e=t.actualOptions.interactivity.modes.attract;e&&(t.retina.attractModeDistance=e.distance*t.retina.pixelRatio)}async interact(){const e=this.container,a=e.actualOptions,r=e.interactivity.status===t.mouseMoveEvent,n=a.interactivity.events,o=n.onHover.enable,c=n.onHover.mode,s=n.onClick.enable,d=n.onClick.mode;r&&o&&(0,t.isInArray)(i,c)?this._hoverAttract():s&&(0,t.isInArray)(i,d)&&this._clickAttract()}isEnabled(e){const a=this.container,r=a.actualOptions,n=a.interactivity.mouse,o=(e?.interactivity??r.interactivity).events;if(!(n.position&&o.onHover.enable||n.clickPosition&&o.onClick.enable))return!1;const c=o.onHover.mode,s=o.onClick.mode;return(0,t.isInArray)(i,c)||(0,t.isInArray)(i,s)}loadModeOptions(t,...i){t.attract||(t.attract=new e);for(const e of i)t.attract.load(e?.attract)}reset(){}}async function o(t,e=!0){await t.addInteractor("externalAttract",(e=>new n(t,e)),e)}})(),r})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Attract External Interaction v3.0.0-beta.
|
|
1
|
+
/*! tsParticles Attract External Interaction v3.0.0-beta.5 by Matteo Bruni */
|
package/umd/Attractor.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
exports.Attractor = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const Attract_js_1 = require("./Options/Classes/Attract.js");
|
|
15
|
+
const attractMode = "attract";
|
|
15
16
|
class Attractor extends engine_1.ExternalInteractorBase {
|
|
16
17
|
constructor(engine, container) {
|
|
17
18
|
super(container);
|
|
@@ -69,7 +70,7 @@
|
|
|
69
70
|
}
|
|
70
71
|
this.handleClickMode = (mode) => {
|
|
71
72
|
const options = this.container.actualOptions, attract = options.interactivity.modes.attract;
|
|
72
|
-
if (!attract || mode !==
|
|
73
|
+
if (!attract || mode !== attractMode) {
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
75
76
|
if (!container.attract) {
|
|
@@ -107,10 +108,10 @@
|
|
|
107
108
|
}
|
|
108
109
|
async interact() {
|
|
109
110
|
const container = this.container, options = container.actualOptions, mouseMoveStatus = container.interactivity.status === engine_1.mouseMoveEvent, events = options.interactivity.events, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, clickEnabled = events.onClick.enable, clickMode = events.onClick.mode;
|
|
110
|
-
if (mouseMoveStatus && hoverEnabled && (0, engine_1.isInArray)(
|
|
111
|
+
if (mouseMoveStatus && hoverEnabled && (0, engine_1.isInArray)(attractMode, hoverMode)) {
|
|
111
112
|
this._hoverAttract();
|
|
112
113
|
}
|
|
113
|
-
else if (clickEnabled && (0, engine_1.isInArray)(
|
|
114
|
+
else if (clickEnabled && (0, engine_1.isInArray)(attractMode, clickMode)) {
|
|
114
115
|
this._clickAttract();
|
|
115
116
|
}
|
|
116
117
|
}
|
|
@@ -120,7 +121,7 @@
|
|
|
120
121
|
return false;
|
|
121
122
|
}
|
|
122
123
|
const hoverMode = events.onHover.mode, clickMode = events.onClick.mode;
|
|
123
|
-
return (0, engine_1.isInArray)(
|
|
124
|
+
return (0, engine_1.isInArray)(attractMode, hoverMode) || (0, engine_1.isInArray)(attractMode, clickMode);
|
|
124
125
|
}
|
|
125
126
|
loadModeOptions(options, ...sources) {
|
|
126
127
|
if (!options.attract) {
|