@tsparticles/plugin-motion 4.0.0-alpha.1 → 4.0.0-alpha.15

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 (34) hide show
  1. package/222.min.js +1 -0
  2. package/493.min.js +1 -0
  3. package/browser/MotionPlugin.js +5 -7
  4. package/{esm/MotionInstance.js → browser/MotionPluginInstance.js} +19 -18
  5. package/browser/Options/Classes/Motion.js +2 -0
  6. package/browser/Options/Classes/MotionReduce.js +2 -0
  7. package/browser/index.js +3 -3
  8. package/cjs/MotionPlugin.js +5 -7
  9. package/{browser/MotionInstance.js → cjs/MotionPluginInstance.js} +19 -18
  10. package/cjs/Options/Classes/Motion.js +2 -0
  11. package/cjs/Options/Classes/MotionReduce.js +2 -0
  12. package/cjs/index.js +3 -3
  13. package/dist_browser_MotionPluginInstance_js.js +30 -0
  14. package/dist_browser_MotionPlugin_js.js +4 -14
  15. package/esm/MotionPlugin.js +5 -7
  16. package/{cjs/MotionInstance.js → esm/MotionPluginInstance.js} +19 -18
  17. package/esm/Options/Classes/Motion.js +2 -0
  18. package/esm/Options/Classes/MotionReduce.js +2 -0
  19. package/esm/index.js +3 -3
  20. package/package.json +2 -2
  21. package/report.html +3 -3
  22. package/tsparticles.plugin.motion.js +2 -2
  23. package/tsparticles.plugin.motion.min.js +2 -2
  24. package/types/MotionPlugin.d.ts +4 -6
  25. package/types/{MotionInstance.d.ts → MotionPluginInstance.d.ts} +1 -1
  26. package/types/index.d.ts +1 -1
  27. package/umd/MotionPlugin.js +40 -8
  28. package/umd/{MotionInstance.js → MotionPluginInstance.js} +21 -20
  29. package/umd/Options/Classes/Motion.js +2 -0
  30. package/umd/Options/Classes/MotionReduce.js +2 -0
  31. package/umd/index.js +3 -3
  32. package/235.min.js +0 -2
  33. package/235.min.js.LICENSE.txt +0 -1
  34. package/tsparticles.plugin.motion.min.js.LICENSE.txt +0 -1
package/222.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_plugin_motion=this.webpackChunk_tsparticles_plugin_motion||[]).push([[222],{222(i,t,e){e.d(t,{MotionPlugin:()=>a});var s=e(303);class l{factor;value;constructor(){this.factor=4,this.value=!0}load(i){(0,s.isNull)(i)||(void 0!==i.factor&&(this.factor=i.factor),void 0!==i.value&&(this.value=i.value))}}class o{disable;reduce;constructor(){this.disable=!0,this.reduce=new l}load(i){(0,s.isNull)(i)||(void 0!==i.disable&&(this.disable=i.disable),this.reduce.load(i.reduce))}}class a{id="motion";async getPlugin(i){let{MotionPluginInstance:t}=await e.e(493).then(e.bind(e,493));return new t(i)}loadOptions(i,t,e){if(!this.needsPlugin())return;let s=t.motion;s?.load||(t.motion=s=new o),s.load(e?.motion)}needsPlugin(){return!0}}}}]);
package/493.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_plugin_motion=this.webpackChunk_tsparticles_plugin_motion||[]).push([[493],{493(e,t,a){a.d(t,{MotionPluginInstance:()=>i});var n=a(303);class i{_container;constructor(e){this._container=e}async init(){let e=this._container,t=e.actualOptions.motion;if(!(t&&(t.disable||t.reduce.value))){e.retina.reduceFactor=1;return}let a=(0,n.safeMatchMedia)("(prefers-reduced-motion: reduce)");if(!a){e.retina.reduceFactor=1;return}this._handleMotionChange(a);let i=()=>{(async()=>{this._handleMotionChange(a);try{await e.refresh()}catch{}})()};a.addEventListener("change",i),await Promise.resolve()}_handleMotionChange=e=>{let t=this._container,a=t.actualOptions.motion;a&&(e.matches?a.disable?t.retina.reduceFactor=0:t.retina.reduceFactor=a.reduce.value?1/a.reduce.factor:1:t.retina.reduceFactor=1)}}}}]);
@@ -1,13 +1,11 @@
1
1
  import { Motion } from "./Options/Classes/Motion.js";
2
- import { MotionInstance } from "./MotionInstance.js";
3
2
  export class MotionPlugin {
4
- constructor() {
5
- this.id = "motion";
3
+ id = "motion";
4
+ async getPlugin(container) {
5
+ const { MotionPluginInstance } = await import("./MotionPluginInstance.js");
6
+ return new MotionPluginInstance(container);
6
7
  }
7
- getPlugin(container) {
8
- return Promise.resolve(new MotionInstance(container));
9
- }
10
- loadOptions(options, source) {
8
+ loadOptions(_container, options, source) {
11
9
  if (!this.needsPlugin()) {
12
10
  return;
13
11
  }
@@ -1,24 +1,8 @@
1
1
  import { safeMatchMedia } from "@tsparticles/engine";
2
2
  const defaultFactor = 1, defaultReduce = 1, disableReduce = 0, identity = 1;
3
- export class MotionInstance {
3
+ export class MotionPluginInstance {
4
+ _container;
4
5
  constructor(container) {
5
- this._handleMotionChange = mediaQuery => {
6
- const container = this._container, motion = container.actualOptions.motion;
7
- if (!motion) {
8
- return;
9
- }
10
- if (mediaQuery.matches) {
11
- if (motion.disable) {
12
- container.retina.reduceFactor = disableReduce;
13
- }
14
- else {
15
- container.retina.reduceFactor = motion.reduce.value ? identity / motion.reduce.factor : defaultFactor;
16
- }
17
- }
18
- else {
19
- container.retina.reduceFactor = defaultReduce;
20
- }
21
- };
22
6
  this._container = container;
23
7
  }
24
8
  async init() {
@@ -46,4 +30,21 @@ export class MotionInstance {
46
30
  mediaQuery.addEventListener("change", handleChange);
47
31
  await Promise.resolve();
48
32
  }
33
+ _handleMotionChange = mediaQuery => {
34
+ const container = this._container, motion = container.actualOptions.motion;
35
+ if (!motion) {
36
+ return;
37
+ }
38
+ if (mediaQuery.matches) {
39
+ if (motion.disable) {
40
+ container.retina.reduceFactor = disableReduce;
41
+ }
42
+ else {
43
+ container.retina.reduceFactor = motion.reduce.value ? identity / motion.reduce.factor : defaultFactor;
44
+ }
45
+ }
46
+ else {
47
+ container.retina.reduceFactor = defaultReduce;
48
+ }
49
+ };
49
50
  }
@@ -1,6 +1,8 @@
1
1
  import { isNull } from "@tsparticles/engine";
2
2
  import { MotionReduce } from "./MotionReduce.js";
3
3
  export class Motion {
4
+ disable;
5
+ reduce;
4
6
  constructor() {
5
7
  this.disable = true;
6
8
  this.reduce = new MotionReduce();
@@ -1,5 +1,7 @@
1
1
  import { isNull } from "@tsparticles/engine";
2
2
  export class MotionReduce {
3
+ factor;
4
+ value;
3
5
  constructor() {
4
6
  this.factor = 4;
5
7
  this.value = true;
package/browser/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export function loadMotionPlugin(engine) {
2
- engine.checkVersion("4.0.0-alpha.1");
3
- engine.register(async (e) => {
1
+ export async function loadMotionPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.15");
3
+ await engine.register(async (e) => {
4
4
  const { MotionPlugin } = await import("./MotionPlugin.js");
5
5
  e.addPlugin(new MotionPlugin());
6
6
  });
@@ -1,13 +1,11 @@
1
1
  import { Motion } from "./Options/Classes/Motion.js";
2
- import { MotionInstance } from "./MotionInstance.js";
3
2
  export class MotionPlugin {
4
- constructor() {
5
- this.id = "motion";
3
+ id = "motion";
4
+ async getPlugin(container) {
5
+ const { MotionPluginInstance } = await import("./MotionPluginInstance.js");
6
+ return new MotionPluginInstance(container);
6
7
  }
7
- getPlugin(container) {
8
- return Promise.resolve(new MotionInstance(container));
9
- }
10
- loadOptions(options, source) {
8
+ loadOptions(_container, options, source) {
11
9
  if (!this.needsPlugin()) {
12
10
  return;
13
11
  }
@@ -1,24 +1,8 @@
1
1
  import { safeMatchMedia } from "@tsparticles/engine";
2
2
  const defaultFactor = 1, defaultReduce = 1, disableReduce = 0, identity = 1;
3
- export class MotionInstance {
3
+ export class MotionPluginInstance {
4
+ _container;
4
5
  constructor(container) {
5
- this._handleMotionChange = mediaQuery => {
6
- const container = this._container, motion = container.actualOptions.motion;
7
- if (!motion) {
8
- return;
9
- }
10
- if (mediaQuery.matches) {
11
- if (motion.disable) {
12
- container.retina.reduceFactor = disableReduce;
13
- }
14
- else {
15
- container.retina.reduceFactor = motion.reduce.value ? identity / motion.reduce.factor : defaultFactor;
16
- }
17
- }
18
- else {
19
- container.retina.reduceFactor = defaultReduce;
20
- }
21
- };
22
6
  this._container = container;
23
7
  }
24
8
  async init() {
@@ -46,4 +30,21 @@ export class MotionInstance {
46
30
  mediaQuery.addEventListener("change", handleChange);
47
31
  await Promise.resolve();
48
32
  }
33
+ _handleMotionChange = mediaQuery => {
34
+ const container = this._container, motion = container.actualOptions.motion;
35
+ if (!motion) {
36
+ return;
37
+ }
38
+ if (mediaQuery.matches) {
39
+ if (motion.disable) {
40
+ container.retina.reduceFactor = disableReduce;
41
+ }
42
+ else {
43
+ container.retina.reduceFactor = motion.reduce.value ? identity / motion.reduce.factor : defaultFactor;
44
+ }
45
+ }
46
+ else {
47
+ container.retina.reduceFactor = defaultReduce;
48
+ }
49
+ };
49
50
  }
@@ -1,6 +1,8 @@
1
1
  import { isNull } from "@tsparticles/engine";
2
2
  import { MotionReduce } from "./MotionReduce.js";
3
3
  export class Motion {
4
+ disable;
5
+ reduce;
4
6
  constructor() {
5
7
  this.disable = true;
6
8
  this.reduce = new MotionReduce();
@@ -1,5 +1,7 @@
1
1
  import { isNull } from "@tsparticles/engine";
2
2
  export class MotionReduce {
3
+ factor;
4
+ value;
3
5
  constructor() {
4
6
  this.factor = 4;
5
7
  this.value = true;
package/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export function loadMotionPlugin(engine) {
2
- engine.checkVersion("4.0.0-alpha.1");
3
- engine.register(async (e) => {
1
+ export async function loadMotionPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.15");
3
+ await engine.register(async (e) => {
4
4
  const { MotionPlugin } = await import("./MotionPlugin.js");
5
5
  e.addPlugin(new MotionPlugin());
6
6
  });
@@ -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.15
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_motion"] = this["webpackChunk_tsparticles_plugin_motion"] || []).push([["dist_browser_MotionPluginInstance_js"],{
19
+
20
+ /***/ "./dist/browser/MotionPluginInstance.js"
21
+ /*!**********************************************!*\
22
+ !*** ./dist/browser/MotionPluginInstance.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 */ MotionPluginInstance: () => (/* binding */ MotionPluginInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst defaultFactor = 1, defaultReduce = 1, disableReduce = 0, identity = 1;\nclass MotionPluginInstance {\n _container;\n constructor(container){\n this._container = container;\n }\n async init() {\n const container = this._container, options = container.actualOptions.motion;\n if (!(options && (options.disable || options.reduce.value))) {\n container.retina.reduceFactor = 1;\n return;\n }\n const mediaQuery = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.safeMatchMedia)(\"(prefers-reduced-motion: reduce)\");\n if (!mediaQuery) {\n container.retina.reduceFactor = defaultFactor;\n return;\n }\n this._handleMotionChange(mediaQuery);\n const handleChange = ()=>{\n void (async ()=>{\n this._handleMotionChange(mediaQuery);\n try {\n await container.refresh();\n } catch {}\n })();\n };\n mediaQuery.addEventListener(\"change\", handleChange);\n await Promise.resolve();\n }\n _handleMotionChange = (mediaQuery)=>{\n const container = this._container, motion = container.actualOptions.motion;\n if (!motion) {\n return;\n }\n if (mediaQuery.matches) {\n if (motion.disable) {\n container.retina.reduceFactor = disableReduce;\n } else {\n container.retina.reduceFactor = motion.reduce.value ? identity / motion.reduce.factor : defaultFactor;\n }\n } else {\n container.retina.reduceFactor = defaultReduce;\n }\n };\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-motion/./dist/browser/MotionPluginInstance.js?\n}");
27
+
28
+ /***/ }
29
+
30
+ }]);
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-alpha.1
7
+ * v4.0.0-alpha.15
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -17,23 +17,13 @@
17
17
  */
18
18
  (this["webpackChunk_tsparticles_plugin_motion"] = this["webpackChunk_tsparticles_plugin_motion"] || []).push([["dist_browser_MotionPlugin_js"],{
19
19
 
20
- /***/ "./dist/browser/MotionInstance.js"
21
- /*!****************************************!*\
22
- !*** ./dist/browser/MotionInstance.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 */ MotionInstance: () => (/* binding */ MotionInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst defaultFactor = 1,\n defaultReduce = 1,\n disableReduce = 0,\n identity = 1;\nclass MotionInstance {\n constructor(container) {\n this._handleMotionChange = mediaQuery => {\n const container = this._container,\n motion = container.actualOptions.motion;\n if (!motion) {\n return;\n }\n if (mediaQuery.matches) {\n if (motion.disable) {\n container.retina.reduceFactor = disableReduce;\n } else {\n container.retina.reduceFactor = motion.reduce.value ? identity / motion.reduce.factor : defaultFactor;\n }\n } else {\n container.retina.reduceFactor = defaultReduce;\n }\n };\n this._container = container;\n }\n async init() {\n const container = this._container,\n options = container.actualOptions.motion;\n if (!(options && (options.disable || options.reduce.value))) {\n container.retina.reduceFactor = 1;\n return;\n }\n const mediaQuery = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.safeMatchMedia)(\"(prefers-reduced-motion: reduce)\");\n if (!mediaQuery) {\n container.retina.reduceFactor = defaultFactor;\n return;\n }\n this._handleMotionChange(mediaQuery);\n const handleChange = () => {\n void (async () => {\n this._handleMotionChange(mediaQuery);\n try {\n await container.refresh();\n } catch {}\n })();\n };\n mediaQuery.addEventListener(\"change\", handleChange);\n await Promise.resolve();\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-motion/./dist/browser/MotionInstance.js?\n}");
27
-
28
- /***/ },
29
-
30
20
  /***/ "./dist/browser/MotionPlugin.js"
31
21
  /*!**************************************!*\
32
22
  !*** ./dist/browser/MotionPlugin.js ***!
33
23
  \**************************************/
34
24
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
35
25
 
36
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MotionPlugin: () => (/* binding */ MotionPlugin)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Motion_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Motion.js */ \"./dist/browser/Options/Classes/Motion.js\");\n/* harmony import */ var _MotionInstance_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./MotionInstance.js */ \"./dist/browser/MotionInstance.js\");\n\n\nclass MotionPlugin {\n constructor() {\n this.id = \"motion\";\n }\n getPlugin(container) {\n return Promise.resolve(new _MotionInstance_js__WEBPACK_IMPORTED_MODULE_1__.MotionInstance(container));\n }\n loadOptions(options, source) {\n if (!this.needsPlugin()) {\n return;\n }\n let motionOptions = options.motion;\n if (!motionOptions?.load) {\n options.motion = motionOptions = new _Options_Classes_Motion_js__WEBPACK_IMPORTED_MODULE_0__.Motion();\n }\n motionOptions.load(source?.motion);\n }\n needsPlugin() {\n return true;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-motion/./dist/browser/MotionPlugin.js?\n}");
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MotionPlugin: () => (/* binding */ MotionPlugin)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Motion_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Motion.js */ \"./dist/browser/Options/Classes/Motion.js\");\n\nclass MotionPlugin {\n id = \"motion\";\n async getPlugin(container) {\n const { MotionPluginInstance } = await __webpack_require__.e(/*! import() */ \"dist_browser_MotionPluginInstance_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./MotionPluginInstance.js */ \"./dist/browser/MotionPluginInstance.js\"));\n return new MotionPluginInstance(container);\n }\n loadOptions(_container, options, source) {\n if (!this.needsPlugin()) {\n return;\n }\n let motionOptions = options.motion;\n if (!motionOptions?.load) {\n options.motion = motionOptions = new _Options_Classes_Motion_js__WEBPACK_IMPORTED_MODULE_0__.Motion();\n }\n motionOptions.load(source?.motion);\n }\n needsPlugin() {\n return true;\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-motion/./dist/browser/MotionPlugin.js?\n}");
37
27
 
38
28
  /***/ },
39
29
 
@@ -43,7 +33,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
43
33
  \************************************************/
44
34
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
45
35
 
46
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Motion: () => (/* binding */ Motion)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _MotionReduce_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./MotionReduce.js */ \"./dist/browser/Options/Classes/MotionReduce.js\");\n\n\nclass Motion {\n constructor() {\n this.disable = true;\n this.reduce = new _MotionReduce_js__WEBPACK_IMPORTED_MODULE_1__.MotionReduce();\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.disable !== undefined) {\n this.disable = data.disable;\n }\n this.reduce.load(data.reduce);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-motion/./dist/browser/Options/Classes/Motion.js?\n}");
36
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Motion: () => (/* binding */ Motion)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _MotionReduce_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./MotionReduce.js */ \"./dist/browser/Options/Classes/MotionReduce.js\");\n\n\nclass Motion {\n disable;\n reduce;\n constructor(){\n this.disable = true;\n this.reduce = new _MotionReduce_js__WEBPACK_IMPORTED_MODULE_1__.MotionReduce();\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.disable !== undefined) {\n this.disable = data.disable;\n }\n this.reduce.load(data.reduce);\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-motion/./dist/browser/Options/Classes/Motion.js?\n}");
47
37
 
48
38
  /***/ },
49
39
 
@@ -53,7 +43,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
53
43
  \******************************************************/
54
44
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
55
45
 
56
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MotionReduce: () => (/* binding */ MotionReduce)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass MotionReduce {\n constructor() {\n this.factor = 4;\n this.value = true;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.factor !== undefined) {\n this.factor = data.factor;\n }\n if (data.value !== undefined) {\n this.value = data.value;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-motion/./dist/browser/Options/Classes/MotionReduce.js?\n}");
46
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MotionReduce: () => (/* binding */ MotionReduce)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass MotionReduce {\n factor;\n value;\n constructor(){\n this.factor = 4;\n this.value = true;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.factor !== undefined) {\n this.factor = data.factor;\n }\n if (data.value !== undefined) {\n this.value = data.value;\n }\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-motion/./dist/browser/Options/Classes/MotionReduce.js?\n}");
57
47
 
58
48
  /***/ }
59
49
 
@@ -1,13 +1,11 @@
1
1
  import { Motion } from "./Options/Classes/Motion.js";
2
- import { MotionInstance } from "./MotionInstance.js";
3
2
  export class MotionPlugin {
4
- constructor() {
5
- this.id = "motion";
3
+ id = "motion";
4
+ async getPlugin(container) {
5
+ const { MotionPluginInstance } = await import("./MotionPluginInstance.js");
6
+ return new MotionPluginInstance(container);
6
7
  }
7
- getPlugin(container) {
8
- return Promise.resolve(new MotionInstance(container));
9
- }
10
- loadOptions(options, source) {
8
+ loadOptions(_container, options, source) {
11
9
  if (!this.needsPlugin()) {
12
10
  return;
13
11
  }
@@ -1,24 +1,8 @@
1
1
  import { safeMatchMedia } from "@tsparticles/engine";
2
2
  const defaultFactor = 1, defaultReduce = 1, disableReduce = 0, identity = 1;
3
- export class MotionInstance {
3
+ export class MotionPluginInstance {
4
+ _container;
4
5
  constructor(container) {
5
- this._handleMotionChange = mediaQuery => {
6
- const container = this._container, motion = container.actualOptions.motion;
7
- if (!motion) {
8
- return;
9
- }
10
- if (mediaQuery.matches) {
11
- if (motion.disable) {
12
- container.retina.reduceFactor = disableReduce;
13
- }
14
- else {
15
- container.retina.reduceFactor = motion.reduce.value ? identity / motion.reduce.factor : defaultFactor;
16
- }
17
- }
18
- else {
19
- container.retina.reduceFactor = defaultReduce;
20
- }
21
- };
22
6
  this._container = container;
23
7
  }
24
8
  async init() {
@@ -46,4 +30,21 @@ export class MotionInstance {
46
30
  mediaQuery.addEventListener("change", handleChange);
47
31
  await Promise.resolve();
48
32
  }
33
+ _handleMotionChange = mediaQuery => {
34
+ const container = this._container, motion = container.actualOptions.motion;
35
+ if (!motion) {
36
+ return;
37
+ }
38
+ if (mediaQuery.matches) {
39
+ if (motion.disable) {
40
+ container.retina.reduceFactor = disableReduce;
41
+ }
42
+ else {
43
+ container.retina.reduceFactor = motion.reduce.value ? identity / motion.reduce.factor : defaultFactor;
44
+ }
45
+ }
46
+ else {
47
+ container.retina.reduceFactor = defaultReduce;
48
+ }
49
+ };
49
50
  }
@@ -1,6 +1,8 @@
1
1
  import { isNull } from "@tsparticles/engine";
2
2
  import { MotionReduce } from "./MotionReduce.js";
3
3
  export class Motion {
4
+ disable;
5
+ reduce;
4
6
  constructor() {
5
7
  this.disable = true;
6
8
  this.reduce = new MotionReduce();
@@ -1,5 +1,7 @@
1
1
  import { isNull } from "@tsparticles/engine";
2
2
  export class MotionReduce {
3
+ factor;
4
+ value;
3
5
  constructor() {
4
6
  this.factor = 4;
5
7
  this.value = true;
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export function loadMotionPlugin(engine) {
2
- engine.checkVersion("4.0.0-alpha.1");
3
- engine.register(async (e) => {
1
+ export async function loadMotionPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.15");
3
+ await engine.register(async (e) => {
4
4
  const { MotionPlugin } = await import("./MotionPlugin.js");
5
5
  e.addPlugin(new MotionPlugin());
6
6
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-motion",
3
- "version": "4.0.0-alpha.1",
3
+ "version": "4.0.0-alpha.15",
4
4
  "description": "tsParticles motion sickness plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -86,7 +86,7 @@
86
86
  "./package.json": "./package.json"
87
87
  },
88
88
  "dependencies": {
89
- "@tsparticles/engine": "4.0.0-alpha.1"
89
+ "@tsparticles/engine": "4.0.0-alpha.15"
90
90
  },
91
91
  "publishConfig": {
92
92
  "access": "public"