Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tsparticles-interaction-external-bounce

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsparticles-interaction-external-bounce - npm Package Compare versions

Comparing version 2.2.4 to 2.3.0

27

browser/Bouncer.js

@@ -1,13 +0,1 @@

var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Bouncer_container;
import { Circle, ExternalInteractorBase, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, divModeExecute, isDivModeEnabled, isInArray, mouseMoveEvent, rectBounce, } from "tsparticles-engine";

@@ -18,4 +6,2 @@ import { Bounce } from "./Options/Classes/Bounce";

super(container);
_Bouncer_container.set(this, void 0);
__classPrivateFieldSet(this, _Bouncer_container, container, "f");
}

@@ -26,3 +12,3 @@ clear() {

init() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), bounce = container.actualOptions.interactivity.modes.bounce;
const container = this.container, bounce = container.actualOptions.interactivity.modes.bounce;
if (!bounce) {

@@ -34,3 +20,3 @@ return;

async interact() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
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.bounce */, hoverMode)) {

@@ -45,3 +31,3 @@ this.processMouseBounce();

var _a;
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), options = container.actualOptions, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events, divs = events.onDiv;
const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events, divs = events.onDiv;
return ((mouse.position && events.onHover.enable && isInArray("bounce" /* HoverMode.bounce */, events.onHover.mode)) ||

@@ -62,3 +48,3 @@ isDivModeEnabled("bounce" /* DivMode.bounce */, divs));

processBounce(position, radius, area) {
const query = __classPrivateFieldGet(this, _Bouncer_container, "f").particles.quadTree.query(area, (p) => this.isEnabled(p));
const query = this.container.particles.quadTree.query(area, (p) => this.isEnabled(p));
for (const particle of query) {

@@ -80,3 +66,3 @@ if (area instanceof Circle) {

processMouseBounce() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
const container = this.container, pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
if (!radius || radius < 0 || !mousePos) {

@@ -88,3 +74,3 @@ return;

singleSelectorBounce(selector, div) {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), query = document.querySelectorAll(selector);
const container = this.container, query = document.querySelectorAll(selector);
if (!query.length) {

@@ -104,2 +90,1 @@ return;

}
_Bouncer_container = new WeakMap();
"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Bouncer_container;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -21,4 +9,2 @@ exports.Bouncer = void 0;

super(container);
_Bouncer_container.set(this, void 0);
__classPrivateFieldSet(this, _Bouncer_container, container, "f");
}

@@ -28,3 +14,3 @@ clear() {

init() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), bounce = container.actualOptions.interactivity.modes.bounce;
const container = this.container, bounce = container.actualOptions.interactivity.modes.bounce;
if (!bounce) {

@@ -36,3 +22,3 @@ return;

async interact() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === tsparticles_engine_1.mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
const container = this.container, options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === tsparticles_engine_1.mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
if (mouseMoveStatus && hoverEnabled && (0, tsparticles_engine_1.isInArray)("bounce", hoverMode)) {

@@ -47,3 +33,3 @@ this.processMouseBounce();

var _a;
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), options = container.actualOptions, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events, divs = events.onDiv;
const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events, divs = events.onDiv;
return ((mouse.position && events.onHover.enable && (0, tsparticles_engine_1.isInArray)("bounce", events.onHover.mode)) ||

@@ -63,3 +49,3 @@ (0, tsparticles_engine_1.isDivModeEnabled)("bounce", divs));

processBounce(position, radius, area) {
const query = __classPrivateFieldGet(this, _Bouncer_container, "f").particles.quadTree.query(area, (p) => this.isEnabled(p));
const query = this.container.particles.quadTree.query(area, (p) => this.isEnabled(p));
for (const particle of query) {

@@ -81,3 +67,3 @@ if (area instanceof tsparticles_engine_1.Circle) {

processMouseBounce() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
const container = this.container, pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
if (!radius || radius < 0 || !mousePos) {

@@ -89,3 +75,3 @@ return;

singleSelectorBounce(selector, div) {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), query = document.querySelectorAll(selector);
const container = this.container, query = document.querySelectorAll(selector);
if (!query.length) {

@@ -106,2 +92,1 @@ return;

exports.Bouncer = Bouncer;
_Bouncer_container = new WeakMap();

@@ -1,13 +0,1 @@

var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Bouncer_container;
import { Circle, ExternalInteractorBase, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, divModeExecute, isDivModeEnabled, isInArray, mouseMoveEvent, rectBounce, } from "tsparticles-engine";

@@ -18,4 +6,2 @@ import { Bounce } from "./Options/Classes/Bounce";

super(container);
_Bouncer_container.set(this, void 0);
__classPrivateFieldSet(this, _Bouncer_container, container, "f");
}

@@ -25,3 +11,3 @@ clear() {

init() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), bounce = container.actualOptions.interactivity.modes.bounce;
const container = this.container, bounce = container.actualOptions.interactivity.modes.bounce;
if (!bounce) {

@@ -33,3 +19,3 @@ return;

async interact() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
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)) {

@@ -44,3 +30,3 @@ this.processMouseBounce();

var _a;
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), options = container.actualOptions, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events, divs = events.onDiv;
const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events, divs = events.onDiv;
return ((mouse.position && events.onHover.enable && isInArray("bounce", events.onHover.mode)) ||

@@ -60,3 +46,3 @@ isDivModeEnabled("bounce", divs));

processBounce(position, radius, area) {
const query = __classPrivateFieldGet(this, _Bouncer_container, "f").particles.quadTree.query(area, (p) => this.isEnabled(p));
const query = this.container.particles.quadTree.query(area, (p) => this.isEnabled(p));
for (const particle of query) {

@@ -78,3 +64,3 @@ if (area instanceof Circle) {

processMouseBounce() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
const container = this.container, pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
if (!radius || radius < 0 || !mousePos) {

@@ -86,3 +72,3 @@ return;

singleSelectorBounce(selector, div) {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), query = document.querySelectorAll(selector);
const container = this.container, query = document.querySelectorAll(selector);
if (!query.length) {

@@ -102,2 +88,1 @@ return;

}
_Bouncer_container = new WeakMap();
{
"name": "tsparticles-interaction-external-bounce",
"version": "2.2.4",
"version": "2.3.0",
"description": "tsParticles bounce external interaction",

@@ -77,4 +77,4 @@ "homepage": "https://particles.js.org",

"dependencies": {
"tsparticles-engine": "^2.2.4"
"tsparticles-engine": "^2.3.0"
}
}

@@ -7,3 +7,3 @@ /*!

* How to use? : Check the GitHub README
* v2.2.4
* v2.3.0
*/

@@ -19,3 +19,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

}
})(this, (__WEBPACK_EXTERNAL_MODULE__818__) => {
})(this, (__WEBPACK_EXTERNAL_MODULE__961__) => {
return /******/ (() => { // webpackBootstrap

@@ -25,6 +25,6 @@ /******/ "use strict";

/***/ 818:
/***/ 961:
/***/ ((module) => {
module.exports = __WEBPACK_EXTERNAL_MODULE__818__;
module.exports = __WEBPACK_EXTERNAL_MODULE__961__;

@@ -102,3 +102,3 @@ /***/ })

// EXTERNAL MODULE: external {"commonjs":"tsparticles-engine","commonjs2":"tsparticles-engine","amd":"tsparticles-engine","root":"window"}
var external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_ = __webpack_require__(818);
var external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_ = __webpack_require__(961);
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Bounce.js

@@ -122,26 +122,7 @@ class Bounce {

;// CONCATENATED MODULE: ./dist/browser/Bouncer.js
var __classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
};
var __classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Bouncer_container;
class Bouncer extends external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.ExternalInteractorBase {
constructor(container) {
super(container);
_Bouncer_container.set(this, void 0);
__classPrivateFieldSet(this, _Bouncer_container, container, "f");
}

@@ -153,3 +134,3 @@

init() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"),
const container = this.container,
bounce = container.actualOptions.interactivity.modes.bounce;

@@ -165,3 +146,3 @@

async interact() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"),
const container = this.container,
options = container.actualOptions,

@@ -188,3 +169,3 @@ events = options.interactivity.events,

const container = __classPrivateFieldGet(this, _Bouncer_container, "f"),
const container = this.container,
options = container.actualOptions,

@@ -194,3 +175,2 @@ mouse = container.interactivity.mouse,

divs = events.onDiv;
return mouse.position && events.onHover.enable && (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("bounce"

@@ -217,3 +197,3 @@ /* HoverMode.bounce */

processBounce(position, radius, area) {
const query = __classPrivateFieldGet(this, _Bouncer_container, "f").particles.quadTree.query(area, p => this.isEnabled(p));
const query = this.container.particles.quadTree.query(area, p => this.isEnabled(p));

@@ -236,3 +216,3 @@ for (const particle of query) {

processMouseBounce() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"),
const container = this.container,
pxRatio = container.retina.pixelRatio,

@@ -251,3 +231,3 @@ tolerance = 10 * pxRatio,

singleSelectorBounce(selector, div) {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"),
const container = this.container,
query = document.querySelectorAll(selector);

@@ -276,3 +256,2 @@

}
_Bouncer_container = new WeakMap();
;// CONCATENATED MODULE: ./dist/browser/index.js

@@ -279,0 +258,0 @@

/*! 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={818: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:()=>a});var e=n(818);class t{constructor(){this.distance=200}load(e){e&&void 0!==e.distance&&(this.distance=e.distance)}}var o,r=function(e,t,o,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,o):i?i.value=o:t.set(e,o),o},s=function(e,t,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(e):n?n.value:t.get(e)};class c extends e.ExternalInteractorBase{constructor(e){super(e),o.set(this,void 0),r(this,o,e,"f")}clear(){}init(){const e=s(this,o,"f"),t=e.actualOptions.interactivity.modes.bounce;t&&(e.retina.bounceModeDistance=t.distance*e.retina.pixelRatio)}async interact(){const t=s(this,o,"f"),n=t.actualOptions.interactivity.events,i=t.interactivity.status===e.mouseMoveEvent,r=n.onHover.enable,c=n.onHover.mode,a=n.onDiv;i&&r&&(0,e.isInArray)("bounce",c)?this.processMouseBounce():(0,e.divModeExecute)("bounce",a,((e,t)=>this.singleSelectorBounce(e,t)))}isEnabled(t){var n;const i=s(this,o,"f"),r=i.actualOptions,c=i.interactivity.mouse,a=(null!==(n=null==t?void 0:t.interactivity)&&void 0!==n?n:r.interactivity).events,l=a.onDiv;return c.position&&a.onHover.enable&&(0,e.isInArray)("bounce",a.onHover.mode)||(0,e.isDivModeEnabled)("bounce",l)}loadModeOptions(e,...o){e.bounce||(e.bounce=new t);for(const t of o)e.bounce.load(null==t?void 0:t.bounce)}reset(){}processBounce(t,n,i){const r=s(this,o,"f").particles.quadTree.query(i,(e=>this.isEnabled(e)));for(const o of r)i instanceof e.Circle?(0,e.circleBounce)((0,e.circleBounceDataFromParticle)(o),{position:t,radius:n,mass:n**2*Math.PI/2,velocity:e.Vector.origin,factor:e.Vector.origin}):i instanceof e.Rectangle&&(0,e.rectBounce)(o,(0,e.calculateBounds)(t,n))}processMouseBounce(){const t=s(this,o,"f"),n=10*t.retina.pixelRatio,i=t.interactivity.mouse.position,r=t.retina.bounceModeDistance;!r||r<0||!i||this.processBounce(i,r,new e.Circle(i.x,i.y,r+n))}singleSelectorBounce(t,n){const i=s(this,o,"f"),r=document.querySelectorAll(t);r.length&&r.forEach((t=>{const o=t,r=i.retina.pixelRatio,s={x:(o.offsetLeft+o.offsetWidth/2)*r,y:(o.offsetTop+o.offsetHeight/2)*r},c=o.offsetWidth/2*r,a=10*r,l="circle"===n.type?new e.Circle(s.x,s.y,c+a):new e.Rectangle(o.offsetLeft*r-a,o.offsetTop*r-a,o.offsetWidth*r+2*a,o.offsetHeight*r+2*a);this.processBounce(s,c,l)}))}}async function a(e){await e.addInteractor("externalBounce",(e=>new c(e)))}o=new WeakMap})(),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={961: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(961);class t{constructor(){this.distance=200}load(e){e&&void 0!==e.distance&&(this.distance=e.distance)}}class o extends e.ExternalInteractorBase{constructor(e){super(e)}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){var o;const n=this.container,i=n.actualOptions,r=n.interactivity.mouse,c=(null!==(o=null==t?void 0:t.interactivity)&&void 0!==o?o:i.interactivity).events,s=c.onDiv;return r.position&&c.onHover.enable&&(0,e.isInArray)("bounce",c.onHover.mode)||(0,e.isDivModeEnabled)("bounce",s)}loadModeOptions(e,...o){e.bounce||(e.bounce=new t);for(const t of o)e.bounce.load(null==t?void 0:t.bounce)}reset(){}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))}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))}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)}))}}async function r(e){await e.addInteractor("externalBounce",(e=>new o(e)))}})(),i})()));

@@ -7,3 +7,3 @@ /*!

* How to use? : Check the GitHub README
* v2.2.4
* v2.3.0
*/
import type { BounceContainer, BounceMode, IBounceMode } from "./Types";
import { ExternalInteractorBase } from "tsparticles-engine";
import type { IModes, Modes, Particle, RecursivePartial } from "tsparticles-engine";
export declare class Bouncer extends ExternalInteractorBase {
#private;
export declare class Bouncer extends ExternalInteractorBase<BounceContainer> {
constructor(container: BounceContainer);

@@ -7,0 +6,0 @@ clear(): void;

@@ -1,12 +0,1 @@

var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
(function (factory) {

@@ -22,3 +11,2 @@ if (typeof module === "object" && typeof module.exports === "object") {

"use strict";
var _Bouncer_container;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -31,4 +19,2 @@ exports.Bouncer = void 0;

super(container);
_Bouncer_container.set(this, void 0);
__classPrivateFieldSet(this, _Bouncer_container, container, "f");
}

@@ -38,3 +24,3 @@ clear() {

init() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), bounce = container.actualOptions.interactivity.modes.bounce;
const container = this.container, bounce = container.actualOptions.interactivity.modes.bounce;
if (!bounce) {

@@ -46,3 +32,3 @@ return;

async interact() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === tsparticles_engine_1.mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
const container = this.container, options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === tsparticles_engine_1.mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
if (mouseMoveStatus && hoverEnabled && (0, tsparticles_engine_1.isInArray)("bounce", hoverMode)) {

@@ -57,3 +43,3 @@ this.processMouseBounce();

var _a;
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), options = container.actualOptions, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events, divs = events.onDiv;
const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events, divs = events.onDiv;
return ((mouse.position && events.onHover.enable && (0, tsparticles_engine_1.isInArray)("bounce", events.onHover.mode)) ||

@@ -73,3 +59,3 @@ (0, tsparticles_engine_1.isDivModeEnabled)("bounce", divs));

processBounce(position, radius, area) {
const query = __classPrivateFieldGet(this, _Bouncer_container, "f").particles.quadTree.query(area, (p) => this.isEnabled(p));
const query = this.container.particles.quadTree.query(area, (p) => this.isEnabled(p));
for (const particle of query) {

@@ -91,3 +77,3 @@ if (area instanceof tsparticles_engine_1.Circle) {

processMouseBounce() {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
const container = this.container, pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
if (!radius || radius < 0 || !mousePos) {

@@ -99,3 +85,3 @@ return;

singleSelectorBounce(selector, div) {
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), query = document.querySelectorAll(selector);
const container = this.container, query = document.querySelectorAll(selector);
if (!query.length) {

@@ -116,3 +102,2 @@ return;

exports.Bouncer = Bouncer;
_Bouncer_container = new WeakMap();
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc