tsparticles-interaction-external-bubble
Advanced tools
Comparing version 2.0.0-beta.1 to 2.0.0-beta.2
{ | ||
"name": "tsparticles-interaction-external-bubble", | ||
"version": "2.0.0-beta.1", | ||
"version": "2.0.0-beta.2", | ||
"description": "tsParticles bubble external interaction", | ||
@@ -65,4 +65,4 @@ "homepage": "https://particles.js.org/", | ||
"dependencies": { | ||
"tsparticles-engine": "^2.0.0-beta.0" | ||
"tsparticles-engine": "^2.0.0-beta.1" | ||
} | ||
} |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v2.0.0-beta.1 | ||
* v2.0.0-beta.2 | ||
*/ | ||
@@ -10,0 +10,0 @@ (function webpackUniversalModuleDefinition(root, factory) { |
@@ -1,2 +0,2 @@ | ||
/*! tsParticles Bubble External Interaction v2.0.0-beta.1 by Matteo Bruni */ | ||
/*! tsParticles Bubble External Interaction v2.0.0-beta.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,(function(e){return(()=>{"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 n=i[e]={exports:{}};return t[e](n,n.exports,o),n.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,t=o(818);function i(e,i,o,b){if(i>=o){const n=e+(i-o)*b;return(0,t.clamp)(n,e,i)}if(i<o){const n=e-(o-i)*b;return(0,t.clamp)(n,i,e)}}!function(e){e.color="color",e.opacity="opacity",e.size="size"}(e||(e={}));class n extends t.ExternalInteractorBase{constructor(e){super(e),this.handleClickMode=i=>{i===t.ClickMode.bubble&&(e.bubble.clicking=!0)}}isEnabled(){const e=this.container,i=e.actualOptions,o=e.interactivity.mouse,b=i.interactivity.events,n=b.onDiv,l=(0,t.isDivModeEnabled)(t.DivMode.bubble,n);if(!(l||b.onHover.enable&&o.position||b.onClick.enable&&o.clickPosition))return!1;const r=b.onHover.mode,a=b.onClick.mode;return(0,t.isInArray)(t.HoverMode.bubble,r)||(0,t.isInArray)(t.ClickMode.bubble,a)||l}reset(e,t){e.bubble.inRange&&!t||(delete e.bubble.div,delete e.bubble.opacity,delete e.bubble.radius,delete e.bubble.color)}interact(){const e=this.container.actualOptions.interactivity.events,i=e.onHover,o=e.onClick,b=i.enable,n=i.mode,l=o.enable,r=o.mode,a=e.onDiv;b&&(0,t.isInArray)(t.HoverMode.bubble,n)?this.hoverBubble():l&&(0,t.isInArray)(t.ClickMode.bubble,r)?this.clickBubble():(0,t.divModeExecute)(t.DivMode.bubble,a,((e,t)=>this.singleSelectorHover(e,t)))}singleSelectorHover(e,i){const o=this.container,b=document.querySelectorAll(e);b.length&&b.forEach((e=>{const b=e,n=o.retina.pixelRatio,l={x:(b.offsetLeft+b.offsetWidth/2)*n,y:(b.offsetTop+b.offsetHeight/2)*n},r=b.offsetWidth/2*n,a=i.type===t.DivType.circle?new t.Circle(l.x,l.y,r):new t.Rectangle(b.offsetLeft*n,b.offsetTop*n,b.offsetWidth*n,b.offsetHeight*n),s=o.particles.quadTree.query(a);for(const e of s){if(!a.contains(e.getPosition()))continue;e.bubble.inRange=!0;const i=o.actualOptions.interactivity.modes.bubble.divs,n=(0,t.divMode)(i,b);e.bubble.div&&e.bubble.div===b||(this.reset(e,!0),e.bubble.div=b),this.hoverBubbleSize(e,1,n),this.hoverBubbleOpacity(e,1,n),this.hoverBubbleColor(e,1,n)}}))}process(t,i,o,b){const n=this.container,l=b.bubbleObj.optValue;if(void 0===l)return;const r=n.actualOptions.interactivity.modes.bubble.duration,a=n.retina.bubbleModeDistance,s=b.particlesObj.optValue,u=b.bubbleObj.value,c=b.particlesObj.value||0,d=b.type;if(l!==s)if(n.bubble.durationEnd)u&&(d===e.size&&delete t.bubble.radius,d===e.opacity&&delete t.bubble.opacity);else if(i<=a){if((null!=u?u:c)!==l){const i=c-o*(c-l)/r;d===e.size&&(t.bubble.radius=i),d===e.opacity&&(t.bubble.opacity=i)}}else d===e.size&&delete t.bubble.radius,d===e.opacity&&delete t.bubble.opacity}clickBubble(){var i,o;const b=this.container,n=b.actualOptions,l=b.interactivity.mouse.clickPosition;if(!l)return;const r=b.retina.bubbleModeDistance,a=b.particles.quadTree.queryCircle(l,r);for(const r of a){if(!b.bubble.clicking)continue;r.bubble.inRange=!b.bubble.durationEnd;const a=r.getPosition(),s=(0,t.getDistance)(a,l),u=((new Date).getTime()-(b.interactivity.mouse.clickTime||0))/1e3;u>n.interactivity.modes.bubble.duration&&(b.bubble.durationEnd=!0),u>2*n.interactivity.modes.bubble.duration&&(b.bubble.clicking=!1,b.bubble.durationEnd=!1);const c={bubbleObj:{optValue:b.retina.bubbleModeSize,value:r.bubble.radius},particlesObj:{optValue:(0,t.getRangeMax)(r.options.size.value)*b.retina.pixelRatio,value:r.size.value},type:e.size};this.process(r,s,u,c);const d={bubbleObj:{optValue:n.interactivity.modes.bubble.opacity,value:r.bubble.opacity},particlesObj:{optValue:(0,t.getRangeMax)(r.options.opacity.value),value:null!==(o=null===(i=r.opacity)||void 0===i?void 0:i.value)&&void 0!==o?o:1},type:e.opacity};this.process(r,s,u,d),b.bubble.durationEnd?delete r.bubble.color:s<=b.retina.bubbleModeDistance?this.hoverBubbleColor(r,s):delete r.bubble.color}}hoverBubble(){const e=this.container,i=e.interactivity.mouse.position;if(void 0===i)return;const o=e.retina.bubbleModeDistance,b=e.particles.quadTree.queryCircle(i,o);for(const n of b){n.bubble.inRange=!0;const b=n.getPosition(),l=(0,t.getDistance)(b,i),r=1-l/o;l<=o?r>=0&&e.interactivity.status===t.Constants.mouseMoveEvent&&(this.hoverBubbleSize(n,r),this.hoverBubbleOpacity(n,r),this.hoverBubbleColor(n,r)):this.reset(n),e.interactivity.status===t.Constants.mouseLeaveEvent&&this.reset(n)}}hoverBubbleSize(e,o,b){const n=this.container,l=(null==b?void 0:b.size)?b.size*n.retina.pixelRatio:n.retina.bubbleModeSize;if(void 0===l)return;const r=(0,t.getRangeMax)(e.options.size.value)*n.retina.pixelRatio,a=i(e.size.value,l,r,o);void 0!==a&&(e.bubble.radius=a)}hoverBubbleOpacity(e,o,b){var n,l,r;const a=this.container.actualOptions,s=null!==(n=null==b?void 0:b.opacity)&&void 0!==n?n:a.interactivity.modes.bubble.opacity;if(!s)return;const u=e.options.opacity.value,c=i(null!==(r=null===(l=e.opacity)||void 0===l?void 0:l.value)&&void 0!==r?r:1,s,(0,t.getRangeMax)(u),o);void 0!==c&&(e.bubble.opacity=c)}hoverBubbleColor(e,i,o){const b=this.container.actualOptions,n=null!=o?o:b.interactivity.modes.bubble;if(!e.bubble.finalColor){const i=n.color;if(!i)return;const o=i instanceof Array?(0,t.itemFromArray)(i):i;e.bubble.finalColor=(0,t.colorToHsl)(o)}if(e.bubble.finalColor)if(n.mix){e.bubble.color=void 0;const o=e.getFillColor();e.bubble.color=o?(0,t.rgbToHsl)((0,t.colorMix)(o,e.bubble.finalColor,1-i,i)):e.bubble.finalColor}else e.bubble.color=e.bubble.finalColor}}function l(e){e.addInteractor("externalBubble",(e=>new n(e)))}})(),b})()})); |
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
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