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
1
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.0.0-beta.4 to 2.0.0-beta.5

12

Bouncer.js

@@ -1,2 +0,2 @@

import { calculateBounds, Circle, circleBounce, circleBounceDataFromParticle, divModeExecute, isDivModeEnabled, isInArray, Rectangle, rectBounce, DivMode, DivType, ExternalInteractorBase, HoverMode, Vector, mouseMoveEvent, } from "tsparticles-engine";
import { Circle, ExternalInteractorBase, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, divModeExecute, isDivModeEnabled, isInArray, mouseMoveEvent, rectBounce, } from "tsparticles-engine";
export class Bouncer extends ExternalInteractorBase {

@@ -8,12 +8,12 @@ constructor(container) {

const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = options.interactivity.events, divs = events.onDiv;
return ((mouse.position && events.onHover.enable && isInArray(HoverMode.bounce, events.onHover.mode)) ||
isDivModeEnabled(DivMode.bounce, divs));
return ((mouse.position && events.onHover.enable && isInArray("bounce", events.onHover.mode)) ||
isDivModeEnabled("bounce", divs));
}
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;
if (mouseMoveStatus && hoverEnabled && isInArray(HoverMode.bounce, hoverMode)) {
if (mouseMoveStatus && hoverEnabled && isInArray("bounce", hoverMode)) {
this.processMouseBounce();
}
else {
divModeExecute(DivMode.bounce, divs, (selector, div) => this.singleSelectorBounce(selector, div));
divModeExecute("bounce", divs, (selector, div) => this.singleSelectorBounce(selector, div));
}

@@ -40,3 +40,3 @@ }

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

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

@@ -1,2 +0,2 @@

import type { Main } from "tsparticles-engine";
export declare function loadExternalBounceInteraction(tsParticles: Main): Promise<void>;
import type { Engine } from "tsparticles-engine";
export declare function loadExternalBounceInteraction(engine: Engine): Promise<void>;

@@ -11,6 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { Bouncer } from "./Bouncer";
export function loadExternalBounceInteraction(tsParticles) {
export function loadExternalBounceInteraction(engine) {
return __awaiter(this, void 0, void 0, function* () {
yield tsParticles.addInteractor("externalBounce", (container) => new Bouncer(container));
yield engine.addInteractor("externalBounce", (container) => new Bouncer(container));
});
}
{
"name": "tsparticles-interaction-external-bounce",
"version": "2.0.0-beta.4",
"version": "2.0.0-beta.5",
"description": "tsParticles bounce external interaction",

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

"dependencies": {
"tsparticles-engine": "^2.0.0-beta.3"
"tsparticles-engine": "^2.0.0-beta.4"
}
}

@@ -1,2 +0,2 @@

import { Main } from "tsparticles-engine";
export declare function loadExternalBounceInteraction(tsParticles: Main): Promise<void>;
import { Engine } from "tsparticles-engine";
export declare function loadExternalBounceInteraction(engine: Engine): Promise<void>;

@@ -1,2 +0,2 @@

import type { Main } from "tsparticles-engine";
export declare function loadExternalBounceInteraction(tsParticles: Main): Promise<void>;
import type { Engine } from "tsparticles-engine";
export declare function loadExternalBounceInteraction(engine: Engine): Promise<void>;

@@ -1,2 +0,2 @@

import type { Main } from "tsparticles-engine";
export declare function loadExternalBounceInteraction(tsParticles: Main): Promise<void>;
import type { Engine } from "tsparticles-engine";
export declare function loadExternalBounceInteraction(engine: Engine): Promise<void>;

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

* How to use? : Check the GitHub README
* v2.0.0-beta.4
* v2.0.0-beta.5
*/

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

divs = events.onDiv;
return mouse.position && events.onHover.enable && (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)(external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.HoverMode.bounce, events.onHover.mode) || (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isDivModeEnabled)(external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.DivMode.bounce, divs);
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);
}

@@ -126,6 +126,6 @@

if (mouseMoveStatus && hoverEnabled && (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)(external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.HoverMode.bounce, hoverMode)) {
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)(external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.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));
}

@@ -165,3 +165,3 @@ }

tolerance = 10 * pxRatio;
const area = div.type === external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.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);
const 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);

@@ -224,5 +224,5 @@ });

function loadExternalBounceInteraction(tsParticles) {
function loadExternalBounceInteraction(engine) {
return __awaiter(this, void 0, void 0, function* () {
yield tsParticles.addInteractor("externalBounce", container => new Bouncer(container));
yield engine.addInteractor("externalBounce", container => new Bouncer(container));
});

@@ -229,0 +229,0 @@ }

@@ -1,2 +0,2 @@

/*! tsParticles Bounce External Interaction v2.0.0-beta.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,(function(e){return(()=>{"use strict";var t={818:t=>{t.exports=e}},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,n),i.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 r={};return(()=>{n.r(r),n.d(r,{loadExternalBounceInteraction:()=>i});var e=n(818);class t extends e.ExternalInteractorBase{constructor(e){super(e)}isEnabled(){const t=this.container,o=t.actualOptions,n=t.interactivity.mouse,r=o.interactivity.events,i=r.onDiv;return n.position&&r.onHover.enable&&(0,e.isInArray)(e.HoverMode.bounce,r.onHover.mode)||(0,e.isDivModeEnabled)(e.DivMode.bounce,i)}interact(){const t=this.container,o=t.actualOptions.interactivity.events,n=t.interactivity.status===e.mouseMoveEvent,r=o.onHover.enable,i=o.onHover.mode,c=o.onDiv;n&&r&&(0,e.isInArray)(e.HoverMode.bounce,i)?this.processMouseBounce():(0,e.divModeExecute)(e.DivMode.bounce,c,((e,t)=>this.singleSelectorBounce(e,t)))}reset(){}processMouseBounce(){const t=this.container,o=10*t.retina.pixelRatio,n=t.interactivity.mouse.position,r=t.retina.bounceModeDistance;n&&this.processBounce(n,r,new e.Circle(n.x,n.y,r+o))}singleSelectorBounce(t,o){const n=this.container,r=document.querySelectorAll(t);r.length&&r.forEach((t=>{const r=t,i=n.retina.pixelRatio,c={x:(r.offsetLeft+r.offsetWidth/2)*i,y:(r.offsetTop+r.offsetHeight/2)*i},s=r.offsetWidth/2*i,a=10*i,u=o.type===e.DivType.circle?new e.Circle(c.x,c.y,s+a):new e.Rectangle(r.offsetLeft*i-a,r.offsetTop*i-a,r.offsetWidth*i+2*a,r.offsetHeight*i+2*a);this.processBounce(c,s,u)}))}processBounce(t,o,n){const r=this.container.particles.quadTree.query(n);for(const i of r)n instanceof e.Circle?(0,e.circleBounce)((0,e.circleBounceDataFromParticle)(i),{position:t,radius:o,mass:Math.pow(o,2)*Math.PI/2,velocity:e.Vector.origin,factor:e.Vector.origin}):n instanceof e.Rectangle&&(0,e.rectBounce)(i,(0,e.calculateBounds)(t,o))}}var o=function(e,t,o,n){return new(o||(o=Promise))((function(r,i){function c(e){try{a(n.next(e))}catch(e){i(e)}}function s(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(c,s)}a((n=n.apply(e,t||[])).next())}))};function i(e){return o(this,void 0,void 0,(function*(){yield e.addInteractor("externalBounce",(e=>new t(e)))}))}})(),r})()}));
/*! tsParticles Bounce External Interaction v2.0.0-beta.5 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,(function(e){return(()=>{"use strict";var t={818:t=>{t.exports=e}},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,n),i.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 r={};return(()=>{n.r(r),n.d(r,{loadExternalBounceInteraction:()=>i});var e=n(818);class t extends e.ExternalInteractorBase{constructor(e){super(e)}isEnabled(){const t=this.container,o=t.actualOptions,n=t.interactivity.mouse,r=o.interactivity.events,i=r.onDiv;return n.position&&r.onHover.enable&&(0,e.isInArray)("bounce",r.onHover.mode)||(0,e.isDivModeEnabled)("bounce",i)}interact(){const t=this.container,o=t.actualOptions.interactivity.events,n=t.interactivity.status===e.mouseMoveEvent,r=o.onHover.enable,i=o.onHover.mode,c=o.onDiv;n&&r&&(0,e.isInArray)("bounce",i)?this.processMouseBounce():(0,e.divModeExecute)("bounce",c,((e,t)=>this.singleSelectorBounce(e,t)))}reset(){}processMouseBounce(){const t=this.container,o=10*t.retina.pixelRatio,n=t.interactivity.mouse.position,r=t.retina.bounceModeDistance;n&&this.processBounce(n,r,new e.Circle(n.x,n.y,r+o))}singleSelectorBounce(t,o){const n=this.container,r=document.querySelectorAll(t);r.length&&r.forEach((t=>{const r=t,i=n.retina.pixelRatio,c={x:(r.offsetLeft+r.offsetWidth/2)*i,y:(r.offsetTop+r.offsetHeight/2)*i},s=r.offsetWidth/2*i,a=10*i,u="circle"===o.type?new e.Circle(c.x,c.y,s+a):new e.Rectangle(r.offsetLeft*i-a,r.offsetTop*i-a,r.offsetWidth*i+2*a,r.offsetHeight*i+2*a);this.processBounce(c,s,u)}))}processBounce(t,o,n){const r=this.container.particles.quadTree.query(n);for(const i of r)n instanceof e.Circle?(0,e.circleBounce)((0,e.circleBounceDataFromParticle)(i),{position:t,radius:o,mass:Math.pow(o,2)*Math.PI/2,velocity:e.Vector.origin,factor:e.Vector.origin}):n instanceof e.Rectangle&&(0,e.rectBounce)(i,(0,e.calculateBounds)(t,o))}}var o=function(e,t,o,n){return new(o||(o=Promise))((function(r,i){function c(e){try{a(n.next(e))}catch(e){i(e)}}function s(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(c,s)}a((n=n.apply(e,t||[])).next())}))};function i(e){return o(this,void 0,void 0,(function*(){yield e.addInteractor("externalBounce",(e=>new t(e)))}))}})(),r})()}));

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