@tsparticles/interaction-external-bounce
Advanced tools
Comparing version 3.0.0-beta.3 to 3.0.0-beta.4
import { Circle, ExternalInteractorBase, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, divModeExecute, isDivModeEnabled, isInArray, mouseMoveEvent, rectBounce, } from "@tsparticles/engine"; | ||
import { Bounce } from "./Options/Classes/Bounce.js"; | ||
const bounceMode = "bounce"; | ||
export class Bouncer extends ExternalInteractorBase { | ||
@@ -57,7 +58,7 @@ constructor(container) { | ||
const container = this.container, options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv; | ||
if (mouseMoveStatus && hoverEnabled && isInArray("bounce", hoverMode)) { | ||
if (mouseMoveStatus && hoverEnabled && isInArray(bounceMode, hoverMode)) { | ||
this._processMouseBounce(); | ||
} | ||
else { | ||
divModeExecute("bounce", divs, (selector, div) => this._singleSelectorBounce(selector, div)); | ||
divModeExecute(bounceMode, divs, (selector, div) => this._singleSelectorBounce(selector, div)); | ||
} | ||
@@ -67,4 +68,4 @@ } | ||
const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? options.interactivity).events, divs = events.onDiv; | ||
return ((mouse.position && events.onHover.enable && isInArray("bounce", events.onHover.mode)) || | ||
isDivModeEnabled("bounce", divs)); | ||
return ((mouse.position && events.onHover.enable && isInArray(bounceMode, events.onHover.mode)) || | ||
isDivModeEnabled(bounceMode, divs)); | ||
} | ||
@@ -71,0 +72,0 @@ loadModeOptions(options, ...sources) { |
@@ -6,2 +6,3 @@ "use strict"; | ||
const Bounce_js_1 = require("./Options/Classes/Bounce.js"); | ||
const bounceMode = "bounce"; | ||
class Bouncer extends engine_1.ExternalInteractorBase { | ||
@@ -61,7 +62,7 @@ constructor(container) { | ||
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; | ||
if (mouseMoveStatus && hoverEnabled && (0, engine_1.isInArray)("bounce", hoverMode)) { | ||
if (mouseMoveStatus && hoverEnabled && (0, engine_1.isInArray)(bounceMode, hoverMode)) { | ||
this._processMouseBounce(); | ||
} | ||
else { | ||
(0, engine_1.divModeExecute)("bounce", divs, (selector, div) => this._singleSelectorBounce(selector, div)); | ||
(0, engine_1.divModeExecute)(bounceMode, divs, (selector, div) => this._singleSelectorBounce(selector, div)); | ||
} | ||
@@ -71,4 +72,4 @@ } | ||
const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? options.interactivity).events, divs = events.onDiv; | ||
return ((mouse.position && events.onHover.enable && (0, engine_1.isInArray)("bounce", events.onHover.mode)) || | ||
(0, engine_1.isDivModeEnabled)("bounce", divs)); | ||
return ((mouse.position && events.onHover.enable && (0, engine_1.isInArray)(bounceMode, events.onHover.mode)) || | ||
(0, engine_1.isDivModeEnabled)(bounceMode, divs)); | ||
} | ||
@@ -75,0 +76,0 @@ loadModeOptions(options, ...sources) { |
import { Circle, ExternalInteractorBase, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, divModeExecute, isDivModeEnabled, isInArray, mouseMoveEvent, rectBounce, } from "@tsparticles/engine"; | ||
import { Bounce } from "./Options/Classes/Bounce.js"; | ||
const bounceMode = "bounce"; | ||
export class Bouncer extends ExternalInteractorBase { | ||
@@ -57,7 +58,7 @@ constructor(container) { | ||
const container = this.container, options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv; | ||
if (mouseMoveStatus && hoverEnabled && isInArray("bounce", hoverMode)) { | ||
if (mouseMoveStatus && hoverEnabled && isInArray(bounceMode, hoverMode)) { | ||
this._processMouseBounce(); | ||
} | ||
else { | ||
divModeExecute("bounce", divs, (selector, div) => this._singleSelectorBounce(selector, div)); | ||
divModeExecute(bounceMode, divs, (selector, div) => this._singleSelectorBounce(selector, div)); | ||
} | ||
@@ -67,4 +68,4 @@ } | ||
const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? options.interactivity).events, divs = events.onDiv; | ||
return ((mouse.position && events.onHover.enable && isInArray("bounce", events.onHover.mode)) || | ||
isDivModeEnabled("bounce", divs)); | ||
return ((mouse.position && events.onHover.enable && isInArray(bounceMode, events.onHover.mode)) || | ||
isDivModeEnabled(bounceMode, divs)); | ||
} | ||
@@ -71,0 +72,0 @@ loadModeOptions(options, ...sources) { |
{ | ||
"name": "@tsparticles/interaction-external-bounce", | ||
"version": "3.0.0-beta.3", | ||
"version": "3.0.0-beta.4", | ||
"description": "tsParticles bounce external interaction", | ||
@@ -63,3 +63,3 @@ "homepage": "https://particles.js.org", | ||
"canvas-confetti", | ||
"@tsparticles/plugin", | ||
"tsparticles-plugin", | ||
"@tsparticles/interaction" | ||
@@ -91,3 +91,3 @@ ], | ||
"dependencies": { | ||
"@tsparticles/engine": "^3.0.0-beta.3" | ||
"@tsparticles/engine": "^3.0.0-beta.4" | ||
}, | ||
@@ -94,0 +94,0 @@ "publishConfig": { |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v3.0.0-beta.3 | ||
* v3.0.0-beta.4 | ||
*/ | ||
@@ -118,2 +118,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
const bounceMode = "bounce"; | ||
class Bouncer extends engine_root_window_.ExternalInteractorBase { | ||
@@ -186,6 +187,6 @@ constructor(container) { | ||
divs = events.onDiv; | ||
if (mouseMoveStatus && hoverEnabled && (0,engine_root_window_.isInArray)("bounce", hoverMode)) { | ||
if (mouseMoveStatus && hoverEnabled && (0,engine_root_window_.isInArray)(bounceMode, hoverMode)) { | ||
this._processMouseBounce(); | ||
} else { | ||
(0,engine_root_window_.divModeExecute)("bounce", divs, (selector, div) => this._singleSelectorBounce(selector, div)); | ||
(0,engine_root_window_.divModeExecute)(bounceMode, divs, (selector, div) => this._singleSelectorBounce(selector, div)); | ||
} | ||
@@ -199,3 +200,3 @@ } | ||
divs = events.onDiv; | ||
return mouse.position && events.onHover.enable && (0,engine_root_window_.isInArray)("bounce", events.onHover.mode) || (0,engine_root_window_.isDivModeEnabled)("bounce", divs); | ||
return mouse.position && events.onHover.enable && (0,engine_root_window_.isInArray)(bounceMode, events.onHover.mode) || (0,engine_root_window_.isDivModeEnabled)(bounceMode, divs); | ||
} | ||
@@ -202,0 +203,0 @@ loadModeOptions(options, ...sources) { |
/*! For license information please see tsparticles.interaction.external.bounce.min.js.LICENSE.txt */ | ||
!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})())); | ||
!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 +0,1 @@ | ||
/*! tsParticles Bounce External Interaction v3.0.0-beta.3 by Matteo Bruni */ | ||
/*! tsParticles Bounce External Interaction v3.0.0-beta.4 by Matteo Bruni */ |
@@ -15,2 +15,3 @@ (function (factory) { | ||
const Bounce_js_1 = require("./Options/Classes/Bounce.js"); | ||
const bounceMode = "bounce"; | ||
class Bouncer extends engine_1.ExternalInteractorBase { | ||
@@ -70,7 +71,7 @@ constructor(container) { | ||
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; | ||
if (mouseMoveStatus && hoverEnabled && (0, engine_1.isInArray)("bounce", hoverMode)) { | ||
if (mouseMoveStatus && hoverEnabled && (0, engine_1.isInArray)(bounceMode, hoverMode)) { | ||
this._processMouseBounce(); | ||
} | ||
else { | ||
(0, engine_1.divModeExecute)("bounce", divs, (selector, div) => this._singleSelectorBounce(selector, div)); | ||
(0, engine_1.divModeExecute)(bounceMode, divs, (selector, div) => this._singleSelectorBounce(selector, div)); | ||
} | ||
@@ -80,4 +81,4 @@ } | ||
const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? options.interactivity).events, divs = events.onDiv; | ||
return ((mouse.position && events.onHover.enable && (0, engine_1.isInArray)("bounce", events.onHover.mode)) || | ||
(0, engine_1.isDivModeEnabled)("bounce", divs)); | ||
return ((mouse.position && events.onHover.enable && (0, engine_1.isInArray)(bounceMode, events.onHover.mode)) || | ||
(0, engine_1.isDivModeEnabled)(bounceMode, divs)); | ||
} | ||
@@ -84,0 +85,0 @@ loadModeOptions(options, ...sources) { |
Sorry, the diff of this file is not supported yet
787
320079