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

tsparticles-interaction-external-bubble

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-bubble - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

4

package.json
{
"name": "tsparticles-interaction-external-bubble",
"version": "2.1.1",
"version": "2.1.2",
"description": "tsParticles bubble external interaction",

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

"dependencies": {
"tsparticles-engine": "^2.1.1"
"tsparticles-engine": "^2.1.2"
}
}

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

* How to use? : Check the GitHub README
* v2.1.1
* v2.1.2
*/

@@ -10,0 +10,0 @@ (function webpackUniversalModuleDefinition(root, factory) {

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

/*! tsParticles Bubble External Interaction v2.1.1 by Matteo Bruni */
/*! tsParticles Bubble External Interaction v2.1.2 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 i="object"==typeof exports?t(require("tsparticles-engine")):t(e.window);for(var o in i)("object"==typeof exports?exports:e)[o]=i[o]}}(this,(e=>(()=>{"use strict";var t={818:t=>{t.exports=e}},i={};function o(e){var b=i[e];if(void 0!==b)return b.exports;var l=i[e]={exports:{}};return t[e](l,l.exports,o),l.exports}o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var b={};return(()=>{o.r(b),o.d(b,{loadExternalBubbleInteraction:()=>l});var e=o(818);function t(t,i,o,b){if(i>=o){const l=t+(i-o)*b;return(0,e.clamp)(l,t,i)}if(i<o){const l=t-(o-i)*b;return(0,e.clamp)(l,i,t)}}class i extends e.ExternalInteractorBase{constructor(e){super(e),e.bubble||(e.bubble={}),this.handleClickMode=t=>{"bubble"===t&&(e.bubble||(e.bubble={}),e.bubble.clicking=!0)}}clear(e,t){e.bubble.inRange&&!t||(delete e.bubble.div,delete e.bubble.opacity,delete e.bubble.radius,delete e.bubble.color)}init(){}async interact(){const t=this.container.actualOptions.interactivity.events,i=t.onHover,o=t.onClick,b=i.enable,l=i.mode,n=o.enable,r=o.mode,a=t.onDiv;b&&(0,e.isInArray)("bubble",l)?this.hoverBubble():n&&(0,e.isInArray)("bubble",r)?this.clickBubble():(0,e.divModeExecute)("bubble",a,((e,t)=>this.singleSelectorHover(e,t)))}isEnabled(t){var i;const o=this.container,b=o.actualOptions,l=o.interactivity.mouse,n=(null!==(i=null==t?void 0:t.interactivity)&&void 0!==i?i:b.interactivity).events,r=n.onDiv,a=(0,e.isDivModeEnabled)("bubble",r);if(!(a||n.onHover.enable&&l.position||n.onClick.enable&&l.clickPosition))return!1;const s=n.onHover.mode,u=n.onClick.mode;return(0,e.isInArray)("bubble",s)||(0,e.isInArray)("bubble",u)||a}reset(e){e.bubble.inRange=!1}clickBubble(){var t,i;const o=this.container,b=o.actualOptions,l=o.interactivity.mouse.clickPosition;if(!l)return;o.bubble||(o.bubble={});const n=o.retina.bubbleModeDistance,r=o.particles.quadTree.queryCircle(l,n,(e=>this.isEnabled(e)));for(const n of r){if(!o.bubble.clicking)continue;n.bubble.inRange=!o.bubble.durationEnd;const r=n.getPosition(),a=(0,e.getDistance)(r,l),s=((new Date).getTime()-(o.interactivity.mouse.clickTime||0))/1e3;s>b.interactivity.modes.bubble.duration&&(o.bubble.durationEnd=!0),s>2*b.interactivity.modes.bubble.duration&&(o.bubble.clicking=!1,o.bubble.durationEnd=!1);const u={bubbleObj:{optValue:o.retina.bubbleModeSize,value:n.bubble.radius},particlesObj:{optValue:(0,e.getRangeMax)(n.options.size.value)*o.retina.pixelRatio,value:n.size.value},type:"size"};this.process(n,a,s,u);const c={bubbleObj:{optValue:b.interactivity.modes.bubble.opacity,value:n.bubble.opacity},particlesObj:{optValue:(0,e.getRangeMax)(n.options.opacity.value),value:null!==(i=null===(t=n.opacity)||void 0===t?void 0:t.value)&&void 0!==i?i:1},type:"opacity"};this.process(n,a,s,c),o.bubble.durationEnd?delete n.bubble.color:a<=o.retina.bubbleModeDistance?this.hoverBubbleColor(n,a):delete n.bubble.color}}hoverBubble(){const t=this.container,i=t.interactivity.mouse.position;if(void 0===i)return;const o=t.retina.bubbleModeDistance,b=t.particles.quadTree.queryCircle(i,o,(e=>this.isEnabled(e)));for(const l of b){l.bubble.inRange=!0;const b=l.getPosition(),n=(0,e.getDistance)(b,i),r=1-n/o;n<=o?r>=0&&t.interactivity.status===e.mouseMoveEvent&&(this.hoverBubbleSize(l,r),this.hoverBubbleOpacity(l,r),this.hoverBubbleColor(l,r)):this.reset(l),t.interactivity.status===e.mouseLeaveEvent&&this.reset(l)}}hoverBubbleColor(t,i,o){const b=this.container.actualOptions,l=null!=o?o:b.interactivity.modes.bubble;if(!t.bubble.finalColor){const i=l.color;if(!i)return;const o=i instanceof Array?(0,e.itemFromArray)(i):i;t.bubble.finalColor=(0,e.rangeColorToHsl)(o)}if(t.bubble.finalColor)if(l.mix){t.bubble.color=void 0;const o=t.getFillColor();t.bubble.color=o?(0,e.rgbToHsl)((0,e.colorMix)(o,t.bubble.finalColor,1-i,i)):t.bubble.finalColor}else t.bubble.color=t.bubble.finalColor}hoverBubbleOpacity(i,o,b){var l,n,r;const a=this.container.actualOptions,s=null!==(l=null==b?void 0:b.opacity)&&void 0!==l?l:a.interactivity.modes.bubble.opacity;if(!s)return;const u=i.options.opacity.value,c=t(null!==(r=null===(n=i.opacity)||void 0===n?void 0:n.value)&&void 0!==r?r:1,s,(0,e.getRangeMax)(u),o);void 0!==c&&(i.bubble.opacity=c)}hoverBubbleSize(i,o,b){const l=this.container,n=(null==b?void 0:b.size)?b.size*l.retina.pixelRatio:l.retina.bubbleModeSize;if(void 0===n)return;const r=(0,e.getRangeMax)(i.options.size.value)*l.retina.pixelRatio,a=t(i.size.value,n,r,o);void 0!==a&&(i.bubble.radius=a)}process(e,t,i,o){const b=this.container,l=o.bubbleObj.optValue;if(void 0===l)return;const n=b.actualOptions.interactivity.modes.bubble.duration,r=b.retina.bubbleModeDistance,a=o.particlesObj.optValue,s=o.bubbleObj.value,u=o.particlesObj.value||0,c=o.type;if(l!==a)if(b.bubble||(b.bubble={}),b.bubble.durationEnd)s&&("size"===c&&delete e.bubble.radius,"opacity"===c&&delete e.bubble.opacity);else if(t<=r){if((null!=s?s:u)!==l){const t=u-i*(u-l)/n;"size"===c&&(e.bubble.radius=t),"opacity"===c&&(e.bubble.opacity=t)}}else"size"===c&&delete e.bubble.radius,"opacity"===c&&delete e.bubble.opacity}singleSelectorHover(t,i){const o=this.container,b=document.querySelectorAll(t);b.length&&b.forEach((t=>{const b=t,l=o.retina.pixelRatio,n={x:(b.offsetLeft+b.offsetWidth/2)*l,y:(b.offsetTop+b.offsetHeight/2)*l},r=b.offsetWidth/2*l,a="circle"===i.type?new e.Circle(n.x,n.y,r):new e.Rectangle(b.offsetLeft*l,b.offsetTop*l,b.offsetWidth*l,b.offsetHeight*l),s=o.particles.quadTree.query(a,(e=>this.isEnabled(e)));for(const t of s){if(!a.contains(t.getPosition()))continue;t.bubble.inRange=!0;const i=o.actualOptions.interactivity.modes.bubble.divs,l=(0,e.divMode)(i,b);t.bubble.div&&t.bubble.div===b||(this.clear(t,!0),t.bubble.div=b),this.hoverBubbleSize(t,1,l),this.hoverBubbleOpacity(t,1,l),this.hoverBubbleColor(t,1,l)}}))}}async function l(e){await e.addInteractor("externalBubble",(e=>new i(e)))}})(),b})()));

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