UNPKG

@tsparticles/interaction-external-push

Version:

tsParticles push external interaction

148 lines (135 loc) 10.7 kB
/*! * 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 * v3.7.1 */ /* * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). * This devtool is neither made for production nor for readable output files. * It uses "eval()" calls to create a separate source file in the browser devtools. * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) * or disable the default devtool with "devtool: false". * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). */ (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__tsparticles_engine__) => { return /******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ "./dist/browser/Options/Classes/Push.js": /*!**********************************************!*\ !*** ./dist/browser/Options/Classes/Push.js ***! \**********************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Push: () => (/* binding */ Push)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nclass Push {\n constructor() {\n this.default = true;\n this.groups = [];\n this.quantity = 4;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.default !== undefined) {\n this.default = data.default;\n }\n if (data.groups !== undefined) {\n this.groups = data.groups.map(t => t);\n }\n if (!this.groups.length) {\n this.default = true;\n }\n const quantity = data.quantity;\n if (quantity !== undefined) {\n this.quantity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(quantity);\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-push/./dist/browser/Options/Classes/Push.js?"); /***/ }), /***/ "./dist/browser/Pusher.js": /*!********************************!*\ !*** ./dist/browser/Pusher.js ***! \********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Pusher: () => (/* binding */ Pusher)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _Options_Classes_Push_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Push.js */ \"./dist/browser/Options/Classes/Push.js\");\n\n\nconst pushMode = \"push\",\n minQuantity = 0;\nclass Pusher extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ExternalInteractorBase {\n constructor(container) {\n super(container);\n this.handleClickMode = mode => {\n if (mode !== pushMode) {\n return;\n }\n const container = this.container,\n options = container.actualOptions,\n pushOptions = options.interactivity.modes.push;\n if (!pushOptions) {\n return;\n }\n const quantity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(pushOptions.quantity);\n if (quantity <= minQuantity) {\n return;\n }\n const group = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromArray)([undefined, ...pushOptions.groups]),\n groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined;\n void container.particles.push(quantity, container.interactivity.mouse, groupOptions, group);\n };\n }\n clear() {}\n init() {}\n interact() {}\n isEnabled() {\n return true;\n }\n loadModeOptions(options, ...sources) {\n if (!options.push) {\n options.push = new _Options_Classes_Push_js__WEBPACK_IMPORTED_MODULE_1__.Push();\n }\n for (const source of sources) {\n options.push.load(source?.push);\n }\n }\n reset() {}\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-push/./dist/browser/Pusher.js?"); /***/ }), /***/ "./dist/browser/index.js": /*!*******************************!*\ !*** ./dist/browser/index.js ***! \*******************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Push: () => (/* reexport safe */ _Options_Classes_Push_js__WEBPACK_IMPORTED_MODULE_2__.Push),\n/* harmony export */ loadExternalPushInteraction: () => (/* binding */ loadExternalPushInteraction)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _Pusher_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Pusher.js */ \"./dist/browser/Pusher.js\");\n/* harmony import */ var _Options_Classes_Push_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Options/Classes/Push.js */ \"./dist/browser/Options/Classes/Push.js\");\n\n\nasync function loadExternalPushInteraction(engine, refresh = true) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.assertValidVersion)(engine, \"3.7.1\");\n await engine.addInteractor(\"externalPush\", container => {\n return Promise.resolve(new _Pusher_js__WEBPACK_IMPORTED_MODULE_1__.Pusher(container));\n }, refresh);\n}\n\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-push/./dist/browser/index.js?"); /***/ }), /***/ "@tsparticles/engine": /*!*********************************************************************************************************************************!*\ !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***! \*********************************************************************************************************************************/ /***/ ((module) => { module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__; /***/ }) /******/ }); /************************************************************************/ /******/ // 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/compat get default export */ /******/ (() => { /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = (module) => { /******/ var getter = module && module.__esModule ? /******/ () => (module['default']) : /******/ () => (module); /******/ __webpack_require__.d(getter, { a: getter }); /******/ return getter; /******/ }; /******/ })(); /******/ /******/ /* 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 }); /******/ }; /******/ })(); /******/ /************************************************************************/ /******/ /******/ // startup /******/ // Load entry module and return exports /******/ // This entry module can't be inlined because the eval devtool is used. /******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js"); /******/ /******/ return __webpack_exports__; /******/ })() ; });