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.3.3 to 2.4.0

12

browser/Bouncer.js

@@ -8,3 +8,2 @@ import { Circle, ExternalInteractorBase, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, divModeExecute, isDivModeEnabled, isInArray, mouseMoveEvent, rectBounce, } from "tsparticles-engine";

clear() {
// do nothing
}

@@ -20,7 +19,7 @@ init() {

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)) {
if (mouseMoveStatus && hoverEnabled && isInArray("bounce", hoverMode)) {
this.processMouseBounce();
}
else {
divModeExecute("bounce" /* DivMode.bounce */, divs, (selector, div) => this.singleSelectorBounce(selector, div));
divModeExecute("bounce", divs, (selector, div) => this.singleSelectorBounce(selector, div));
}

@@ -31,4 +30,4 @@ }

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)) ||
isDivModeEnabled("bounce" /* DivMode.bounce */, divs));
return ((mouse.position && events.onHover.enable && isInArray("bounce", events.onHover.mode)) ||
isDivModeEnabled("bounce", divs));
}

@@ -44,3 +43,2 @@ loadModeOptions(options, ...sources) {

reset() {
// do nothing
}

@@ -80,3 +78,3 @@ processBounce(position, radius, area) {

y: (elem.offsetTop + elem.offsetHeight / 2) * pxRatio,
}, radius = (elem.offsetWidth / 2) * pxRatio, tolerance = 10 * pxRatio, area = div.type === "circle" /* DivType.circle */
}, radius = (elem.offsetWidth / 2) * pxRatio, tolerance = 10 * pxRatio, area = div.type === "circle"
? new Circle(pos.x, pos.y, radius + tolerance)

@@ -83,0 +81,0 @@ : new Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * 2, elem.offsetHeight * pxRatio + tolerance * 2);

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -19,10 +28,12 @@ exports.Bouncer = void 0;

}
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;
if (mouseMoveStatus && hoverEnabled && (0, tsparticles_engine_1.isInArray)("bounce", hoverMode)) {
this.processMouseBounce();
}
else {
(0, tsparticles_engine_1.divModeExecute)("bounce", divs, (selector, div) => this.singleSelectorBounce(selector, div));
}
interact() {
return __awaiter(this, void 0, void 0, function* () {
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)) {
this.processMouseBounce();
}
else {
(0, tsparticles_engine_1.divModeExecute)("bounce", divs, (selector, div) => this.singleSelectorBounce(selector, div));
}
});
}

@@ -52,3 +63,3 @@ isEnabled(particle) {

radius,
mass: (radius ** 2 * Math.PI) / 2,
mass: (Math.pow(radius, 2) * Math.PI) / 2,
velocity: tsparticles_engine_1.Vector.origin,

@@ -55,0 +66,0 @@ factor: tsparticles_engine_1.Vector.origin,

@@ -16,7 +16,18 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadExternalBounceInteraction = void 0;
const Bouncer_1 = require("./Bouncer");
async function loadExternalBounceInteraction(engine) {
await engine.addInteractor("externalBounce", (container) => new Bouncer_1.Bouncer(container));
function loadExternalBounceInteraction(engine) {
return __awaiter(this, void 0, void 0, function* () {
yield engine.addInteractor("externalBounce", (container) => new Bouncer_1.Bouncer(container));
});
}

@@ -23,0 +34,0 @@ exports.loadExternalBounceInteraction = loadExternalBounceInteraction;

{
"name": "tsparticles-interaction-external-bounce",
"version": "2.3.3",
"version": "2.4.0",
"description": "tsParticles bounce external interaction",

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

"dependencies": {
"tsparticles-engine": "^2.3.3"
"tsparticles-engine": "^2.4.0"
}
}

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

* How to use? : Check the GitHub README
* v2.3.3
* v2.4.0
*/

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

}
load(data) {

@@ -112,3 +111,2 @@ if (!data) {

}
if (data.distance !== undefined) {

@@ -118,3 +116,2 @@ this.distance = data.distance;

}
}

@@ -128,52 +125,34 @@ ;// CONCATENATED MODULE: ./dist/browser/Bouncer.js

}
clear() {// do nothing
}
clear() {}
init() {
const container = this.container,
bounce = container.actualOptions.interactivity.modes.bounce;
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 === external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.mouseMoveEvent,
hoverEnabled = events.onHover.enable,
hoverMode = events.onHover.mode,
divs = events.onDiv;
if (mouseMoveStatus && hoverEnabled && (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("bounce"
/* HoverMode.bounce */
, hoverMode)) {
options = container.actualOptions,
events = options.interactivity.events,
mouseMoveStatus = container.interactivity.status === external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.mouseMoveEvent,
hoverEnabled = events.onHover.enable,
hoverMode = events.onHover.mode,
divs = events.onDiv;
if (mouseMoveStatus && hoverEnabled && (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("bounce", hoverMode)) {
this.processMouseBounce();
} else {
(0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.divModeExecute)("bounce"
/* DivMode.bounce */
, divs, (selector, div) => this.singleSelectorBounce(selector, div));
(0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.divModeExecute)("bounce", divs, (selector, div) => this.singleSelectorBounce(selector, div));
}
}
isEnabled(particle) {
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;
return mouse.position && events.onHover.enable && (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("bounce"
/* HoverMode.bounce */
, events.onHover.mode) || (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isDivModeEnabled)("bounce"
/* DivMode.bounce */
, divs);
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,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("bounce", events.onHover.mode) || (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isDivModeEnabled)("bounce", divs);
}
loadModeOptions(options, ...sources) {

@@ -183,3 +162,2 @@ if (!options.bounce) {

}
for (const source of sources) {

@@ -189,9 +167,5 @@ options.bounce.load(source === null || source === void 0 ? void 0 : source.bounce);

}
reset() {// do nothing
}
reset() {}
processBounce(position, radius, area) {
const query = this.container.particles.quadTree.query(area, p => this.isEnabled(p));
for (const particle of query) {

@@ -211,41 +185,32 @@ if (area instanceof external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.Circle) {

}
processMouseBounce() {
const container = this.container,
pxRatio = container.retina.pixelRatio,
tolerance = 10 * pxRatio,
mousePos = container.interactivity.mouse.position,
radius = container.retina.bounceModeDistance;
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 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,
query = document.querySelectorAll(selector);
query = document.querySelectorAll(selector);
if (!query.length) {
return;
}
query.forEach(item => {
const elem = item,
pxRatio = container.retina.pixelRatio,
pos = {
x: (elem.offsetLeft + elem.offsetWidth / 2) * pxRatio,
y: (elem.offsetTop + elem.offsetHeight / 2) * pxRatio
},
radius = elem.offsetWidth / 2 * pxRatio,
tolerance = 10 * pxRatio,
area = div.type === "circle"
/* DivType.circle */
? new external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.Circle(pos.x, pos.y, radius + tolerance) : new external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * 2, elem.offsetHeight * pxRatio + tolerance * 2);
pxRatio = container.retina.pixelRatio,
pos = {
x: (elem.offsetLeft + elem.offsetWidth / 2) * pxRatio,
y: (elem.offsetTop + elem.offsetHeight / 2) * pxRatio
},
radius = elem.offsetWidth / 2 * pxRatio,
tolerance = 10 * pxRatio,
area = div.type === "circle" ? new external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.Circle(pos.x, pos.y, radius + tolerance) : new external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * 2, elem.offsetHeight * pxRatio + tolerance * 2);
this.processBounce(pos, radius, area);
});
}
}

@@ -252,0 +217,0 @@ ;// CONCATENATED MODULE: ./dist/browser/index.js

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

* How to use? : Check the GitHub README
* v2.3.3
* v2.4.0
*/

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