@tsparticles/plugin-motion 4.0.0-alpha.0 → 4.0.0-alpha.14
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/222.min.js +1 -0
- package/493.min.js +1 -0
- package/browser/MotionPlugin.js +5 -7
- package/{esm/MotionInstance.js → browser/MotionPluginInstance.js} +19 -18
- package/browser/Options/Classes/Motion.js +2 -0
- package/browser/Options/Classes/MotionReduce.js +2 -0
- package/browser/index.js +3 -3
- package/cjs/MotionPlugin.js +5 -7
- package/{browser/MotionInstance.js → cjs/MotionPluginInstance.js} +19 -18
- package/cjs/Options/Classes/Motion.js +2 -0
- package/cjs/Options/Classes/MotionReduce.js +2 -0
- package/cjs/index.js +3 -3
- package/dist_browser_MotionPluginInstance_js.js +30 -0
- package/dist_browser_MotionPlugin_js.js +4 -14
- package/esm/MotionPlugin.js +5 -7
- package/{cjs/MotionInstance.js → esm/MotionPluginInstance.js} +19 -18
- package/esm/Options/Classes/Motion.js +2 -0
- package/esm/Options/Classes/MotionReduce.js +2 -0
- package/esm/index.js +3 -3
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.plugin.motion.js +2 -2
- package/tsparticles.plugin.motion.min.js +2 -2
- package/types/MotionPlugin.d.ts +4 -6
- package/types/{MotionInstance.d.ts → MotionPluginInstance.d.ts} +1 -1
- package/types/index.d.ts +1 -1
- package/umd/MotionPlugin.js +40 -8
- package/umd/{MotionInstance.js → MotionPluginInstance.js} +21 -20
- package/umd/Options/Classes/Motion.js +2 -0
- package/umd/Options/Classes/MotionReduce.js +2 -0
- package/umd/index.js +3 -3
- package/235.min.js +0 -2
- package/235.min.js.LICENSE.txt +0 -1
- package/tsparticles.plugin.motion.min.js.LICENSE.txt +0 -1
|
@@ -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.
|
|
7
|
+
* v4.0.0-alpha.14
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -34,7 +34,7 @@ return /******/ (() => { // webpackBootstrap
|
|
|
34
34
|
\*******************************/
|
|
35
35
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
36
36
|
|
|
37
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadMotionPlugin: () => (/* binding */ loadMotionPlugin)\n/* harmony export */ });\
|
|
37
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadMotionPlugin: () => (/* binding */ loadMotionPlugin)\n/* harmony export */ });\nasync function loadMotionPlugin(engine) {\n engine.checkVersion(\"4.0.0-alpha.14\");\n await engine.register(async (e)=>{\n const { MotionPlugin } = await __webpack_require__.e(/*! import() */ \"dist_browser_MotionPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./MotionPlugin.js */ \"./dist/browser/MotionPlugin.js\"));\n e.addPlugin(new MotionPlugin());\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-motion/./dist/browser/index.js?\n}");
|
|
38
38
|
|
|
39
39
|
/***/ },
|
|
40
40
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,e=>(()=>{"use strict";var t,r,o,i={303(t){t.exports=e}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return i[e](r,r.exports,a),r.exports}a.m=i,a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,r)=>(a.f[r](e,t),t),[])),a.u=e=>""+e+".min.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s={},a.l=(e,t,r,o)=>{if(s[e])return void s[e].push(t);if(void 0!==r)for(var i,n,l=document.getElementsByTagName("script"),c=0;c<l.length;c++){var p=l[c];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")=="@tsparticles/plugin-motion:"+r){i=p;break}}i||(n=!0,(i=document.createElement("script")).charset="utf-8",a.nc&&i.setAttribute("nonce",a.nc),i.setAttribute("data-webpack","@tsparticles/plugin-motion:"+r),i.src=e),s[e]=[t];var u=(t,r)=>{i.onerror=i.onload=null,clearTimeout(d);var o=s[e];if(delete s[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach(e=>e(r)),t)return t(r)},d=setTimeout(u.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=u.bind(null,i.onerror),i.onload=u.bind(null,i.onload),n&&document.head.appendChild(i)},a.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.g.importScripts&&(l=a.g.location+"");var s,l,c=a.g.document;if(!l&&c&&(c.currentScript&&"SCRIPT"===c.currentScript.tagName.toUpperCase()&&(l=c.currentScript.src),!l)){var p=c.getElementsByTagName("script");if(p.length)for(var u=p.length-1;u>-1&&(!l||!/^http(s?):/.test(l));)l=p[u--].src}if(!l)throw Error("Automatic publicPath is not supported in this browser");a.p=l=l.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),t={414:0},a.f.j=(e,r)=>{var o=a.o(t,e)?t[e]:void 0;if(0!==o)if(o)r.push(o[2]);else{var i=new Promise((r,i)=>o=t[e]=[r,i]);r.push(o[2]=i);var n=a.p+a.u(e),s=Error();a.l(n,r=>{if(a.o(t,e)&&(0!==(o=t[e])&&(t[e]=void 0),o)){var i=r&&("load"===r.type?"missing":r.type),n=r&&r.target&&r.target.src;s.message="Loading chunk "+e+` failed.
|
|
2
|
+
(`+i+": "+n+")",s.name="ChunkLoadError",s.type=i,s.request=n,o[1](s)}},"chunk-"+e,e)}},r=(e,r)=>{var o,i,[n,s,l]=r,c=0;if(n.some(e=>0!==t[e])){for(o in s)a.o(s,o)&&(a.m[o]=s[o]);l&&l(a)}for(e&&e(r);c<n.length;c++)i=n[c],a.o(t,i)&&t[i]&&t[i][0](),t[i]=0},(o=this.webpackChunk_tsparticles_plugin_motion=this.webpackChunk_tsparticles_plugin_motion||[]).forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o));var d={};async function f(e){e.checkVersion("4.0.0-alpha.14"),await e.register(async e=>{let{MotionPlugin:t}=await a.e(222).then(a.bind(a,222));e.addPlugin(new t)})}return a.r(d),a.d(d,{loadMotionPlugin:()=>f}),d})());
|
package/types/MotionPlugin.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { Container, IPlugin, RecursivePartial } from "@tsparticles/engine";
|
|
1
|
+
import type { Container, IContainerPlugin, IPlugin, RecursivePartial } from "@tsparticles/engine";
|
|
2
2
|
import type { IMotionOptions, MotionOptions } from "./types.js";
|
|
3
|
-
import { MotionInstance } from "./MotionInstance.js";
|
|
4
3
|
export declare class MotionPlugin implements IPlugin {
|
|
5
|
-
readonly id
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
loadOptions(options: MotionOptions, source?: RecursivePartial<IMotionOptions>): void;
|
|
4
|
+
readonly id = "motion";
|
|
5
|
+
getPlugin(container: Container): Promise<IContainerPlugin>;
|
|
6
|
+
loadOptions(_container: Container, options: MotionOptions, source?: RecursivePartial<IMotionOptions>): void;
|
|
9
7
|
needsPlugin(): boolean;
|
|
10
8
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type IContainerPlugin } from "@tsparticles/engine";
|
|
2
2
|
import type { MotionContainer } from "./types.js";
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class MotionPluginInstance implements IContainerPlugin {
|
|
4
4
|
private readonly _container;
|
|
5
5
|
constructor(container: MotionContainer);
|
|
6
6
|
init(): Promise<void>;
|
package/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type Engine } from "@tsparticles/engine";
|
|
2
|
-
export declare function loadMotionPlugin(engine: Engine): void
|
|
2
|
+
export declare function loadMotionPlugin(engine: Engine): Promise<void>;
|
package/umd/MotionPlugin.js
CHANGED
|
@@ -1,25 +1,57 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
18
|
+
var ownKeys = function(o) {
|
|
19
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
20
|
+
var ar = [];
|
|
21
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
22
|
+
return ar;
|
|
23
|
+
};
|
|
24
|
+
return ownKeys(o);
|
|
25
|
+
};
|
|
26
|
+
return function (mod) {
|
|
27
|
+
if (mod && mod.__esModule) return mod;
|
|
28
|
+
var result = {};
|
|
29
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
30
|
+
__setModuleDefault(result, mod);
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
1
34
|
(function (factory) {
|
|
2
35
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
36
|
var v = factory(require, exports);
|
|
4
37
|
if (v !== undefined) module.exports = v;
|
|
5
38
|
}
|
|
6
39
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Options/Classes/Motion.js"
|
|
40
|
+
define(["require", "exports", "./Options/Classes/Motion.js"], factory);
|
|
8
41
|
}
|
|
9
42
|
})(function (require, exports) {
|
|
10
43
|
"use strict";
|
|
44
|
+
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
11
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
46
|
exports.MotionPlugin = void 0;
|
|
13
47
|
const Motion_js_1 = require("./Options/Classes/Motion.js");
|
|
14
|
-
const MotionInstance_js_1 = require("./MotionInstance.js");
|
|
15
48
|
class MotionPlugin {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return Promise.resolve(new MotionInstance_js_1.MotionInstance(container));
|
|
49
|
+
id = "motion";
|
|
50
|
+
async getPlugin(container) {
|
|
51
|
+
const { MotionPluginInstance } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./MotionPluginInstance.js"))) : new Promise((resolve_1, reject_1) => { require(["./MotionPluginInstance.js"], resolve_1, reject_1); }).then(__importStar));
|
|
52
|
+
return new MotionPluginInstance(container);
|
|
21
53
|
}
|
|
22
|
-
loadOptions(options, source) {
|
|
54
|
+
loadOptions(_container, options, source) {
|
|
23
55
|
if (!this.needsPlugin()) {
|
|
24
56
|
return;
|
|
25
57
|
}
|
|
@@ -9,28 +9,12 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.MotionPluginInstance = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const defaultFactor = 1, defaultReduce = 1, disableReduce = 0, identity = 1;
|
|
15
|
-
class
|
|
15
|
+
class MotionPluginInstance {
|
|
16
|
+
_container;
|
|
16
17
|
constructor(container) {
|
|
17
|
-
this._handleMotionChange = mediaQuery => {
|
|
18
|
-
const container = this._container, motion = container.actualOptions.motion;
|
|
19
|
-
if (!motion) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (mediaQuery.matches) {
|
|
23
|
-
if (motion.disable) {
|
|
24
|
-
container.retina.reduceFactor = disableReduce;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
container.retina.reduceFactor = motion.reduce.value ? identity / motion.reduce.factor : defaultFactor;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
container.retina.reduceFactor = defaultReduce;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
18
|
this._container = container;
|
|
35
19
|
}
|
|
36
20
|
async init() {
|
|
@@ -58,6 +42,23 @@
|
|
|
58
42
|
mediaQuery.addEventListener("change", handleChange);
|
|
59
43
|
await Promise.resolve();
|
|
60
44
|
}
|
|
45
|
+
_handleMotionChange = mediaQuery => {
|
|
46
|
+
const container = this._container, motion = container.actualOptions.motion;
|
|
47
|
+
if (!motion) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (mediaQuery.matches) {
|
|
51
|
+
if (motion.disable) {
|
|
52
|
+
container.retina.reduceFactor = disableReduce;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
container.retina.reduceFactor = motion.reduce.value ? identity / motion.reduce.factor : defaultFactor;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
container.retina.reduceFactor = defaultReduce;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
61
62
|
}
|
|
62
|
-
exports.
|
|
63
|
+
exports.MotionPluginInstance = MotionPluginInstance;
|
|
63
64
|
});
|
package/umd/index.js
CHANGED
|
@@ -44,9 +44,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
44
44
|
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
46
|
exports.loadMotionPlugin = loadMotionPlugin;
|
|
47
|
-
function loadMotionPlugin(engine) {
|
|
48
|
-
engine.checkVersion("4.0.0-alpha.
|
|
49
|
-
engine.register(async (e) => {
|
|
47
|
+
async function loadMotionPlugin(engine) {
|
|
48
|
+
engine.checkVersion("4.0.0-alpha.14");
|
|
49
|
+
await engine.register(async (e) => {
|
|
50
50
|
const { MotionPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./MotionPlugin.js"))) : new Promise((resolve_1, reject_1) => { require(["./MotionPlugin.js"], resolve_1, reject_1); }).then(__importStar));
|
|
51
51
|
e.addPlugin(new MotionPlugin());
|
|
52
52
|
});
|
package/235.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 235.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_plugin_motion=this.webpackChunk_tsparticles_plugin_motion||[]).push([[235],{235(e,t,i){i.d(t,{MotionPlugin:()=>s});var a=i(303);class o{constructor(){this.factor=4,this.value=!0}load(e){(0,a.isNull)(e)||(void 0!==e.factor&&(this.factor=e.factor),void 0!==e.value&&(this.value=e.value))}}class n{constructor(){this.disable=!0,this.reduce=new o}load(e){(0,a.isNull)(e)||(void 0!==e.disable&&(this.disable=e.disable),this.reduce.load(e.reduce))}}class r{constructor(e){this._handleMotionChange=e=>{const t=this._container,i=t.actualOptions.motion;i&&(e.matches?i.disable?t.retina.reduceFactor=0:t.retina.reduceFactor=i.reduce.value?1/i.reduce.factor:1:t.retina.reduceFactor=1)},this._container=e}async init(){const e=this._container,t=e.actualOptions.motion;if(!t||!t.disable&&!t.reduce.value)return void(e.retina.reduceFactor=1);const i=(0,a.safeMatchMedia)("(prefers-reduced-motion: reduce)");if(!i)return void(e.retina.reduceFactor=1);this._handleMotionChange(i);i.addEventListener("change",(()=>{(async()=>{this._handleMotionChange(i);try{await e.refresh()}catch{}})()})),await Promise.resolve()}}class s{constructor(){this.id="motion"}getPlugin(e){return Promise.resolve(new r(e))}loadOptions(e,t){if(!this.needsPlugin())return;let i=e.motion;i?.load||(e.motion=i=new n),i.load(t?.motion)}needsPlugin(){return!0}}}}]);
|
package/235.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Motion Plugin v4.0.0-alpha.0 by Matteo Bruni */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Motion Plugin v4.0.0-alpha.0 by Matteo Bruni */
|