@tsparticles/plugin-responsive 4.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/48.min.js +2 -0
  2. package/48.min.js.LICENSE.txt +1 -0
  3. package/740.min.js +2 -0
  4. package/740.min.js.LICENSE.txt +1 -0
  5. package/LICENSE +21 -0
  6. package/README.md +74 -0
  7. package/browser/Options/Classes/Responsive.js +28 -0
  8. package/browser/Options/Interfaces/IResponsive.js +1 -0
  9. package/browser/ResponsiveMode.js +5 -0
  10. package/browser/ResponsivePlugin.js +37 -0
  11. package/browser/ResponsivePluginInstance.js +15 -0
  12. package/browser/index.js +7 -0
  13. package/browser/package.json +1 -0
  14. package/browser/types.js +1 -0
  15. package/cjs/Options/Classes/Responsive.js +28 -0
  16. package/cjs/Options/Interfaces/IResponsive.js +1 -0
  17. package/cjs/ResponsiveMode.js +5 -0
  18. package/cjs/ResponsivePlugin.js +37 -0
  19. package/cjs/ResponsivePluginInstance.js +15 -0
  20. package/cjs/index.js +7 -0
  21. package/cjs/package.json +1 -0
  22. package/cjs/types.js +1 -0
  23. package/dist_browser_ResponsivePluginInstance_js.js +30 -0
  24. package/dist_browser_ResponsivePlugin_js.js +50 -0
  25. package/esm/Options/Classes/Responsive.js +28 -0
  26. package/esm/Options/Interfaces/IResponsive.js +1 -0
  27. package/esm/ResponsiveMode.js +5 -0
  28. package/esm/ResponsivePlugin.js +37 -0
  29. package/esm/ResponsivePluginInstance.js +15 -0
  30. package/esm/index.js +7 -0
  31. package/esm/package.json +1 -0
  32. package/esm/types.js +1 -0
  33. package/package.json +95 -0
  34. package/report.html +40 -0
  35. package/tsparticles.plugin.responsive.js +305 -0
  36. package/tsparticles.plugin.responsive.min.js +2 -0
  37. package/tsparticles.plugin.responsive.min.js.LICENSE.txt +1 -0
  38. package/types/Options/Classes/Responsive.d.ts +10 -0
  39. package/types/Options/Interfaces/IResponsive.d.ts +7 -0
  40. package/types/ResponsiveMode.d.ts +4 -0
  41. package/types/ResponsivePlugin.d.ts +9 -0
  42. package/types/ResponsivePluginInstance.d.ts +7 -0
  43. package/types/index.d.ts +2 -0
  44. package/types/types.d.ts +14 -0
  45. package/umd/Options/Classes/Responsive.js +42 -0
  46. package/umd/Options/Interfaces/IResponsive.js +12 -0
  47. package/umd/ResponsiveMode.js +18 -0
  48. package/umd/ResponsivePlugin.js +85 -0
  49. package/umd/ResponsivePluginInstance.js +29 -0
  50. package/umd/index.js +54 -0
  51. package/umd/types.js +12 -0
package/48.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 48.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_plugin_responsive=this.webpackChunk_tsparticles_plugin_responsive||[]).push([[48],{48(s,e,i){i.d(e,{ResponsivePlugin:()=>a});var n,t=i(303);!function(s){s.screen="screen",s.canvas="canvas"}(n||(n={}));class o{constructor(){this.maxWidth=1/0,this.options={},this.mode=n.canvas}load(s){(0,t.isNull)(s)||((0,t.isNull)(s.maxWidth)||(this.maxWidth=s.maxWidth),(0,t.isNull)(s.mode)||(s.mode===n.screen?this.mode=n.screen:this.mode=n.canvas),(0,t.isNull)(s.options)||(this.options=(0,t.deepExtend)({},s.options)))}}class a{constructor(){this.id="responsive"}async getPlugin(s){const{ResponsivePluginInstance:e}=await i.e(740).then(i.bind(i,740));return new e(s)}loadOptions(s,e,i){if(!this.needsPlugin(e)&&!this.needsPlugin(i))return;if(e.setResponsive=(s,i,t)=>{e.load(t);const o=e.responsive?.find((e=>e.mode===n.screen?e.maxWidth>screen.availWidth:e.maxWidth*i>s));return e.load(o?.options),o?.maxWidth},e.responsive??=[],void 0!==i?.responsive)for(const s of i.responsive){const i=new o;s&&i.load(s),e.responsive.push(i)}e.responsive.sort(((s,e)=>s.maxWidth-e.maxWidth))}needsPlugin(s){return!!s?.responsive?.length}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Responsive Plugin v4.0.0-alpha.4 by Matteo Bruni */
package/740.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 740.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_plugin_responsive=this.webpackChunk_tsparticles_plugin_responsive||[]).push([[740],{740(s,t,i){i.d(t,{ResponsivePluginInstance:()=>n});class n{constructor(s){this._container=s}updateActualOptions(){const s=this._container;s.actualOptions.responsive=[];const t=s.actualOptions.setResponsive?.(s.canvas.size.width,s.retina.pixelRatio,s.options);return s.responsiveMaxWidth!==t&&(s.responsiveMaxWidth=t,!0)}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Responsive Plugin v4.0.0-alpha.4 by Matteo Bruni */
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Matteo Bruni
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ [![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org)
2
+
3
+ # tsParticles Responsive Plugin
4
+
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/plugin-responsive/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/plugin-responsive)
6
+ [![npmjs](https://badge.fury.io/js/@tsparticles/plugin-responsive.svg)](https://www.npmjs.com/package/@tsparticles/plugin-responsive)
7
+ [![npmjs](https://img.shields.io/npm/dt/@tsparticles/plugin-responsive)](https://www.npmjs.com/package/@tsparticles/plugin-responsive) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
+
9
+ [tsParticles](https://github.com/tsparticles/tsparticles) plugin for handling responsive feature.
10
+
11
+ ## How to use it
12
+
13
+ ### CDN / Vanilla JS / jQuery
14
+
15
+ The CDN/Vanilla version JS has one required file in vanilla configuration:
16
+
17
+ Including the `tsparticles.plugin.responsive.min.js` file will export the function to load the plugin:
18
+
19
+ ```javascript
20
+ loadResponsivePlugin;
21
+ ```
22
+
23
+ ### Usage
24
+
25
+ Once the scripts are loaded you can set up `tsParticles` and the plugin like this:
26
+
27
+ ```javascript
28
+ (async () => {
29
+ await loadResponsivePlugin(tsParticles);
30
+
31
+ await tsParticles.load({
32
+ id: "tsparticles",
33
+ options: {
34
+ /* options */
35
+ },
36
+ });
37
+ })();
38
+ ```
39
+
40
+ ### ESM / CommonJS
41
+
42
+ This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
43
+
44
+ ```shell
45
+ $ npm install @tsparticles/plugin-responsive
46
+ ```
47
+
48
+ or
49
+
50
+ ```shell
51
+ $ yarn add @tsparticles/plugin-responsive
52
+ ```
53
+
54
+ Then you need to import it in the app, like this:
55
+
56
+ ```javascript
57
+ const { tsParticles } = require("@tsparticles/engine");
58
+ const { loadResponsivePlugin } = require("@tsparticles/plugin-responsive");
59
+
60
+ (async () => {
61
+ await loadResponsivePlugin(tsParticles);
62
+ })();
63
+ ```
64
+
65
+ or
66
+
67
+ ```javascript
68
+ import { tsParticles } from "@tsparticles/engine";
69
+ import { loadResponsivePlugin } from "@tsparticles/plugin-responsive";
70
+
71
+ (async () => {
72
+ await loadResponsivePlugin(tsParticles);
73
+ })();
74
+ ```
@@ -0,0 +1,28 @@
1
+ import { deepExtend, isNull, } from "@tsparticles/engine";
2
+ import { ResponsiveMode } from "../../ResponsiveMode.js";
3
+ export class Responsive {
4
+ constructor() {
5
+ this.maxWidth = Infinity;
6
+ this.options = {};
7
+ this.mode = ResponsiveMode.canvas;
8
+ }
9
+ load(data) {
10
+ if (isNull(data)) {
11
+ return;
12
+ }
13
+ if (!isNull(data.maxWidth)) {
14
+ this.maxWidth = data.maxWidth;
15
+ }
16
+ if (!isNull(data.mode)) {
17
+ if (data.mode === ResponsiveMode.screen) {
18
+ this.mode = ResponsiveMode.screen;
19
+ }
20
+ else {
21
+ this.mode = ResponsiveMode.canvas;
22
+ }
23
+ }
24
+ if (!isNull(data.options)) {
25
+ this.options = deepExtend({}, data.options);
26
+ }
27
+ }
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export var ResponsiveMode;
2
+ (function (ResponsiveMode) {
3
+ ResponsiveMode["screen"] = "screen";
4
+ ResponsiveMode["canvas"] = "canvas";
5
+ })(ResponsiveMode || (ResponsiveMode = {}));
@@ -0,0 +1,37 @@
1
+ import { Responsive } from "./Options/Classes/Responsive.js";
2
+ import { ResponsiveMode } from "./ResponsiveMode.js";
3
+ export class ResponsivePlugin {
4
+ constructor() {
5
+ this.id = "responsive";
6
+ }
7
+ async getPlugin(container) {
8
+ const { ResponsivePluginInstance } = await import("./ResponsivePluginInstance.js");
9
+ return new ResponsivePluginInstance(container);
10
+ }
11
+ loadOptions(_container, options, source) {
12
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
13
+ return;
14
+ }
15
+ const setResponsive = (width, pxRatio, defaultOptions) => {
16
+ options.load(defaultOptions);
17
+ const responsiveOptions = options.responsive?.find(t => t.mode === ResponsiveMode.screen ? t.maxWidth > screen.availWidth : t.maxWidth * pxRatio > width);
18
+ options.load(responsiveOptions?.options);
19
+ return responsiveOptions?.maxWidth;
20
+ };
21
+ options.setResponsive = setResponsive;
22
+ options.responsive ??= [];
23
+ if (source?.responsive !== undefined) {
24
+ for (const responsive of source.responsive) {
25
+ const optResponsive = new Responsive();
26
+ if (responsive) {
27
+ optResponsive.load(responsive);
28
+ }
29
+ options.responsive.push(optResponsive);
30
+ }
31
+ }
32
+ options.responsive.sort((a, b) => a.maxWidth - b.maxWidth);
33
+ }
34
+ needsPlugin(options) {
35
+ return !!options?.responsive?.length;
36
+ }
37
+ }
@@ -0,0 +1,15 @@
1
+ export class ResponsivePluginInstance {
2
+ constructor(container) {
3
+ this._container = container;
4
+ }
5
+ updateActualOptions() {
6
+ const container = this._container;
7
+ container.actualOptions.responsive = [];
8
+ const newMaxWidth = container.actualOptions.setResponsive?.(container.canvas.size.width, container.retina.pixelRatio, container.options);
9
+ if (container.responsiveMaxWidth === newMaxWidth) {
10
+ return false;
11
+ }
12
+ container.responsiveMaxWidth = newMaxWidth;
13
+ return true;
14
+ }
15
+ }
@@ -0,0 +1,7 @@
1
+ export function loadResponsivePlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.4");
3
+ engine.register(async (e) => {
4
+ const { ResponsivePlugin } = await import("./ResponsivePlugin.js");
5
+ e.addPlugin(new ResponsivePlugin());
6
+ });
7
+ }
@@ -0,0 +1 @@
1
+ { "type": "module" }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
1
+ import { deepExtend, isNull, } from "@tsparticles/engine";
2
+ import { ResponsiveMode } from "../../ResponsiveMode.js";
3
+ export class Responsive {
4
+ constructor() {
5
+ this.maxWidth = Infinity;
6
+ this.options = {};
7
+ this.mode = ResponsiveMode.canvas;
8
+ }
9
+ load(data) {
10
+ if (isNull(data)) {
11
+ return;
12
+ }
13
+ if (!isNull(data.maxWidth)) {
14
+ this.maxWidth = data.maxWidth;
15
+ }
16
+ if (!isNull(data.mode)) {
17
+ if (data.mode === ResponsiveMode.screen) {
18
+ this.mode = ResponsiveMode.screen;
19
+ }
20
+ else {
21
+ this.mode = ResponsiveMode.canvas;
22
+ }
23
+ }
24
+ if (!isNull(data.options)) {
25
+ this.options = deepExtend({}, data.options);
26
+ }
27
+ }
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export var ResponsiveMode;
2
+ (function (ResponsiveMode) {
3
+ ResponsiveMode["screen"] = "screen";
4
+ ResponsiveMode["canvas"] = "canvas";
5
+ })(ResponsiveMode || (ResponsiveMode = {}));
@@ -0,0 +1,37 @@
1
+ import { Responsive } from "./Options/Classes/Responsive.js";
2
+ import { ResponsiveMode } from "./ResponsiveMode.js";
3
+ export class ResponsivePlugin {
4
+ constructor() {
5
+ this.id = "responsive";
6
+ }
7
+ async getPlugin(container) {
8
+ const { ResponsivePluginInstance } = await import("./ResponsivePluginInstance.js");
9
+ return new ResponsivePluginInstance(container);
10
+ }
11
+ loadOptions(_container, options, source) {
12
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
13
+ return;
14
+ }
15
+ const setResponsive = (width, pxRatio, defaultOptions) => {
16
+ options.load(defaultOptions);
17
+ const responsiveOptions = options.responsive?.find(t => t.mode === ResponsiveMode.screen ? t.maxWidth > screen.availWidth : t.maxWidth * pxRatio > width);
18
+ options.load(responsiveOptions?.options);
19
+ return responsiveOptions?.maxWidth;
20
+ };
21
+ options.setResponsive = setResponsive;
22
+ options.responsive ??= [];
23
+ if (source?.responsive !== undefined) {
24
+ for (const responsive of source.responsive) {
25
+ const optResponsive = new Responsive();
26
+ if (responsive) {
27
+ optResponsive.load(responsive);
28
+ }
29
+ options.responsive.push(optResponsive);
30
+ }
31
+ }
32
+ options.responsive.sort((a, b) => a.maxWidth - b.maxWidth);
33
+ }
34
+ needsPlugin(options) {
35
+ return !!options?.responsive?.length;
36
+ }
37
+ }
@@ -0,0 +1,15 @@
1
+ export class ResponsivePluginInstance {
2
+ constructor(container) {
3
+ this._container = container;
4
+ }
5
+ updateActualOptions() {
6
+ const container = this._container;
7
+ container.actualOptions.responsive = [];
8
+ const newMaxWidth = container.actualOptions.setResponsive?.(container.canvas.size.width, container.retina.pixelRatio, container.options);
9
+ if (container.responsiveMaxWidth === newMaxWidth) {
10
+ return false;
11
+ }
12
+ container.responsiveMaxWidth = newMaxWidth;
13
+ return true;
14
+ }
15
+ }
package/cjs/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export function loadResponsivePlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.4");
3
+ engine.register(async (e) => {
4
+ const { ResponsivePlugin } = await import("./ResponsivePlugin.js");
5
+ e.addPlugin(new ResponsivePlugin());
6
+ });
7
+ }
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
package/cjs/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v4.0.0-alpha.4
8
+ */
9
+ "use strict";
10
+ /*
11
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
12
+ * This devtool is neither made for production nor for readable output files.
13
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
14
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
15
+ * or disable the default devtool with "devtool: false".
16
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
17
+ */
18
+ (this["webpackChunk_tsparticles_plugin_responsive"] = this["webpackChunk_tsparticles_plugin_responsive"] || []).push([["dist_browser_ResponsivePluginInstance_js"],{
19
+
20
+ /***/ "./dist/browser/ResponsivePluginInstance.js"
21
+ /*!**************************************************!*\
22
+ !*** ./dist/browser/ResponsivePluginInstance.js ***!
23
+ \**************************************************/
24
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25
+
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ResponsivePluginInstance: () => (/* binding */ ResponsivePluginInstance)\n/* harmony export */ });\nclass ResponsivePluginInstance {\n constructor(container) {\n this._container = container;\n }\n updateActualOptions() {\n const container = this._container;\n container.actualOptions.responsive = [];\n const newMaxWidth = container.actualOptions.setResponsive?.(container.canvas.size.width, container.retina.pixelRatio, container.options);\n if (container.responsiveMaxWidth === newMaxWidth) {\n return false;\n }\n container.responsiveMaxWidth = newMaxWidth;\n return true;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-responsive/./dist/browser/ResponsivePluginInstance.js?\n}");
27
+
28
+ /***/ }
29
+
30
+ }]);
@@ -0,0 +1,50 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v4.0.0-alpha.4
8
+ */
9
+ "use strict";
10
+ /*
11
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
12
+ * This devtool is neither made for production nor for readable output files.
13
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
14
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
15
+ * or disable the default devtool with "devtool: false".
16
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
17
+ */
18
+ (this["webpackChunk_tsparticles_plugin_responsive"] = this["webpackChunk_tsparticles_plugin_responsive"] || []).push([["dist_browser_ResponsivePlugin_js"],{
19
+
20
+ /***/ "./dist/browser/Options/Classes/Responsive.js"
21
+ /*!****************************************************!*\
22
+ !*** ./dist/browser/Options/Classes/Responsive.js ***!
23
+ \****************************************************/
24
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25
+
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Responsive: () => (/* binding */ Responsive)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _ResponsiveMode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../ResponsiveMode.js */ \"./dist/browser/ResponsiveMode.js\");\n\n\nclass Responsive {\n constructor() {\n this.maxWidth = Infinity;\n this.options = {};\n this.mode = _ResponsiveMode_js__WEBPACK_IMPORTED_MODULE_1__.ResponsiveMode.canvas;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (!(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data.maxWidth)) {\n this.maxWidth = data.maxWidth;\n }\n if (!(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data.mode)) {\n if (data.mode === _ResponsiveMode_js__WEBPACK_IMPORTED_MODULE_1__.ResponsiveMode.screen) {\n this.mode = _ResponsiveMode_js__WEBPACK_IMPORTED_MODULE_1__.ResponsiveMode.screen;\n } else {\n this.mode = _ResponsiveMode_js__WEBPACK_IMPORTED_MODULE_1__.ResponsiveMode.canvas;\n }\n }\n if (!(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data.options)) {\n this.options = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.deepExtend)({}, data.options);\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-responsive/./dist/browser/Options/Classes/Responsive.js?\n}");
27
+
28
+ /***/ },
29
+
30
+ /***/ "./dist/browser/ResponsiveMode.js"
31
+ /*!****************************************!*\
32
+ !*** ./dist/browser/ResponsiveMode.js ***!
33
+ \****************************************/
34
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
35
+
36
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ResponsiveMode: () => (/* binding */ ResponsiveMode)\n/* harmony export */ });\nvar ResponsiveMode;\n(function (ResponsiveMode) {\n ResponsiveMode[\"screen\"] = \"screen\";\n ResponsiveMode[\"canvas\"] = \"canvas\";\n})(ResponsiveMode || (ResponsiveMode = {}));\n\n//# sourceURL=webpack://@tsparticles/plugin-responsive/./dist/browser/ResponsiveMode.js?\n}");
37
+
38
+ /***/ },
39
+
40
+ /***/ "./dist/browser/ResponsivePlugin.js"
41
+ /*!******************************************!*\
42
+ !*** ./dist/browser/ResponsivePlugin.js ***!
43
+ \******************************************/
44
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
45
+
46
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ResponsivePlugin: () => (/* binding */ ResponsivePlugin)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Responsive_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Responsive.js */ \"./dist/browser/Options/Classes/Responsive.js\");\n/* harmony import */ var _ResponsiveMode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ResponsiveMode.js */ \"./dist/browser/ResponsiveMode.js\");\n\n\nclass ResponsivePlugin {\n constructor() {\n this.id = \"responsive\";\n }\n async getPlugin(container) {\n const {\n ResponsivePluginInstance\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_ResponsivePluginInstance_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./ResponsivePluginInstance.js */ \"./dist/browser/ResponsivePluginInstance.js\"));\n return new ResponsivePluginInstance(container);\n }\n loadOptions(_container, options, source) {\n if (!this.needsPlugin(options) && !this.needsPlugin(source)) {\n return;\n }\n const setResponsive = (width, pxRatio, defaultOptions) => {\n options.load(defaultOptions);\n const responsiveOptions = options.responsive?.find(t => t.mode === _ResponsiveMode_js__WEBPACK_IMPORTED_MODULE_1__.ResponsiveMode.screen ? t.maxWidth > screen.availWidth : t.maxWidth * pxRatio > width);\n options.load(responsiveOptions?.options);\n return responsiveOptions?.maxWidth;\n };\n options.setResponsive = setResponsive;\n options.responsive ??= [];\n if (source?.responsive !== undefined) {\n for (const responsive of source.responsive) {\n const optResponsive = new _Options_Classes_Responsive_js__WEBPACK_IMPORTED_MODULE_0__.Responsive();\n if (responsive) {\n optResponsive.load(responsive);\n }\n options.responsive.push(optResponsive);\n }\n }\n options.responsive.sort((a, b) => a.maxWidth - b.maxWidth);\n }\n needsPlugin(options) {\n return !!options?.responsive?.length;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-responsive/./dist/browser/ResponsivePlugin.js?\n}");
47
+
48
+ /***/ }
49
+
50
+ }]);
@@ -0,0 +1,28 @@
1
+ import { deepExtend, isNull, } from "@tsparticles/engine";
2
+ import { ResponsiveMode } from "../../ResponsiveMode.js";
3
+ export class Responsive {
4
+ constructor() {
5
+ this.maxWidth = Infinity;
6
+ this.options = {};
7
+ this.mode = ResponsiveMode.canvas;
8
+ }
9
+ load(data) {
10
+ if (isNull(data)) {
11
+ return;
12
+ }
13
+ if (!isNull(data.maxWidth)) {
14
+ this.maxWidth = data.maxWidth;
15
+ }
16
+ if (!isNull(data.mode)) {
17
+ if (data.mode === ResponsiveMode.screen) {
18
+ this.mode = ResponsiveMode.screen;
19
+ }
20
+ else {
21
+ this.mode = ResponsiveMode.canvas;
22
+ }
23
+ }
24
+ if (!isNull(data.options)) {
25
+ this.options = deepExtend({}, data.options);
26
+ }
27
+ }
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export var ResponsiveMode;
2
+ (function (ResponsiveMode) {
3
+ ResponsiveMode["screen"] = "screen";
4
+ ResponsiveMode["canvas"] = "canvas";
5
+ })(ResponsiveMode || (ResponsiveMode = {}));
@@ -0,0 +1,37 @@
1
+ import { Responsive } from "./Options/Classes/Responsive.js";
2
+ import { ResponsiveMode } from "./ResponsiveMode.js";
3
+ export class ResponsivePlugin {
4
+ constructor() {
5
+ this.id = "responsive";
6
+ }
7
+ async getPlugin(container) {
8
+ const { ResponsivePluginInstance } = await import("./ResponsivePluginInstance.js");
9
+ return new ResponsivePluginInstance(container);
10
+ }
11
+ loadOptions(_container, options, source) {
12
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
13
+ return;
14
+ }
15
+ const setResponsive = (width, pxRatio, defaultOptions) => {
16
+ options.load(defaultOptions);
17
+ const responsiveOptions = options.responsive?.find(t => t.mode === ResponsiveMode.screen ? t.maxWidth > screen.availWidth : t.maxWidth * pxRatio > width);
18
+ options.load(responsiveOptions?.options);
19
+ return responsiveOptions?.maxWidth;
20
+ };
21
+ options.setResponsive = setResponsive;
22
+ options.responsive ??= [];
23
+ if (source?.responsive !== undefined) {
24
+ for (const responsive of source.responsive) {
25
+ const optResponsive = new Responsive();
26
+ if (responsive) {
27
+ optResponsive.load(responsive);
28
+ }
29
+ options.responsive.push(optResponsive);
30
+ }
31
+ }
32
+ options.responsive.sort((a, b) => a.maxWidth - b.maxWidth);
33
+ }
34
+ needsPlugin(options) {
35
+ return !!options?.responsive?.length;
36
+ }
37
+ }
@@ -0,0 +1,15 @@
1
+ export class ResponsivePluginInstance {
2
+ constructor(container) {
3
+ this._container = container;
4
+ }
5
+ updateActualOptions() {
6
+ const container = this._container;
7
+ container.actualOptions.responsive = [];
8
+ const newMaxWidth = container.actualOptions.setResponsive?.(container.canvas.size.width, container.retina.pixelRatio, container.options);
9
+ if (container.responsiveMaxWidth === newMaxWidth) {
10
+ return false;
11
+ }
12
+ container.responsiveMaxWidth = newMaxWidth;
13
+ return true;
14
+ }
15
+ }
package/esm/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export function loadResponsivePlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.4");
3
+ engine.register(async (e) => {
4
+ const { ResponsivePlugin } = await import("./ResponsivePlugin.js");
5
+ e.addPlugin(new ResponsivePlugin());
6
+ });
7
+ }
@@ -0,0 +1 @@
1
+ { "type": "module" }
package/esm/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@tsparticles/plugin-responsive",
3
+ "version": "4.0.0-alpha.4",
4
+ "description": "tsParticles responsive plugin",
5
+ "homepage": "https://particles.js.org",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/tsparticles/tsparticles.git",
9
+ "directory": "plugins/responsive"
10
+ },
11
+ "keywords": [
12
+ "front-end",
13
+ "frontend",
14
+ "tsparticles",
15
+ "particles.js",
16
+ "particlesjs",
17
+ "particles",
18
+ "particle",
19
+ "canvas",
20
+ "jsparticles",
21
+ "xparticles",
22
+ "particles-js",
23
+ "particles-bg",
24
+ "particles-bg-vue",
25
+ "particles-ts",
26
+ "particles.ts",
27
+ "react-particles-js",
28
+ "react-particles.js",
29
+ "react-particles",
30
+ "react",
31
+ "reactjs",
32
+ "vue-particles",
33
+ "ngx-particles",
34
+ "angular-particles",
35
+ "particleground",
36
+ "vue",
37
+ "vuejs",
38
+ "preact",
39
+ "preactjs",
40
+ "jquery",
41
+ "angularjs",
42
+ "angular",
43
+ "typescript",
44
+ "javascript",
45
+ "animation",
46
+ "web",
47
+ "html5",
48
+ "web-design",
49
+ "webdesign",
50
+ "css",
51
+ "html",
52
+ "css3",
53
+ "animated",
54
+ "background",
55
+ "confetti",
56
+ "canvas",
57
+ "fireworks",
58
+ "fireworks-js",
59
+ "confetti-js",
60
+ "confettijs",
61
+ "fireworksjs",
62
+ "canvas-confetti",
63
+ "tsparticles-plugin"
64
+ ],
65
+ "author": "Matteo Bruni <matteo.bruni@me.com>",
66
+ "license": "MIT",
67
+ "bugs": {
68
+ "url": "https://github.com/tsparticles/tsparticles/issues"
69
+ },
70
+ "sideEffects": false,
71
+ "jsdelivr": "tsparticles.plugin.responsive.min.js",
72
+ "unpkg": "tsparticles.plugin.responsive.min.js",
73
+ "browser": "browser/index.js",
74
+ "main": "cjs/index.js",
75
+ "module": "esm/index.js",
76
+ "types": "types/index.d.ts",
77
+ "exports": {
78
+ ".": {
79
+ "types": "./types/index.d.ts",
80
+ "browser": "./browser/index.js",
81
+ "import": "./esm/index.js",
82
+ "require": "./cjs/index.js",
83
+ "umd": "./umd/index.js",
84
+ "default": "./cjs/index.js"
85
+ },
86
+ "./package.json": "./package.json"
87
+ },
88
+ "dependencies": {
89
+ "@tsparticles/engine": "4.0.0-alpha.4"
90
+ },
91
+ "publishConfig": {
92
+ "access": "public"
93
+ },
94
+ "type": "module"
95
+ }