203 lines
7.4 KiB
JavaScript
203 lines
7.4 KiB
JavaScript
/*!
|
|
* 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__, {
|
|
"Trail": () => (/* reexport */ Trail),
|
|
"loadExternalTrailInteraction": () => (/* binding */ loadExternalTrailInteraction)
|
|
});
|
|
|
|
// 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/Trail.js
|
|
|
|
class Trail {
|
|
constructor() {
|
|
this.delay = 1;
|
|
this.pauseOnStop = false;
|
|
this.quantity = 1;
|
|
}
|
|
load(data) {
|
|
if (!data) {
|
|
return;
|
|
}
|
|
if (data.delay !== undefined) {
|
|
this.delay = data.delay;
|
|
}
|
|
if (data.quantity !== undefined) {
|
|
this.quantity = data.quantity;
|
|
}
|
|
if (data.particles !== undefined) {
|
|
this.particles = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.deepExtend)({}, data.particles);
|
|
}
|
|
if (data.pauseOnStop !== undefined) {
|
|
this.pauseOnStop = data.pauseOnStop;
|
|
}
|
|
}
|
|
}
|
|
;// CONCATENATED MODULE: ./dist/browser/TrailMaker.js
|
|
|
|
|
|
class TrailMaker extends external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.ExternalInteractorBase {
|
|
constructor(container) {
|
|
super(container);
|
|
this._delay = 0;
|
|
}
|
|
clear() {}
|
|
init() {}
|
|
async interact(delta) {
|
|
var _a, _b, _c, _d;
|
|
if (!this.container.retina.reduceFactor) {
|
|
return;
|
|
}
|
|
const container = this.container,
|
|
options = container.actualOptions,
|
|
trailOptions = options.interactivity.modes.trail;
|
|
if (!trailOptions) {
|
|
return;
|
|
}
|
|
const optDelay = trailOptions.delay * 1000 / this.container.retina.reduceFactor;
|
|
if (this._delay < optDelay) {
|
|
this._delay += delta.value;
|
|
}
|
|
if (this._delay < optDelay) {
|
|
return;
|
|
}
|
|
let canEmit = true;
|
|
if (trailOptions.pauseOnStop) {
|
|
if (container.interactivity.mouse.position === this._lastPosition || ((_a = container.interactivity.mouse.position) === null || _a === void 0 ? void 0 : _a.x) === ((_b = this._lastPosition) === null || _b === void 0 ? void 0 : _b.x) && ((_c = container.interactivity.mouse.position) === null || _c === void 0 ? void 0 : _c.y) === ((_d = this._lastPosition) === null || _d === void 0 ? void 0 : _d.y)) {
|
|
canEmit = false;
|
|
}
|
|
}
|
|
if (container.interactivity.mouse.position) {
|
|
this._lastPosition = {
|
|
x: container.interactivity.mouse.position.x,
|
|
y: container.interactivity.mouse.position.y
|
|
};
|
|
} else {
|
|
delete this._lastPosition;
|
|
}
|
|
if (canEmit) {
|
|
container.particles.push(trailOptions.quantity, container.interactivity.mouse, trailOptions.particles);
|
|
}
|
|
this._delay -= optDelay;
|
|
}
|
|
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;
|
|
return mouse.clicking && mouse.inside && !!mouse.position && (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("trail", events.onClick.mode) || mouse.inside && !!mouse.position && (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("trail", events.onHover.mode);
|
|
}
|
|
loadModeOptions(options, ...sources) {
|
|
if (!options.trail) {
|
|
options.trail = new Trail();
|
|
}
|
|
for (const source of sources) {
|
|
options.trail.load(source === null || source === void 0 ? void 0 : source.trail);
|
|
}
|
|
}
|
|
reset() {}
|
|
}
|
|
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
|
|
async function loadExternalTrailInteraction(engine) {
|
|
await engine.addInteractor("externalTrail", container => new TrailMaker(container));
|
|
}
|
|
|
|
|
|
})();
|
|
|
|
/******/ return __webpack_exports__;
|
|
/******/ })()
|
|
;
|
|
}); |