@tsparticles/interaction-external-bounce 3.0.0-beta.3 → 3.0.0-beta.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.3
7
+ * v3.0.0-beta.4
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -114,6 +114,7 @@ class Bounce {
114
114
  ;// CONCATENATED MODULE: ./dist/browser/Bouncer.js
115
115
 
116
116
 
117
+ const bounceMode = "bounce";
117
118
  class Bouncer extends engine_root_window_.ExternalInteractorBase {
118
119
  constructor(container) {
119
120
  super(container);
@@ -181,10 +182,10 @@ class Bouncer extends engine_root_window_.ExternalInteractorBase {
181
182
  hoverEnabled = events.onHover.enable,
182
183
  hoverMode = events.onHover.mode,
183
184
  divs = events.onDiv;
184
- if (mouseMoveStatus && hoverEnabled && (0,engine_root_window_.isInArray)("bounce", hoverMode)) {
185
+ if (mouseMoveStatus && hoverEnabled && (0,engine_root_window_.isInArray)(bounceMode, hoverMode)) {
185
186
  this._processMouseBounce();
186
187
  } else {
187
- (0,engine_root_window_.divModeExecute)("bounce", divs, (selector, div) => this._singleSelectorBounce(selector, div));
188
+ (0,engine_root_window_.divModeExecute)(bounceMode, divs, (selector, div) => this._singleSelectorBounce(selector, div));
188
189
  }
189
190
  }
190
191
  isEnabled(particle) {
@@ -193,7 +194,7 @@ class Bouncer extends engine_root_window_.ExternalInteractorBase {
193
194
  mouse = container.interactivity.mouse,
194
195
  events = (particle?.interactivity ?? options.interactivity).events,
195
196
  divs = events.onDiv;
196
- return mouse.position && events.onHover.enable && (0,engine_root_window_.isInArray)("bounce", events.onHover.mode) || (0,engine_root_window_.isDivModeEnabled)("bounce", divs);
197
+ return mouse.position && events.onHover.enable && (0,engine_root_window_.isInArray)(bounceMode, events.onHover.mode) || (0,engine_root_window_.isDivModeEnabled)(bounceMode, divs);
197
198
  }
198
199
  loadModeOptions(options, ...sources) {
199
200
  if (!options.bounce) {
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.interaction.external.bounce.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function n(e){var i=o[e];if(void 0!==i)return i.exports;var r=o[e]={exports:{}};return t[e](r,r.exports,n),r.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{n.r(i),n.d(i,{Bounce:()=>t,loadExternalBounceInteraction:()=>r});var e=n(533);class t{constructor(){this.distance=200}load(e){e&&void 0!==e.distance&&(this.distance=e.distance)}}class o extends e.ExternalInteractorBase{constructor(t){super(t),this._processBounce=(t,o,n)=>{const i=this.container.particles.quadTree.query(n,(e=>this.isEnabled(e)));for(const r of i)n instanceof e.Circle?(0,e.circleBounce)((0,e.circleBounceDataFromParticle)(r),{position:t,radius:o,mass:o**2*Math.PI/2,velocity:e.Vector.origin,factor:e.Vector.origin}):n instanceof e.Rectangle&&(0,e.rectBounce)(r,(0,e.calculateBounds)(t,o))},this._processMouseBounce=()=>{const t=this.container,o=10*t.retina.pixelRatio,n=t.interactivity.mouse.position,i=t.retina.bounceModeDistance;!i||i<0||!n||this._processBounce(n,i,new e.Circle(n.x,n.y,i+o))},this._singleSelectorBounce=(t,o)=>{const n=this.container,i=document.querySelectorAll(t);i.length&&i.forEach((t=>{const i=t,r=n.retina.pixelRatio,c={x:(i.offsetLeft+i.offsetWidth/2)*r,y:(i.offsetTop+i.offsetHeight/2)*r},s=i.offsetWidth/2*r,a=10*r,u="circle"===o.type?new e.Circle(c.x,c.y,s+a):new e.Rectangle(i.offsetLeft*r-a,i.offsetTop*r-a,i.offsetWidth*r+2*a,i.offsetHeight*r+2*a);this._processBounce(c,s,u)}))}}clear(){}init(){const e=this.container,t=e.actualOptions.interactivity.modes.bounce;t&&(e.retina.bounceModeDistance=t.distance*e.retina.pixelRatio)}async interact(){const t=this.container,o=t.actualOptions.interactivity.events,n=t.interactivity.status===e.mouseMoveEvent,i=o.onHover.enable,r=o.onHover.mode,c=o.onDiv;n&&i&&(0,e.isInArray)("bounce",r)?this._processMouseBounce():(0,e.divModeExecute)("bounce",c,((e,t)=>this._singleSelectorBounce(e,t)))}isEnabled(t){const o=this.container,n=o.actualOptions,i=o.interactivity.mouse,r=(t?.interactivity??n.interactivity).events,c=r.onDiv;return i.position&&r.onHover.enable&&(0,e.isInArray)("bounce",r.onHover.mode)||(0,e.isDivModeEnabled)("bounce",c)}loadModeOptions(e,...o){e.bounce||(e.bounce=new t);for(const t of o)e.bounce.load(t?.bounce)}reset(){}}async function r(e,t=!0){await e.addInteractor("externalBounce",(e=>new o(e)),t)}})(),i})()));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function n(e){var i=o[e];if(void 0!==i)return i.exports;var r=o[e]={exports:{}};return t[e](r,r.exports,n),r.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{n.r(i),n.d(i,{Bounce:()=>t,loadExternalBounceInteraction:()=>s});var e=n(533);class t{constructor(){this.distance=200}load(e){e&&void 0!==e.distance&&(this.distance=e.distance)}}const o="bounce";class r extends e.ExternalInteractorBase{constructor(t){super(t),this._processBounce=(t,o,n)=>{const i=this.container.particles.quadTree.query(n,(e=>this.isEnabled(e)));for(const r of i)n instanceof e.Circle?(0,e.circleBounce)((0,e.circleBounceDataFromParticle)(r),{position:t,radius:o,mass:o**2*Math.PI/2,velocity:e.Vector.origin,factor:e.Vector.origin}):n instanceof e.Rectangle&&(0,e.rectBounce)(r,(0,e.calculateBounds)(t,o))},this._processMouseBounce=()=>{const t=this.container,o=10*t.retina.pixelRatio,n=t.interactivity.mouse.position,i=t.retina.bounceModeDistance;!i||i<0||!n||this._processBounce(n,i,new e.Circle(n.x,n.y,i+o))},this._singleSelectorBounce=(t,o)=>{const n=this.container,i=document.querySelectorAll(t);i.length&&i.forEach((t=>{const i=t,r=n.retina.pixelRatio,s={x:(i.offsetLeft+i.offsetWidth/2)*r,y:(i.offsetTop+i.offsetHeight/2)*r},c=i.offsetWidth/2*r,a=10*r,u="circle"===o.type?new e.Circle(s.x,s.y,c+a):new e.Rectangle(i.offsetLeft*r-a,i.offsetTop*r-a,i.offsetWidth*r+2*a,i.offsetHeight*r+2*a);this._processBounce(s,c,u)}))}}clear(){}init(){const e=this.container,t=e.actualOptions.interactivity.modes.bounce;t&&(e.retina.bounceModeDistance=t.distance*e.retina.pixelRatio)}async interact(){const t=this.container,n=t.actualOptions.interactivity.events,i=t.interactivity.status===e.mouseMoveEvent,r=n.onHover.enable,s=n.onHover.mode,c=n.onDiv;i&&r&&(0,e.isInArray)(o,s)?this._processMouseBounce():(0,e.divModeExecute)(o,c,((e,t)=>this._singleSelectorBounce(e,t)))}isEnabled(t){const n=this.container,i=n.actualOptions,r=n.interactivity.mouse,s=(t?.interactivity??i.interactivity).events,c=s.onDiv;return r.position&&s.onHover.enable&&(0,e.isInArray)(o,s.onHover.mode)||(0,e.isDivModeEnabled)(o,c)}loadModeOptions(e,...o){e.bounce||(e.bounce=new t);for(const t of o)e.bounce.load(t?.bounce)}reset(){}}async function s(e,t=!0){await e.addInteractor("externalBounce",(e=>new r(e)),t)}})(),i})()));
@@ -1 +1 @@
1
- /*! tsParticles Bounce External Interaction v3.0.0-beta.3 by Matteo Bruni */
1
+ /*! tsParticles Bounce External Interaction v3.0.0-beta.4 by Matteo Bruni */
package/umd/Bouncer.js CHANGED
@@ -12,6 +12,7 @@
12
12
  exports.Bouncer = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  const Bounce_js_1 = require("./Options/Classes/Bounce.js");
15
+ const bounceMode = "bounce";
15
16
  class Bouncer extends engine_1.ExternalInteractorBase {
16
17
  constructor(container) {
17
18
  super(container);
@@ -66,17 +67,17 @@
66
67
  }
67
68
  async interact() {
68
69
  const container = this.container, options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === engine_1.mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
69
- if (mouseMoveStatus && hoverEnabled && (0, engine_1.isInArray)("bounce", hoverMode)) {
70
+ if (mouseMoveStatus && hoverEnabled && (0, engine_1.isInArray)(bounceMode, hoverMode)) {
70
71
  this._processMouseBounce();
71
72
  }
72
73
  else {
73
- (0, engine_1.divModeExecute)("bounce", divs, (selector, div) => this._singleSelectorBounce(selector, div));
74
+ (0, engine_1.divModeExecute)(bounceMode, divs, (selector, div) => this._singleSelectorBounce(selector, div));
74
75
  }
75
76
  }
76
77
  isEnabled(particle) {
77
78
  const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? options.interactivity).events, divs = events.onDiv;
78
- return ((mouse.position && events.onHover.enable && (0, engine_1.isInArray)("bounce", events.onHover.mode)) ||
79
- (0, engine_1.isDivModeEnabled)("bounce", divs));
79
+ return ((mouse.position && events.onHover.enable && (0, engine_1.isInArray)(bounceMode, events.onHover.mode)) ||
80
+ (0, engine_1.isDivModeEnabled)(bounceMode, divs));
80
81
  }
81
82
  loadModeOptions(options, ...sources) {
82
83
  if (!options.bounce) {