@tsparticles/plugin-motion 4.0.0-alpha.5 → 4.0.0-beta.0
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.
- package/423.min.js +1 -0
- package/766.min.js +1 -0
- package/browser/MotionPlugin.js +1 -3
- package/browser/MotionPluginInstance.js +18 -17
- package/browser/Options/Classes/Motion.js +2 -0
- package/browser/Options/Classes/MotionReduce.js +2 -0
- package/browser/index.js +1 -1
- package/cjs/MotionPlugin.js +1 -3
- package/cjs/MotionPluginInstance.js +18 -17
- package/cjs/Options/Classes/Motion.js +2 -0
- package/cjs/Options/Classes/MotionReduce.js +2 -0
- package/cjs/index.js +1 -1
- package/dist_browser_MotionPluginInstance_js.js +2 -2
- package/dist_browser_MotionPlugin_js.js +4 -4
- package/esm/MotionPlugin.js +1 -3
- package/esm/MotionPluginInstance.js +18 -17
- package/esm/Options/Classes/Motion.js +2 -0
- package/esm/Options/Classes/MotionReduce.js +2 -0
- package/esm/index.js +1 -1
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.plugin.motion.js +31 -19
- package/tsparticles.plugin.motion.min.js +2 -2
- package/types/MotionPlugin.d.ts +1 -2
- package/umd/MotionPlugin.js +1 -3
- package/umd/MotionPluginInstance.js +18 -17
- package/umd/Options/Classes/Motion.js +2 -0
- package/umd/Options/Classes/MotionReduce.js +2 -0
- package/umd/index.js +1 -1
- package/728.min.js +0 -2
- package/728.min.js.LICENSE.txt +0 -1
- package/802.min.js +0 -2
- package/802.min.js.LICENSE.txt +0 -1
- package/tsparticles.plugin.motion.min.js.LICENSE.txt +0 -1
package/423.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_motion=this.webpackChunk_tsparticles_plugin_motion||[]).push([[423],{423(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(766).then(e.bind(e,766));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/766.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_motion=this.webpackChunk_tsparticles_plugin_motion||[]).push([[766],{766(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)}}}}]);
|
package/browser/MotionPlugin.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Motion } from "./Options/Classes/Motion.js";
|
|
2
2
|
export class MotionPlugin {
|
|
3
|
-
|
|
4
|
-
this.id = "motion";
|
|
5
|
-
}
|
|
3
|
+
id = "motion";
|
|
6
4
|
async getPlugin(container) {
|
|
7
5
|
const { MotionPluginInstance } = await import("./MotionPluginInstance.js");
|
|
8
6
|
return new MotionPluginInstance(container);
|
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
import { safeMatchMedia } from "@tsparticles/engine";
|
|
2
2
|
const defaultFactor = 1, defaultReduce = 1, disableReduce = 0, identity = 1;
|
|
3
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 MotionPluginInstance {
|
|
|
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
|
}
|
package/browser/index.js
CHANGED
package/cjs/MotionPlugin.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Motion } from "./Options/Classes/Motion.js";
|
|
2
2
|
export class MotionPlugin {
|
|
3
|
-
|
|
4
|
-
this.id = "motion";
|
|
5
|
-
}
|
|
3
|
+
id = "motion";
|
|
6
4
|
async getPlugin(container) {
|
|
7
5
|
const { MotionPluginInstance } = await import("./MotionPluginInstance.js");
|
|
8
6
|
return new MotionPluginInstance(container);
|
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
import { safeMatchMedia } from "@tsparticles/engine";
|
|
2
2
|
const defaultFactor = 1, defaultReduce = 1, disableReduce = 0, identity = 1;
|
|
3
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 MotionPluginInstance {
|
|
|
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
|
}
|
package/cjs/index.js
CHANGED
|
@@ -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-
|
|
7
|
+
* v4.0.0-beta.0
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\**********************************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
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
|
|
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
27
|
|
|
28
28
|
/***/ }
|
|
29
29
|
|
|
@@ -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-
|
|
7
|
+
* v4.0.0-beta.0
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\**************************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
25
|
|
|
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
|
|
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}");
|
|
27
27
|
|
|
28
28
|
/***/ },
|
|
29
29
|
|
|
@@ -33,7 +33,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
33
33
|
\************************************************/
|
|
34
34
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
35
|
|
|
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
|
|
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}");
|
|
37
37
|
|
|
38
38
|
/***/ },
|
|
39
39
|
|
|
@@ -43,7 +43,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
43
43
|
\******************************************************/
|
|
44
44
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
45
|
|
|
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
|
|
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}");
|
|
47
47
|
|
|
48
48
|
/***/ }
|
|
49
49
|
|
package/esm/MotionPlugin.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Motion } from "./Options/Classes/Motion.js";
|
|
2
2
|
export class MotionPlugin {
|
|
3
|
-
|
|
4
|
-
this.id = "motion";
|
|
5
|
-
}
|
|
3
|
+
id = "motion";
|
|
6
4
|
async getPlugin(container) {
|
|
7
5
|
const { MotionPluginInstance } = await import("./MotionPluginInstance.js");
|
|
8
6
|
return new MotionPluginInstance(container);
|
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
import { safeMatchMedia } from "@tsparticles/engine";
|
|
2
2
|
const defaultFactor = 1, defaultReduce = 1, disableReduce = 0, identity = 1;
|
|
3
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 MotionPluginInstance {
|
|
|
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
|
}
|
package/esm/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/plugin-motion",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
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-
|
|
89
|
+
"@tsparticles/engine": "4.0.0-beta.0"
|
|
90
90
|
},
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|