@tsparticles/interaction-external-repulse 4.0.0-beta.12 → 4.0.0-beta.15

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.
@@ -1,2 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"),require("@tsparticles/plugin-interactivity"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine","@tsparticles/plugin-interactivity"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine"),require("@tsparticles/plugin-interactivity")):t(e.window,e.window);for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(this,(e,t)=>(()=>{"use strict";var r,i,o,n={303(t){t.exports=e},702(e){e.exports=t},162(e,t,r){r.d(t,{Z:()=>a});var i=r(303),o=r(123),n=r(51);class a extends o._{divs;load(e){super.load(e),(0,i.isNull)(e)||(this.divs=(0,i.executeOnSingleOrMultiple)(e.divs,e=>{let t=new n.W;return t.load(e),t}))}}},123(e,t,r){r.d(t,{_:()=>o});var i=r(303);class o{distance;duration;easing;factor;maxSpeed;speed;constructor(){this.distance=200,this.duration=.4,this.factor=100,this.speed=1,this.maxSpeed=50,this.easing=i.EasingType.easeOutQuad}load(e){(0,i.isNull)(e)||(void 0!==e.distance&&(this.distance=e.distance),void 0!==e.duration&&(this.duration=e.duration),void 0!==e.easing&&(this.easing=e.easing),void 0!==e.factor&&(this.factor=e.factor),void 0!==e.speed&&(this.speed=e.speed),void 0!==e.maxSpeed&&(this.maxSpeed=e.maxSpeed))}}},51(e,t,r){r.d(t,{W:()=>n});var i=r(303),o=r(123);class n extends o._{selectors;constructor(){super(),this.selectors=[]}load(e){super.load(e),(0,i.isNull)(e)||void 0!==e.selectors&&(this.selectors=e.selectors)}}}},a={};function s(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return n[e](r,r.exports,s),r.exports}s.m=n,c=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var r=Object.create(null);s.r(r);var i={};l=l||[null,c({}),c([]),c(c)];for(var o=2&t&&e;("object"==typeof o||"function"==typeof o)&&!~l.indexOf(o);o=c(o))Object.getOwnPropertyNames(o).forEach(t=>i[t]=()=>e[t]);return i.default=()=>e,s.d(r,i),r},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce((t,r)=>(s.f[r](e,t),t),[])),s.u=e=>""+e+".min.js",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),p={},s.l=(e,t,r,i)=>{if(p[e])return void p[e].push(t);if(void 0!==r)for(var o,n,a=document.getElementsByTagName("script"),l=0;l<a.length;l++){var c=a[l];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")=="@tsparticles/interaction-external-repulse:"+r){o=c;break}}o||(n=!0,(o=document.createElement("script")).charset="utf-8",s.nc&&o.setAttribute("nonce",s.nc),o.setAttribute("data-webpack","@tsparticles/interaction-external-repulse:"+r),o.src=e),p[e]=[t];var u=(t,r)=>{o.onerror=o.onload=null,clearTimeout(d);var i=p[e];if(delete p[e],o.parentNode&&o.parentNode.removeChild(o),i&&i.forEach(e=>e(r)),t)return t(r)},d=setTimeout(u.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=u.bind(null,o.onerror),o.onload=u.bind(null,o.onload),n&&document.head.appendChild(o)},s.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(u=s.g.location+"");var l,c,p,u,d=s.g.document;if(!u&&d&&(d.currentScript&&"SCRIPT"===d.currentScript.tagName.toUpperCase()&&(u=d.currentScript.src),!u)){var f=d.getElementsByTagName("script");if(f.length)for(var h=f.length-1;h>-1&&(!u||!/^http(s?):/.test(u));)u=f[h--].src}if(!u)throw Error("Automatic publicPath is not supported in this browser");s.p=u=u.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r={64:0},s.f.j=(e,t)=>{var i=s.o(r,e)?r[e]:void 0;if(0!==i)if(i)t.push(i[2]);else{var o=new Promise((t,o)=>i=r[e]=[t,o]);t.push(i[2]=o);var n=s.p+s.u(e),a=Error();s.l(n,t=>{if(s.o(r,e)&&(0!==(i=r[e])&&(r[e]=void 0),i)){var o=t&&("load"===t.type?"missing":t.type),n=t&&t.target&&t.target.src;a.message="Loading chunk "+e+` failed.
2
- (`+o+": "+n+")",a.name="ChunkLoadError",a.type=o,a.request=n,i[1](a)}},"chunk-"+e,e)}},i=(e,t)=>{var i,o,[n,a,l]=t,c=0;if(n.some(e=>0!==r[e])){for(i in a)s.o(a,i)&&(s.m[i]=a[i]);l&&l(s)}for(e&&e(t);c<n.length;c++)o=n[c],s.o(r,o)&&r[o]&&r[o][0](),r[o]=0},(o=this.webpackChunk_tsparticles_interaction_external_repulse=this.webpackChunk_tsparticles_interaction_external_repulse||[]).forEach(i.bind(null,0)),o.push=i.bind(null,o.push.bind(o));var v={};s.r(v),s.d(v,{Repulse:()=>m.Z,RepulseBase:()=>g._,RepulseDiv:()=>b.W,loadExternalRepulseInteraction:()=>y});var g=s(123),b=s(51),m=s(162);async function y(e){e.checkVersion("4.0.0-beta.12"),await e.pluginManager.register(async e=>{let{ensureInteractivityPluginLoaded:t}=await Promise.resolve().then(s.t.bind(s,702,19));t(e);let r=e.pluginManager;r.addInteractor?.("externalRepulse",async e=>{let{Repulser:t}=await s.e(580).then(s.bind(s,580));return new t(r,e)})})}return v})());
1
+ !function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var e="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,e){return e in t||(t[e]={}),t[e]}})}:function(t){return t};t.__tsParticlesInternals.bundles=e(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=e(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=e(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=e(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=e(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=e(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=e(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=e(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=e(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=e(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=e(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=e(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=e(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/plugin-interactivity","@tsparticles/engine"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.interactions.externalRepulse=t.__tsParticlesInternals.interactions.externalRepulse||{}),t.__tsParticlesInternals.plugins.interactivity,t.__tsParticlesInternals.engine)}(this,function(t,e,s){"use strict";class n{distance;duration;easing;factor;maxSpeed;speed;constructor(){this.distance=200,this.duration=.4,this.factor=100,this.speed=1,this.maxSpeed=50,this.easing=s.EasingType.easeOutQuad}load(t){s.isNull(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.speed&&(this.speed=t.speed),void 0!==t.maxSpeed&&(this.maxSpeed=t.maxSpeed))}}class i extends n{selectors;constructor(){super(),this.selectors=[]}load(t){super.load(t),s.isNull(t)||void 0!==t.selectors&&(this.selectors=t.selectors)}}class a extends n{divs;load(t){super.load(t),s.isNull(t)||(this.divs=s.executeOnSingleOrMultiple(t.divs,t=>{const e=new i;return e.load(t),e}))}}const r="repulse";class l extends e.ExternalInteractorBase{handleClickMode;_clickVec;_maxDistance;_normVec;_pluginManager;constructor(t,e){super(e),this._pluginManager=t,this._maxDistance=0,this._normVec=s.Vector.origin,this._clickVec=s.Vector.origin,e.repulse??={particles:[]},this.handleClickMode=(t,n)=>{const i=this.container.actualOptions,a=i.interactivity?.modes.repulse;if(!a||t!==r)return;e.repulse??={particles:[]};const l=e.repulse;l.clicking=!0,l.count=0;for(const t of e.repulse.particles)this.isEnabled(n,t)&&t.velocity.setTo(t.initialVelocity);l.particles=[],l.finish=!1,setTimeout(()=>{e.destroyed||(l.clicking=!1)},a.duration*s.millisecondsToSeconds)}}get maxDistance(){return this._maxDistance}clear(){}init(){const t=this.container,e=t.actualOptions.interactivity?.modes.repulse;e&&(this._maxDistance=e.distance,t.retina.repulseModeDistance=e.distance*t.retina.pixelRatio)}interact(t){const n=this.container.actualOptions,i=t.status===e.mouseMoveEvent,a=n.interactivity?.events;if(!a)return;const l=a.onHover,c=l.enable,o=l.mode,_=a.onClick,p=_.enable,u=_.mode,d=a.onDiv;i&&c&&s.isInArray(r,o)?this._hoverRepulse(t):p&&s.isInArray(r,u)?this._clickRepulse(t):e.divModeExecute(r,d,(e,s)=>{this._singleSelectorRepulse(t,e,s)})}isEnabled(t,n){const i=this.container.actualOptions,a=t.mouse,l=(n?.interactivity??i.interactivity)?.events;if(!l)return!1;const c=l.onDiv,o=l.onHover,_=l.onClick,p=e.isDivModeEnabled(r,c);if(!(p||o.enable&&a.position||_.enable&&a.clickPosition))return!1;const u=o.mode,d=_.mode;return s.isInArray(r,u)||s.isInArray(r,d)||p}loadModeOptions(t,...e){t.repulse??=new a;for(const s of e)t.repulse.load(s?.repulse)}reset(){}_clickRepulse=t=>{const e=this.container,n=e.actualOptions.interactivity?.modes.repulse;if(!n)return;const i=e.repulse??{particles:[]};if(i.finish||(i.count??=0,i.count++,i.count===e.particles.count&&(i.finish=!0)),i.clicking){const a=e.retina.repulseModeDistance;if(!a||a<0)return;const r=Math.pow(a/6,3),l=t.mouse.clickPosition;if(void 0===l)return;const c=new s.Circle(l.x,l.y,r),o=e.particles.grid.query(c,e=>this.isEnabled(t,e));for(const t of o){const{dx:e,dy:a,distance:c}=s.getDistances(l,t.position),o=c**2,_=-r*n.speed/o;o<=r&&(i.particles.push(t),this._clickVec.x=e,this._clickVec.y=a,this._clickVec.length=_,t.velocity.setTo(this._clickVec))}}else if(!1===i.clicking){for(const t of i.particles)t.velocity.setTo(t.initialVelocity);i.particles=[]}};_hoverRepulse=t=>{const e=this.container,n=t.mouse.position,i=e.retina.repulseModeDistance;!i||i<0||!n||this._processRepulse(t,n,i,new s.Circle(n.x,n.y,i))};_processRepulse=(t,e,n,i,a)=>{const r=this.container,l=r.particles.grid.query(i,e=>this.isEnabled(t,e)),c=r.actualOptions.interactivity?.modes.repulse;if(!c)return;const{easing:o,speed:_,factor:p,maxSpeed:u}=c,d=this._pluginManager.getEasing(o),h=(a?.speed??_)*p;for(const t of l){const{dx:i,dy:a,distance:r}=s.getDistances(t.position,e),l=s.clamp(d(1-r/n)*h,0,u);this._normVec.x=r?i/r*l:h,this._normVec.y=r?a/r*l:h,t.position.addTo(this._normVec)}};_singleSelectorRepulse=(t,n,i)=>{const a=this.container,r=a.actualOptions.interactivity?.modes.repulse;if(!r)return;const l=s.safeDocument().querySelectorAll(n);l.length&&l.forEach(n=>{const l=n,c=a.retina.pixelRatio,o={x:(l.offsetLeft+l.offsetWidth*s.half)*c,y:(l.offsetTop+l.offsetHeight*s.half)*c},_=l.offsetWidth*s.half*c,p=i.type===e.DivType.circle?new s.Circle(o.x,o.y,_):new s.Rectangle(l.offsetLeft*c,l.offsetTop*c,l.offsetWidth*c,l.offsetHeight*c),u=r.divs,d=e.divMode(u,l);this._processRepulse(t,o,_,p,d)})}}async function c(t){t.checkVersion("4.0.0-beta.15"),await t.pluginManager.register(t=>{e.ensureInteractivityPluginLoaded(t);const s=t.pluginManager;s.addInteractor?.("externalRepulse",t=>Promise.resolve(new l(s,t)))})}const o=globalThis;o.__tsParticlesInternals=o.__tsParticlesInternals??{},o.loadExternalRepulseInteraction=c,t.Repulse=a,t.RepulseBase=n,t.RepulseDiv=i,t.loadExternalRepulseInteraction=c}),Object.assign(globalThis.window||globalThis,{loadExternalRepulseInteraction:(globalThis.__tsParticlesInternals.interactions.externalRepulse||{}).loadExternalRepulseInteraction}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
@@ -0,0 +1 @@
1
+ export * from "./index.js";
@@ -0,0 +1,8 @@
1
+ import { type Engine } from "@tsparticles/engine/lazy";
2
+ export declare function loadExternalRepulseInteraction(engine: Engine): Promise<void>;
3
+ export * from "./Options/Classes/RepulseBase.js";
4
+ export * from "./Options/Classes/RepulseDiv.js";
5
+ export * from "./Options/Classes/Repulse.js";
6
+ export type * from "./Options/Interfaces/IRepulseBase.js";
7
+ export type * from "./Options/Interfaces/IRepulseDiv.js";
8
+ export type * from "./Options/Interfaces/IRepulse.js";
package/580.min.js DELETED
@@ -1 +0,0 @@
1
- "use strict";(this.webpackChunk_tsparticles_interaction_external_repulse=this.webpackChunk_tsparticles_interaction_external_repulse||[]).push([[580],{580(e,t,i){i.d(t,{Repulser:()=>c});var s=i(303),n=i(702),l=i(162);let r="repulse";class c extends n.ExternalInteractorBase{handleClickMode;_clickVec;_maxDistance;_normVec;_pluginManager;constructor(e,t){super(t),this._pluginManager=e,this._maxDistance=0,this._normVec=s.Vector.origin,this._clickVec=s.Vector.origin,t.repulse??={particles:[]},this.handleClickMode=(e,i)=>{let n=this.container.actualOptions,l=n.interactivity?.modes.repulse;if(!l||e!==r)return;t.repulse??={particles:[]};let c=t.repulse;for(let e of(c.clicking=!0,c.count=0,t.repulse.particles))this.isEnabled(i,e)&&e.velocity.setTo(e.initialVelocity);c.particles=[],c.finish=!1,setTimeout(()=>{t.destroyed||(c.clicking=!1)},l.duration*s.millisecondsToSeconds)}}get maxDistance(){return this._maxDistance}clear(){}init(){let e=this.container,t=e.actualOptions.interactivity?.modes.repulse;t&&(this._maxDistance=t.distance,e.retina.repulseModeDistance=t.distance*e.retina.pixelRatio)}interact(e){let t=this.container.actualOptions,i=e.status===n.mouseMoveEvent,l=t.interactivity?.events;if(!l)return;let c=l.onHover,o=c.enable,a=c.mode,p=l.onClick,u=p.enable,h=p.mode,d=l.onDiv;i&&o&&(0,s.isInArray)(r,a)?this._hoverRepulse(e):u&&(0,s.isInArray)(r,h)?this._clickRepulse(e):(0,n.divModeExecute)(r,d,(t,i)=>{this._singleSelectorRepulse(e,t,i)})}isEnabled(e,t){let i=this.container.actualOptions,l=e.mouse,c=(t?.interactivity??i.interactivity)?.events;if(!c)return!1;let o=c.onDiv,a=c.onHover,p=c.onClick,u=(0,n.isDivModeEnabled)(r,o);if(!(u||a.enable&&l.position||p.enable&&l.clickPosition))return!1;let h=a.mode,d=p.mode;return(0,s.isInArray)(r,h)||(0,s.isInArray)(r,d)||u}loadModeOptions(e,...t){for(let i of(e.repulse??=new l.Z,t))e.repulse.load(i?.repulse)}reset(){}_clickRepulse=e=>{let t=this.container,i=t.actualOptions.interactivity?.modes.repulse;if(!i)return;let n=t.repulse??{particles:[]};if(n.finish||(n.count??=0,n.count++,n.count===t.particles.count&&(n.finish=!0)),n.clicking){let l=t.retina.repulseModeDistance;if(!l||l<0)return;let r=Math.pow(l/6,3),c=e.mouse.clickPosition;if(void 0===c)return;let o=new s.Circle(c.x,c.y,r);for(let l of t.particles.grid.query(o,t=>this.isEnabled(e,t))){let{dx:e,dy:t,distance:o}=(0,s.getDistances)(c,l.position),a=o**2,p=-r*i.speed/a;a<=r&&(n.particles.push(l),this._clickVec.x=e,this._clickVec.y=t,this._clickVec.length=p,l.velocity.setTo(this._clickVec))}}else if(!1===n.clicking){for(let e of n.particles)e.velocity.setTo(e.initialVelocity);n.particles=[]}};_hoverRepulse=e=>{let t=this.container,i=e.mouse.position,n=t.retina.repulseModeDistance;n&&!(n<0)&&i&&this._processRepulse(e,i,n,new s.Circle(i.x,i.y,n))};_processRepulse=(e,t,i,n,l)=>{let r=this.container,c=r.particles.grid.query(n,t=>this.isEnabled(e,t)),o=r.actualOptions.interactivity?.modes.repulse;if(!o)return;let{easing:a,speed:p,factor:u,maxSpeed:h}=o,d=this._pluginManager.getEasing(a),f=(l?.speed??p)*u;for(let e of c){let{dx:n,dy:l,distance:r}=(0,s.getDistances)(e.position,t),c=(0,s.clamp)(d(1-r/i)*f,0,h);this._normVec.x=r?n/r*c:f,this._normVec.y=r?l/r*c:f,e.position.addTo(this._normVec)}};_singleSelectorRepulse=(e,t,i)=>{let l=this.container,r=l.actualOptions.interactivity?.modes.repulse;if(!r)return;let c=(0,s.safeDocument)().querySelectorAll(t);c.length&&c.forEach(t=>{let c=l.retina.pixelRatio,o={x:(t.offsetLeft+t.offsetWidth*s.half)*c,y:(t.offsetTop+t.offsetHeight*s.half)*c},a=t.offsetWidth*s.half*c,p=i.type===n.DivType.circle?new s.Circle(o.x,o.y,a):new s.Rectangle(t.offsetLeft*c,t.offsetTop*c,t.offsetWidth*c,t.offsetHeight*c),u=r.divs,h=(0,n.divMode)(u,t);this._processRepulse(e,o,a,p,h)})}}}}]);
@@ -1,30 +0,0 @@
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-beta.12
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_repulse"] = this["webpackChunk_tsparticles_interaction_external_repulse"] || []).push([["dist_browser_Repulser_js"],{
19
-
20
- /***/ "./dist/browser/Repulser.js"
21
- /*!**********************************!*\
22
- !*** ./dist/browser/Repulser.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 */ Repulser: () => (/* binding */ Repulser)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\");\n/* harmony import */ var _Options_Classes_Repulse_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Options/Classes/Repulse.js */ \"./dist/browser/Options/Classes/Repulse.js\");\n\n\n\nconst repulseMode = \"repulse\", minDistance = 0, repulseRadiusFactor = 6, repulseRadiusPower = 3, squarePower = 2, minRadius = 0, minSpeed = 0, easingOffset = 1;\nclass Repulser extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.ExternalInteractorBase {\n handleClickMode;\n _clickVec;\n _maxDistance;\n _normVec;\n _pluginManager;\n constructor(pluginManager, container){\n super(container);\n this._pluginManager = pluginManager;\n this._maxDistance = 0;\n this._normVec = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n this._clickVec = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n container.repulse ??= {\n particles: []\n };\n this.handleClickMode = (mode, interactivityData)=>{\n const options = this.container.actualOptions, repulseOpts = options.interactivity?.modes.repulse;\n if (!repulseOpts || mode !== repulseMode) {\n return;\n }\n container.repulse ??= {\n particles: []\n };\n const repulse = container.repulse;\n repulse.clicking = true;\n repulse.count = 0;\n for (const particle of container.repulse.particles){\n if (!this.isEnabled(interactivityData, particle)) {\n continue;\n }\n particle.velocity.setTo(particle.initialVelocity);\n }\n repulse.particles = [];\n repulse.finish = false;\n setTimeout(()=>{\n if (container.destroyed) {\n return;\n }\n repulse.clicking = false;\n }, repulseOpts.duration * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.millisecondsToSeconds);\n };\n }\n get maxDistance() {\n return this._maxDistance;\n }\n clear() {}\n init() {\n const container = this.container, repulse = container.actualOptions.interactivity?.modes.repulse;\n if (!repulse) {\n return;\n }\n this._maxDistance = repulse.distance;\n container.retina.repulseModeDistance = repulse.distance * container.retina.pixelRatio;\n }\n interact(interactivityData) {\n const container = this.container, options = container.actualOptions, mouseMoveStatus = interactivityData.status === _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.mouseMoveEvent, events = options.interactivity?.events;\n if (!events) {\n return;\n }\n const hover = events.onHover, hoverEnabled = hover.enable, hoverMode = hover.mode, click = events.onClick, clickEnabled = click.enable, clickMode = click.mode, divs = events.onDiv;\n if (mouseMoveStatus && hoverEnabled && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(repulseMode, hoverMode)) {\n this._hoverRepulse(interactivityData);\n } else if (clickEnabled && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(repulseMode, clickMode)) {\n this._clickRepulse(interactivityData);\n } else {\n (0,_tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.divModeExecute)(repulseMode, divs, (selector, div)=>{\n this._singleSelectorRepulse(interactivityData, selector, div);\n });\n }\n }\n isEnabled(interactivityData, particle) {\n const container = this.container, options = container.actualOptions, mouse = interactivityData.mouse, events = (particle?.interactivity ?? options.interactivity)?.events;\n if (!events) {\n return false;\n }\n const divs = events.onDiv, hover = events.onHover, click = events.onClick, divRepulse = (0,_tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.isDivModeEnabled)(repulseMode, divs);\n if (!(divRepulse || hover.enable && !!mouse.position || click.enable && mouse.clickPosition)) {\n return false;\n }\n const hoverMode = hover.mode, clickMode = click.mode;\n return (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(repulseMode, hoverMode) || (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(repulseMode, clickMode) || divRepulse;\n }\n loadModeOptions(options, ...sources) {\n options.repulse ??= new _Options_Classes_Repulse_js__WEBPACK_IMPORTED_MODULE_2__.Repulse();\n for (const source of sources){\n options.repulse.load(source?.repulse);\n }\n }\n reset() {}\n _clickRepulse = (interactivityData)=>{\n const container = this.container, repulseOptions = container.actualOptions.interactivity?.modes.repulse;\n if (!repulseOptions) {\n return;\n }\n const repulse = container.repulse ?? {\n particles: []\n };\n if (!repulse.finish) {\n repulse.count ??= 0;\n repulse.count++;\n if (repulse.count === container.particles.count) {\n repulse.finish = true;\n }\n }\n if (repulse.clicking) {\n const repulseDistance = container.retina.repulseModeDistance;\n if (!repulseDistance || repulseDistance < minDistance) {\n return;\n }\n const repulseRadius = Math.pow(repulseDistance / repulseRadiusFactor, repulseRadiusPower), mouseClickPos = interactivityData.mouse.clickPosition;\n if (mouseClickPos === undefined) {\n return;\n }\n const range = new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Circle(mouseClickPos.x, mouseClickPos.y, repulseRadius), query = container.particles.grid.query(range, (p)=>this.isEnabled(interactivityData, p));\n for (const particle of query){\n const { dx, dy, distance } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(mouseClickPos, particle.position), d = distance ** squarePower, velocity = repulseOptions.speed, force = -repulseRadius * velocity / d;\n if (d <= repulseRadius) {\n repulse.particles.push(particle);\n this._clickVec.x = dx;\n this._clickVec.y = dy;\n this._clickVec.length = force;\n particle.velocity.setTo(this._clickVec);\n }\n }\n } else if (repulse.clicking === false) {\n for (const particle of repulse.particles){\n particle.velocity.setTo(particle.initialVelocity);\n }\n repulse.particles = [];\n }\n };\n _hoverRepulse = (interactivityData)=>{\n const container = this.container, mousePos = interactivityData.mouse.position, repulseRadius = container.retina.repulseModeDistance;\n if (!repulseRadius || repulseRadius < minRadius || !mousePos) {\n return;\n }\n this._processRepulse(interactivityData, mousePos, repulseRadius, new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Circle(mousePos.x, mousePos.y, repulseRadius));\n };\n _processRepulse = (interactivityData, position, repulseRadius, area, divRepulse)=>{\n const container = this.container, query = container.particles.grid.query(area, (p)=>this.isEnabled(interactivityData, p)), repulseOptions = container.actualOptions.interactivity?.modes.repulse;\n if (!repulseOptions) {\n return;\n }\n const { easing, speed, factor, maxSpeed } = repulseOptions, easingFunc = this._pluginManager.getEasing(easing), velocity = (divRepulse?.speed ?? speed) * factor;\n for (const particle of query){\n const { dx, dy, distance } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, position), repulseFactor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)(easingFunc(easingOffset - distance / repulseRadius) * velocity, minSpeed, maxSpeed);\n this._normVec.x = !distance ? velocity : dx / distance * repulseFactor;\n this._normVec.y = !distance ? velocity : dy / distance * repulseFactor;\n particle.position.addTo(this._normVec);\n }\n };\n _singleSelectorRepulse = (interactivityData, selector, div)=>{\n const container = this.container, repulse = container.actualOptions.interactivity?.modes.repulse;\n if (!repulse) {\n return;\n }\n const query = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.safeDocument)().querySelectorAll(selector);\n if (!query.length) {\n return;\n }\n query.forEach((item)=>{\n const elem = item, pxRatio = container.retina.pixelRatio, pos = {\n x: (elem.offsetLeft + elem.offsetWidth * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half) * pxRatio,\n y: (elem.offsetTop + elem.offsetHeight * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half) * pxRatio\n }, repulseRadius = elem.offsetWidth * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half * pxRatio, area = div.type === _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.DivType.circle ? new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Circle(pos.x, pos.y, repulseRadius) : new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Rectangle(elem.offsetLeft * pxRatio, elem.offsetTop * pxRatio, elem.offsetWidth * pxRatio, elem.offsetHeight * pxRatio), divs = repulse.divs, divRepulse = (0,_tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.divMode)(divs, elem);\n this._processRepulse(interactivityData, pos, repulseRadius, area, divRepulse);\n });\n };\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-repulse/./dist/browser/Repulser.js?\n}");
27
-
28
- /***/ }
29
-
30
- }]);