/*! * Author : Matteo Bruni * MIT license: https://opensource.org/licenses/MIT * Demo / Generator : https://particles.js.org/ * GitHub : https://www.github.com/matteobruni/tsparticles * How to use? : Check the GitHub README * v2.8.0 */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("tsparticles-engine")); else if(typeof define === 'function' && define.amd) define(["tsparticles-engine"], factory); else { var a = typeof exports === 'object' ? factory(require("tsparticles-engine")) : factory(root["window"]); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(this, (__WEBPACK_EXTERNAL_MODULE__961__) => { return /******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ 961: /***/ ((module) => { module.exports = __WEBPACK_EXTERNAL_MODULE__961__; /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ var cachedModule = __webpack_module_cache__[moduleId]; /******/ if (cachedModule !== undefined) { /******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ // no module.id needed /******/ // no module.loaded needed /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ /******/ /* webpack/runtime/define property getters */ /******/ (() => { /******/ // define getter functions for harmony exports /******/ __webpack_require__.d = (exports, definition) => { /******/ for(var key in definition) { /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); /******/ } /******/ } /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ (() => { /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) /******/ })(); /******/ /******/ /* webpack/runtime/make namespace object */ /******/ (() => { /******/ // define __esModule on exports /******/ __webpack_require__.r = (exports) => { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ })(); /******/ /************************************************************************/ var __webpack_exports__ = {}; // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. (() => { // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { "Bubble": () => (/* reexport */ Bubble), "BubbleBase": () => (/* reexport */ BubbleBase), "BubbleDiv": () => (/* reexport */ BubbleDiv), "loadExternalBubbleInteraction": () => (/* binding */ loadExternalBubbleInteraction) }); // EXTERNAL MODULE: external {"commonjs":"tsparticles-engine","commonjs2":"tsparticles-engine","amd":"tsparticles-engine","root":"window"} var external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_ = __webpack_require__(961); ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/BubbleBase.js class BubbleBase { constructor() { this.distance = 200; this.duration = 0.4; this.mix = false; } load(data) { if (!data) { return; } if (data.distance !== undefined) { this.distance = data.distance; } if (data.duration !== undefined) { this.duration = data.duration; } if (data.mix !== undefined) { this.mix = data.mix; } if (data.opacity !== undefined) { this.opacity = data.opacity; } if (data.color !== undefined) { const sourceColor = this.color instanceof Array ? undefined : this.color; this.color = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.executeOnSingleOrMultiple)(data.color, color => { return external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.OptionsColor.create(sourceColor, color); }); } if (data.size !== undefined) { this.size = data.size; } } } ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/BubbleDiv.js class BubbleDiv extends BubbleBase { constructor() { super(); this.selectors = []; } get ids() { return (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.executeOnSingleOrMultiple)(this.selectors, t => t.replace("#", "")); } set ids(value) { this.selectors = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.executeOnSingleOrMultiple)(value, t => `#${t}`); } load(data) { super.load(data); if (!data) { return; } if (data.ids !== undefined) { this.ids = data.ids; } if (data.selectors !== undefined) { this.selectors = data.selectors; } } } ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Bubble.js class Bubble extends BubbleBase { load(data) { super.load(data); if (!data) { return; } this.divs = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.executeOnSingleOrMultiple)(data.divs, div => { const tmp = new BubbleDiv(); tmp.load(div); return tmp; }); } } ;// CONCATENATED MODULE: ./dist/browser/Bubbler.js function calculateBubbleValue(particleValue, modeValue, optionsValue, ratio) { if (modeValue >= optionsValue) { const value = particleValue + (modeValue - optionsValue) * ratio; return (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.clamp)(value, particleValue, modeValue); } else if (modeValue < optionsValue) { const value = particleValue - (optionsValue - modeValue) * ratio; return (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.clamp)(value, modeValue, particleValue); } } class Bubbler extends external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.ExternalInteractorBase { constructor(container) { super(container); if (!container.bubble) { container.bubble = {}; } this.handleClickMode = mode => { if (mode !== "bubble") { return; } if (!container.bubble) { container.bubble = {}; } container.bubble.clicking = true; }; } clear(particle, delta, force) { if (particle.bubble.inRange && !force) { return; } delete particle.bubble.div; delete particle.bubble.opacity; delete particle.bubble.radius; delete particle.bubble.color; } init() { const container = this.container, bubble = container.actualOptions.interactivity.modes.bubble; if (!bubble) { return; } container.retina.bubbleModeDistance = bubble.distance * container.retina.pixelRatio; if (bubble.size !== undefined) { container.retina.bubbleModeSize = bubble.size * container.retina.pixelRatio; } } async interact(delta) { const options = this.container.actualOptions, events = options.interactivity.events, onHover = events.onHover, onClick = events.onClick, hoverEnabled = onHover.enable, hoverMode = onHover.mode, clickEnabled = onClick.enable, clickMode = onClick.mode, divs = events.onDiv; if (hoverEnabled && (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("bubble", hoverMode)) { this.hoverBubble(delta); } else if (clickEnabled && (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("bubble", clickMode)) { this.clickBubble(delta); } else { (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.divModeExecute)("bubble", divs, (selector, div) => this.singleSelectorHover(delta, 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, divBubble = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isDivModeEnabled)("bubble", divs); if (!(divBubble || events.onHover.enable && mouse.position || events.onClick.enable && mouse.clickPosition)) { return false; } const hoverMode = events.onHover.mode; const clickMode = events.onClick.mode; return (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("bubble", hoverMode) || (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("bubble", clickMode) || divBubble; } loadModeOptions(options, ...sources) { if (!options.bubble) { options.bubble = new Bubble(); } for (const source of sources) { options.bubble.load(source === null || source === void 0 ? void 0 : source.bubble); } } reset(particle) { particle.bubble.inRange = false; } clickBubble(delta) { var _a, _b; const container = this.container, options = container.actualOptions, mouseClickPos = container.interactivity.mouse.clickPosition, bubble = options.interactivity.modes.bubble; if (!bubble || !mouseClickPos) { return; } if (!container.bubble) { container.bubble = {}; } const distance = container.retina.bubbleModeDistance; if (!distance || distance < 0) { return; } const query = container.particles.quadTree.queryCircle(mouseClickPos, distance, p => this.isEnabled(p)); for (const particle of query) { if (!container.bubble.clicking) { continue; } particle.bubble.inRange = !container.bubble.durationEnd; const pos = particle.getPosition(), distMouse = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getDistance)(pos, mouseClickPos), timeSpent = (new Date().getTime() - (container.interactivity.mouse.clickTime || 0)) / 1000; if (timeSpent > bubble.duration) { container.bubble.durationEnd = true; } if (timeSpent > bubble.duration * 2) { container.bubble.clicking = false; container.bubble.durationEnd = false; } const sizeData = { bubbleObj: { optValue: container.retina.bubbleModeSize, value: particle.bubble.radius }, particlesObj: { optValue: (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeMax)(particle.options.size.value) * container.retina.pixelRatio, value: particle.size.value }, type: "size" }; this.process(particle, distMouse, timeSpent, sizeData); const opacityData = { bubbleObj: { optValue: bubble.opacity, value: particle.bubble.opacity }, particlesObj: { optValue: (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeMax)(particle.options.opacity.value), value: (_b = (_a = particle.opacity) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 1 }, type: "opacity" }; this.process(particle, distMouse, timeSpent, opacityData); if (!container.bubble.durationEnd) { if (distMouse <= distance) { this.hoverBubbleColor(particle, distMouse); } else { delete particle.bubble.color; } } else { delete particle.bubble.color; } } } hoverBubble(delta) { const container = this.container, mousePos = container.interactivity.mouse.position, distance = container.retina.bubbleModeDistance; if (!distance || distance < 0 || mousePos === undefined) { return; } const query = container.particles.quadTree.queryCircle(mousePos, distance, p => this.isEnabled(p)); for (const particle of query) { particle.bubble.inRange = true; const pos = particle.getPosition(), pointDistance = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getDistance)(pos, mousePos), ratio = 1 - pointDistance / distance; if (pointDistance <= distance) { if (ratio >= 0 && container.interactivity.status === external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.mouseMoveEvent) { this.hoverBubbleSize(particle, ratio); this.hoverBubbleOpacity(particle, ratio); this.hoverBubbleColor(particle, ratio); } } else { this.reset(particle); } if (container.interactivity.status === external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.mouseLeaveEvent) { this.reset(particle); } } } hoverBubbleColor(particle, ratio, divBubble) { const options = this.container.actualOptions; const bubbleOptions = divBubble !== null && divBubble !== void 0 ? divBubble : options.interactivity.modes.bubble; if (!bubbleOptions) { return; } if (!particle.bubble.finalColor) { const modeColor = bubbleOptions.color; if (!modeColor) { return; } const bubbleColor = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.itemFromSingleOrMultiple)(modeColor); particle.bubble.finalColor = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.rangeColorToHsl)(bubbleColor); } if (!particle.bubble.finalColor) { return; } if (bubbleOptions.mix) { particle.bubble.color = undefined; const pColor = particle.getFillColor(); particle.bubble.color = pColor ? (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.rgbToHsl)((0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.colorMix)(pColor, particle.bubble.finalColor, 1 - ratio, ratio)) : particle.bubble.finalColor; } else { particle.bubble.color = particle.bubble.finalColor; } } hoverBubbleOpacity(particle, ratio, divBubble) { var _a, _b, _c, _d; const container = this.container, options = container.actualOptions, modeOpacity = (_a = divBubble === null || divBubble === void 0 ? void 0 : divBubble.opacity) !== null && _a !== void 0 ? _a : (_b = options.interactivity.modes.bubble) === null || _b === void 0 ? void 0 : _b.opacity; if (!modeOpacity) { return; } const optOpacity = particle.options.opacity.value; const pOpacity = (_d = (_c = particle.opacity) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 1; const opacity = calculateBubbleValue(pOpacity, modeOpacity, (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeMax)(optOpacity), ratio); if (opacity !== undefined) { particle.bubble.opacity = opacity; } } hoverBubbleSize(particle, ratio, divBubble) { const container = this.container, modeSize = (divBubble === null || divBubble === void 0 ? void 0 : divBubble.size) ? divBubble.size * container.retina.pixelRatio : container.retina.bubbleModeSize; if (modeSize === undefined) { return; } const optSize = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeMax)(particle.options.size.value) * container.retina.pixelRatio; const pSize = particle.size.value; const size = calculateBubbleValue(pSize, modeSize, optSize, ratio); if (size !== undefined) { particle.bubble.radius = size; } } process(particle, distMouse, timeSpent, data) { const container = this.container, bubbleParam = data.bubbleObj.optValue, options = container.actualOptions, bubble = options.interactivity.modes.bubble; if (!bubble || bubbleParam === undefined) { return; } const bubbleDuration = bubble.duration, bubbleDistance = container.retina.bubbleModeDistance, particlesParam = data.particlesObj.optValue, pObjBubble = data.bubbleObj.value, pObj = data.particlesObj.value || 0, type = data.type; if (!bubbleDistance || bubbleDistance < 0 || bubbleParam === particlesParam) { return; } if (!container.bubble) { container.bubble = {}; } if (!container.bubble.durationEnd) { if (distMouse <= bubbleDistance) { const obj = pObjBubble !== null && pObjBubble !== void 0 ? pObjBubble : pObj; if (obj !== bubbleParam) { const value = pObj - timeSpent * (pObj - bubbleParam) / bubbleDuration; if (type === "size") { particle.bubble.radius = value; } if (type === "opacity") { particle.bubble.opacity = value; } } } else { if (type === "size") { delete particle.bubble.radius; } if (type === "opacity") { delete particle.bubble.opacity; } } } else if (pObjBubble) { if (type === "size") { delete particle.bubble.radius; } if (type === "opacity") { delete particle.bubble.opacity; } } } singleSelectorHover(delta, selector, div) { const container = this.container, selectors = document.querySelectorAll(selector), bubble = container.actualOptions.interactivity.modes.bubble; if (!bubble || !selectors.length) { return; } selectors.forEach(item => { const elem = item, pxRatio = container.retina.pixelRatio, pos = { x: (elem.offsetLeft + elem.offsetWidth / 2) * pxRatio, y: (elem.offsetTop + elem.offsetHeight / 2) * pxRatio }, repulseRadius = elem.offsetWidth / 2 * pxRatio, area = div.type === "circle" ? new external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.Circle(pos.x, pos.y, repulseRadius) : new external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.Rectangle(elem.offsetLeft * pxRatio, elem.offsetTop * pxRatio, elem.offsetWidth * pxRatio, elem.offsetHeight * pxRatio), query = container.particles.quadTree.query(area, p => this.isEnabled(p)); for (const particle of query) { if (!area.contains(particle.getPosition())) { continue; } particle.bubble.inRange = true; const divs = bubble.divs; const divBubble = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.divMode)(divs, elem); if (!particle.bubble.div || particle.bubble.div !== elem) { this.clear(particle, delta, true); particle.bubble.div = elem; } this.hoverBubbleSize(particle, 1, divBubble); this.hoverBubbleOpacity(particle, 1, divBubble); this.hoverBubbleColor(particle, 1, divBubble); } }); } } ;// CONCATENATED MODULE: ./dist/browser/index.js async function loadExternalBubbleInteraction(engine) { await engine.addInteractor("externalBubble", container => new Bubbler(container)); } })(); /******/ return __webpack_exports__; /******/ })() ; });