UNPKG

tsparticles

Version:

Easily create highly customizable particle, confetti and fireworks animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.

68 lines (67 loc) 3.36 kB
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "./Options/Classes/PolygonMask", "./PolygonMaskInstance", "../../Utils"], factory); } })(function (require, exports) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadPolygonMaskPlugin = void 0; const PolygonMask_1 = require("./Options/Classes/PolygonMask"); const PolygonMaskInstance_1 = require("./PolygonMaskInstance"); const Utils_1 = require("../../Utils"); class PolygonMaskPlugin { constructor() { this.id = "polygonMask"; } getPlugin(container) { return new PolygonMaskInstance_1.PolygonMaskInstance(container); } needsPlugin(options) { var _a, _b, _c; return ((_b = (_a = options === null || options === void 0 ? void 0 : options.polygon) === null || _a === void 0 ? void 0 : _a.enable) !== null && _b !== void 0 ? _b : (((_c = options === null || options === void 0 ? void 0 : options.polygon) === null || _c === void 0 ? void 0 : _c.type) !== undefined && options.polygon.type !== "none")); } loadOptions(options, source) { if (!this.needsPlugin(source)) { return; } const optionsCast = options; let polygonOptions = optionsCast.polygon; if ((polygonOptions === null || polygonOptions === void 0 ? void 0 : polygonOptions.load) === undefined) { optionsCast.polygon = polygonOptions = new PolygonMask_1.PolygonMask(); } polygonOptions.load(source === null || source === void 0 ? void 0 : source.polygon); } } async function loadPolygonMaskPlugin(engine) { if (!(0, Utils_1.isSsr)() && !("SVGPathSeg" in window)) { await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./pathseg"))) : new Promise((resolve_1, reject_1) => { require(["./pathseg"], resolve_1, reject_1); }).then(__importStar)); } const plugin = new PolygonMaskPlugin(); await engine.addPlugin(plugin); } exports.loadPolygonMaskPlugin = loadPolygonMaskPlugin; });