tsparticles-interaction-external-bounce
Advanced tools
Comparing version 2.1.4 to 2.2.0
@@ -0,5 +1,20 @@ | ||
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"; | ||
import { Bounce } from "./Options/Classes/Bounce"; | ||
export class Bouncer extends ExternalInteractorBase { | ||
constructor(container) { | ||
super(container); | ||
_Bouncer_container.set(this, void 0); | ||
__classPrivateFieldSet(this, _Bouncer_container, container, "f"); | ||
} | ||
@@ -10,6 +25,10 @@ clear() { | ||
init() { | ||
// do nothing | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), bounce = container.actualOptions.interactivity.modes.bounce; | ||
if (!bounce) { | ||
return; | ||
} | ||
container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio; | ||
} | ||
async interact() { | ||
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; | ||
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; | ||
if (mouseMoveStatus && hoverEnabled && isInArray("bounce" /* HoverMode.bounce */, hoverMode)) { | ||
@@ -24,6 +43,14 @@ this.processMouseBounce(); | ||
var _a; | ||
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; | ||
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; | ||
return ((mouse.position && events.onHover.enable && isInArray("bounce" /* HoverMode.bounce */, events.onHover.mode)) || | ||
isDivModeEnabled("bounce" /* DivMode.bounce */, divs)); | ||
} | ||
loadModeOptions(options, ...sources) { | ||
if (!options.bounce) { | ||
options.bounce = new Bounce(); | ||
} | ||
for (const source of sources) { | ||
options.bounce.load(source === null || source === void 0 ? void 0 : source.bounce); | ||
} | ||
} | ||
reset() { | ||
@@ -33,3 +60,3 @@ // do nothing | ||
processBounce(position, radius, area) { | ||
const query = this.container.particles.quadTree.query(area, (p) => this.isEnabled(p)); | ||
const query = __classPrivateFieldGet(this, _Bouncer_container, "f").particles.quadTree.query(area, (p) => this.isEnabled(p)); | ||
for (const particle of query) { | ||
@@ -51,9 +78,10 @@ if (area instanceof Circle) { | ||
processMouseBounce() { | ||
const container = this.container, pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance; | ||
if (mousePos) { | ||
this.processBounce(mousePos, radius, new Circle(mousePos.x, mousePos.y, radius + tolerance)); | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance; | ||
if (!radius || radius < 0 || !mousePos) { | ||
return; | ||
} | ||
this.processBounce(mousePos, radius, new Circle(mousePos.x, mousePos.y, radius + tolerance)); | ||
} | ||
singleSelectorBounce(selector, div) { | ||
const container = this.container, query = document.querySelectorAll(selector); | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), query = document.querySelectorAll(selector); | ||
if (!query.length) { | ||
@@ -73,1 +101,2 @@ 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 }); | ||
exports.Bouncer = void 0; | ||
const tsparticles_engine_1 = require("tsparticles-engine"); | ||
const Bounce_1 = require("./Options/Classes/Bounce"); | ||
class Bouncer extends tsparticles_engine_1.ExternalInteractorBase { | ||
constructor(container) { | ||
super(container); | ||
_Bouncer_container.set(this, void 0); | ||
__classPrivateFieldSet(this, _Bouncer_container, container, "f"); | ||
} | ||
@@ -12,5 +27,10 @@ clear() { | ||
init() { | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), bounce = container.actualOptions.interactivity.modes.bounce; | ||
if (!bounce) { | ||
return; | ||
} | ||
container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio; | ||
} | ||
async interact() { | ||
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; | ||
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; | ||
if (mouseMoveStatus && hoverEnabled && (0, tsparticles_engine_1.isInArray)("bounce", hoverMode)) { | ||
@@ -25,10 +45,18 @@ this.processMouseBounce(); | ||
var _a; | ||
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; | ||
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; | ||
return ((mouse.position && events.onHover.enable && (0, tsparticles_engine_1.isInArray)("bounce", events.onHover.mode)) || | ||
(0, tsparticles_engine_1.isDivModeEnabled)("bounce", divs)); | ||
} | ||
loadModeOptions(options, ...sources) { | ||
if (!options.bounce) { | ||
options.bounce = new Bounce_1.Bounce(); | ||
} | ||
for (const source of sources) { | ||
options.bounce.load(source === null || source === void 0 ? void 0 : source.bounce); | ||
} | ||
} | ||
reset() { | ||
} | ||
processBounce(position, radius, area) { | ||
const query = this.container.particles.quadTree.query(area, (p) => this.isEnabled(p)); | ||
const query = __classPrivateFieldGet(this, _Bouncer_container, "f").particles.quadTree.query(area, (p) => this.isEnabled(p)); | ||
for (const particle of query) { | ||
@@ -50,9 +78,10 @@ if (area instanceof tsparticles_engine_1.Circle) { | ||
processMouseBounce() { | ||
const container = this.container, pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance; | ||
if (mousePos) { | ||
this.processBounce(mousePos, radius, new tsparticles_engine_1.Circle(mousePos.x, mousePos.y, radius + tolerance)); | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance; | ||
if (!radius || radius < 0 || !mousePos) { | ||
return; | ||
} | ||
this.processBounce(mousePos, radius, new tsparticles_engine_1.Circle(mousePos.x, mousePos.y, radius + tolerance)); | ||
} | ||
singleSelectorBounce(selector, div) { | ||
const container = this.container, query = document.querySelectorAll(selector); | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), query = document.querySelectorAll(selector); | ||
if (!query.length) { | ||
@@ -73,1 +102,2 @@ return; | ||
exports.Bouncer = Bouncer; | ||
_Bouncer_container = new WeakMap(); |
@@ -0,5 +1,20 @@ | ||
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"; | ||
import { Bounce } from "./Options/Classes/Bounce"; | ||
export class Bouncer extends ExternalInteractorBase { | ||
constructor(container) { | ||
super(container); | ||
_Bouncer_container.set(this, void 0); | ||
__classPrivateFieldSet(this, _Bouncer_container, container, "f"); | ||
} | ||
@@ -9,5 +24,10 @@ clear() { | ||
init() { | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), bounce = container.actualOptions.interactivity.modes.bounce; | ||
if (!bounce) { | ||
return; | ||
} | ||
container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio; | ||
} | ||
async interact() { | ||
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; | ||
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; | ||
if (mouseMoveStatus && hoverEnabled && isInArray("bounce", hoverMode)) { | ||
@@ -22,10 +42,18 @@ this.processMouseBounce(); | ||
var _a; | ||
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; | ||
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; | ||
return ((mouse.position && events.onHover.enable && isInArray("bounce", events.onHover.mode)) || | ||
isDivModeEnabled("bounce", divs)); | ||
} | ||
loadModeOptions(options, ...sources) { | ||
if (!options.bounce) { | ||
options.bounce = new Bounce(); | ||
} | ||
for (const source of sources) { | ||
options.bounce.load(source === null || source === void 0 ? void 0 : source.bounce); | ||
} | ||
} | ||
reset() { | ||
} | ||
processBounce(position, radius, area) { | ||
const query = this.container.particles.quadTree.query(area, (p) => this.isEnabled(p)); | ||
const query = __classPrivateFieldGet(this, _Bouncer_container, "f").particles.quadTree.query(area, (p) => this.isEnabled(p)); | ||
for (const particle of query) { | ||
@@ -47,9 +75,10 @@ if (area instanceof Circle) { | ||
processMouseBounce() { | ||
const container = this.container, pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance; | ||
if (mousePos) { | ||
this.processBounce(mousePos, radius, new Circle(mousePos.x, mousePos.y, radius + tolerance)); | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance; | ||
if (!radius || radius < 0 || !mousePos) { | ||
return; | ||
} | ||
this.processBounce(mousePos, radius, new Circle(mousePos.x, mousePos.y, radius + tolerance)); | ||
} | ||
singleSelectorBounce(selector, div) { | ||
const container = this.container, query = document.querySelectorAll(selector); | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), query = document.querySelectorAll(selector); | ||
if (!query.length) { | ||
@@ -69,1 +98,2 @@ return; | ||
} | ||
_Bouncer_container = new WeakMap(); |
{ | ||
"name": "tsparticles-interaction-external-bounce", | ||
"version": "2.1.4", | ||
"version": "2.2.0", | ||
"description": "tsParticles bounce external interaction", | ||
"homepage": "https://particles.js.org/", | ||
"homepage": "https://particles.js.org", | ||
"repository": { | ||
@@ -64,3 +64,3 @@ "type": "git", | ||
], | ||
"author": "Matteo Bruni", | ||
"author": "Matteo Bruni <matteo.bruni@me.com>", | ||
"license": "MIT", | ||
@@ -76,4 +76,4 @@ "bugs": { | ||
"dependencies": { | ||
"tsparticles-engine": "^2.1.4" | ||
"tsparticles-engine": "^2.2.0" | ||
} | ||
} |
@@ -7,3 +7,3 @@ [![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org) | ||
[![npmjs](https://badge.fury.io/js/tsparticles-interaction-external-bounce.svg)](https://www.npmjs.com/package/tsparticles-interaction-external-bounce) | ||
[![npmjs](https://img.shields.io/npm/dt/tsparticles-interaction-external-bounce)](https://www.npmjs.com/package/tsparticles-interaction-external-bounce) | ||
[![npmjs](https://img.shields.io/npm/dt/tsparticles-interaction-external-bounce)](https://www.npmjs.com/package/tsparticles-interaction-external-bounce) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni) | ||
@@ -10,0 +10,0 @@ [tsParticles](https://github.com/matteobruni/tsparticles) interaction plugin for bounce effect around mouse or HTML |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v2.1.4 | ||
* v2.2.0 | ||
*/ | ||
@@ -100,7 +100,44 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_ = __webpack_require__(818); | ||
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Bounce.js | ||
class Bounce { | ||
constructor() { | ||
this.distance = 200; | ||
} | ||
load(data) { | ||
if (!data) { | ||
return; | ||
} | ||
if (data.distance !== undefined) { | ||
this.distance = data.distance; | ||
} | ||
} | ||
} | ||
;// 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"); | ||
} | ||
@@ -111,7 +148,15 @@ | ||
init() {// do nothing | ||
init() { | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), | ||
bounce = container.actualOptions.interactivity.modes.bounce; | ||
if (!bounce) { | ||
return; | ||
} | ||
container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio; | ||
} | ||
async interact() { | ||
const container = this.container, | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), | ||
options = container.actualOptions, | ||
@@ -138,3 +183,3 @@ events = options.interactivity.events, | ||
const container = this.container, | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), | ||
options = container.actualOptions, | ||
@@ -144,2 +189,3 @@ 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" | ||
@@ -152,2 +198,12 @@ /* HoverMode.bounce */ | ||
loadModeOptions(options, ...sources) { | ||
if (!options.bounce) { | ||
options.bounce = new Bounce(); | ||
} | ||
for (const source of sources) { | ||
options.bounce.load(source === null || source === void 0 ? void 0 : source.bounce); | ||
} | ||
} | ||
reset() {// do nothing | ||
@@ -157,3 +213,3 @@ } | ||
processBounce(position, radius, area) { | ||
const query = this.container.particles.quadTree.query(area, p => this.isEnabled(p)); | ||
const query = __classPrivateFieldGet(this, _Bouncer_container, "f").particles.quadTree.query(area, p => this.isEnabled(p)); | ||
@@ -176,3 +232,3 @@ for (const particle of query) { | ||
processMouseBounce() { | ||
const container = this.container, | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), | ||
pxRatio = container.retina.pixelRatio, | ||
@@ -183,9 +239,11 @@ tolerance = 10 * pxRatio, | ||
if (mousePos) { | ||
this.processBounce(mousePos, radius, new external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.Circle(mousePos.x, mousePos.y, radius + tolerance)); | ||
if (!radius || radius < 0 || !mousePos) { | ||
return; | ||
} | ||
this.processBounce(mousePos, radius, new external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.Circle(mousePos.x, mousePos.y, radius + tolerance)); | ||
} | ||
singleSelectorBounce(selector, div) { | ||
const container = this.container, | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), | ||
query = document.querySelectorAll(selector); | ||
@@ -214,2 +272,3 @@ | ||
} | ||
_Bouncer_container = new WeakMap(); | ||
;// CONCATENATED MODULE: ./dist/browser/index.js | ||
@@ -216,0 +275,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! tsParticles Bounce External Interaction v2.1.4 by Matteo Bruni */ | ||
!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,{loadExternalBounceInteraction:()=>o});var e=n(818);class t extends e.ExternalInteractorBase{constructor(e){super(e)}clear(){}init(){}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)}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;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,l="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,l)}))}}async function o(e){await e.addInteractor("externalBounce",(e=>new t(e)))}})(),i})())); | ||
/*! 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,{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})())); |
@@ -0,5 +1,7 @@ | ||
import type { BounceContainer, BounceMode, IBounceMode } from "./Types"; | ||
import { ExternalInteractorBase } from "tsparticles-engine"; | ||
import type { Container, Particle } from "tsparticles-engine"; | ||
import type { IModes, Modes, Particle, RecursivePartial } from "tsparticles-engine"; | ||
export declare class Bouncer extends ExternalInteractorBase { | ||
constructor(container: Container); | ||
#private; | ||
constructor(container: BounceContainer); | ||
clear(): void; | ||
@@ -9,2 +11,3 @@ init(): void; | ||
isEnabled(particle?: Particle): boolean; | ||
loadModeOptions(options: Modes & BounceMode, ...sources: RecursivePartial<(IModes & IBounceMode) | undefined>[]): void; | ||
reset(): void; | ||
@@ -11,0 +14,0 @@ private processBounce; |
@@ -0,1 +1,12 @@ | ||
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) { | ||
@@ -7,12 +18,16 @@ if (typeof module === "object" && typeof module.exports === "object") { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "tsparticles-engine"], factory); | ||
define(["require", "exports", "tsparticles-engine", "./Options/Classes/Bounce"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
var _Bouncer_container; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Bouncer = void 0; | ||
const tsparticles_engine_1 = require("tsparticles-engine"); | ||
const Bounce_1 = require("./Options/Classes/Bounce"); | ||
class Bouncer extends tsparticles_engine_1.ExternalInteractorBase { | ||
constructor(container) { | ||
super(container); | ||
_Bouncer_container.set(this, void 0); | ||
__classPrivateFieldSet(this, _Bouncer_container, container, "f"); | ||
} | ||
@@ -22,5 +37,10 @@ clear() { | ||
init() { | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), bounce = container.actualOptions.interactivity.modes.bounce; | ||
if (!bounce) { | ||
return; | ||
} | ||
container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio; | ||
} | ||
async interact() { | ||
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; | ||
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; | ||
if (mouseMoveStatus && hoverEnabled && (0, tsparticles_engine_1.isInArray)("bounce", hoverMode)) { | ||
@@ -35,10 +55,18 @@ this.processMouseBounce(); | ||
var _a; | ||
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; | ||
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; | ||
return ((mouse.position && events.onHover.enable && (0, tsparticles_engine_1.isInArray)("bounce", events.onHover.mode)) || | ||
(0, tsparticles_engine_1.isDivModeEnabled)("bounce", divs)); | ||
} | ||
loadModeOptions(options, ...sources) { | ||
if (!options.bounce) { | ||
options.bounce = new Bounce_1.Bounce(); | ||
} | ||
for (const source of sources) { | ||
options.bounce.load(source === null || source === void 0 ? void 0 : source.bounce); | ||
} | ||
} | ||
reset() { | ||
} | ||
processBounce(position, radius, area) { | ||
const query = this.container.particles.quadTree.query(area, (p) => this.isEnabled(p)); | ||
const query = __classPrivateFieldGet(this, _Bouncer_container, "f").particles.quadTree.query(area, (p) => this.isEnabled(p)); | ||
for (const particle of query) { | ||
@@ -60,9 +88,10 @@ if (area instanceof tsparticles_engine_1.Circle) { | ||
processMouseBounce() { | ||
const container = this.container, pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance; | ||
if (mousePos) { | ||
this.processBounce(mousePos, radius, new tsparticles_engine_1.Circle(mousePos.x, mousePos.y, radius + tolerance)); | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), pxRatio = container.retina.pixelRatio, tolerance = 10 * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance; | ||
if (!radius || radius < 0 || !mousePos) { | ||
return; | ||
} | ||
this.processBounce(mousePos, radius, new tsparticles_engine_1.Circle(mousePos.x, mousePos.y, radius + tolerance)); | ||
} | ||
singleSelectorBounce(selector, div) { | ||
const container = this.container, query = document.querySelectorAll(selector); | ||
const container = __classPrivateFieldGet(this, _Bouncer_container, "f"), query = document.querySelectorAll(selector); | ||
if (!query.length) { | ||
@@ -83,2 +112,3 @@ return; | ||
exports.Bouncer = Bouncer; | ||
_Bouncer_container = new WeakMap(); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
328601
37
849
1
80
Updatedtsparticles-engine@^2.2.0