@tsparticles/ribbons 4.0.5
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/LICENSE +21 -0
- package/README.md +83 -0
- package/browser/IRibbonsOptions.js +1 -0
- package/browser/RibbonsOptions.js +138 -0
- package/browser/RibbonsParams.js +1 -0
- package/browser/browser.js +4 -0
- package/browser/bundle.js +5 -0
- package/browser/index.js +1 -0
- package/browser/index.lazy.js +1 -0
- package/browser/package.json +1 -0
- package/browser/ribbons.js +79 -0
- package/browser/ribbons.lazy.js +80 -0
- package/browser/types.js +1 -0
- package/browser/utils.js +195 -0
- package/cjs/IRibbonsOptions.js +1 -0
- package/cjs/RibbonsOptions.js +138 -0
- package/cjs/RibbonsParams.js +1 -0
- package/cjs/browser.js +4 -0
- package/cjs/bundle.js +5 -0
- package/cjs/index.js +1 -0
- package/cjs/index.lazy.js +1 -0
- package/cjs/package.json +1 -0
- package/cjs/ribbons.js +79 -0
- package/cjs/ribbons.lazy.js +80 -0
- package/cjs/types.js +1 -0
- package/cjs/utils.js +195 -0
- package/esm/IRibbonsOptions.js +1 -0
- package/esm/RibbonsOptions.js +138 -0
- package/esm/RibbonsParams.js +1 -0
- package/esm/browser.js +4 -0
- package/esm/bundle.js +5 -0
- package/esm/index.js +1 -0
- package/esm/index.lazy.js +1 -0
- package/esm/package.json +1 -0
- package/esm/ribbons.js +79 -0
- package/esm/ribbons.lazy.js +80 -0
- package/esm/types.js +1 -0
- package/esm/utils.js +195 -0
- package/package.json +88 -0
- package/report.html +4950 -0
- package/tsparticles.ribbons.bundle.js +8433 -0
- package/tsparticles.ribbons.bundle.min.js +1 -0
- package/tsparticles.ribbons.js +424 -0
- package/tsparticles.ribbons.min.js +1 -0
- package/types/IRibbonsOptions.d.ts +17 -0
- package/types/RibbonsOptions.d.ts +22 -0
- package/types/RibbonsParams.d.ts +7 -0
- package/types/browser.d.ts +1 -0
- package/types/bundle.d.ts +2 -0
- package/types/index.d.ts +5 -0
- package/types/index.lazy.d.ts +5 -0
- package/types/ribbons.d.ts +16 -0
- package/types/ribbons.lazy.d.ts +16 -0
- package/types/types.d.ts +4 -0
- package/types/utils.d.ts +7 -0
package/esm/ribbons.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { isString, tsParticles } from "@tsparticles/engine";
|
|
2
|
+
import { loadBasic } from "@tsparticles/basic";
|
|
3
|
+
import { loadEmittersPluginSimple } from "@tsparticles/plugin-emitters/plugin";
|
|
4
|
+
import { loadEmittersShapeSquare } from "@tsparticles/plugin-emitters-shape-square";
|
|
5
|
+
import { loadLifeUpdater } from "@tsparticles/updater-life";
|
|
6
|
+
import { loadMotionPlugin } from "@tsparticles/plugin-motion";
|
|
7
|
+
import { loadRibbonShape } from "@tsparticles/shape-ribbon";
|
|
8
|
+
import { setRibbons } from "./utils.js";
|
|
9
|
+
let initPromise = null;
|
|
10
|
+
async function doInitPlugins(engine) {
|
|
11
|
+
engine.checkVersion("4.0.5");
|
|
12
|
+
await engine.pluginManager.register(async (e) => {
|
|
13
|
+
const emittersRegister = async (engine) => {
|
|
14
|
+
await loadEmittersPluginSimple(engine);
|
|
15
|
+
await loadEmittersShapeSquare(engine);
|
|
16
|
+
};
|
|
17
|
+
await Promise.all([
|
|
18
|
+
loadBasic(e),
|
|
19
|
+
loadMotionPlugin(e),
|
|
20
|
+
emittersRegister(e),
|
|
21
|
+
loadRibbonShape(e),
|
|
22
|
+
loadLifeUpdater(e),
|
|
23
|
+
]);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async function initPlugins(engine) {
|
|
27
|
+
if (initPromise) {
|
|
28
|
+
return initPromise;
|
|
29
|
+
}
|
|
30
|
+
initPromise = doInitPlugins(engine);
|
|
31
|
+
return initPromise;
|
|
32
|
+
}
|
|
33
|
+
export async function ribbons(idOrOptions, ribbonsOptions) {
|
|
34
|
+
await initPlugins(tsParticles);
|
|
35
|
+
let options, id;
|
|
36
|
+
if (isString(idOrOptions)) {
|
|
37
|
+
id = idOrOptions;
|
|
38
|
+
options = ribbonsOptions ?? {};
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
id = "ribbons";
|
|
42
|
+
options = idOrOptions ?? {};
|
|
43
|
+
}
|
|
44
|
+
return setRibbons(tsParticles, {
|
|
45
|
+
id,
|
|
46
|
+
options,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
ribbons.create = async (canvas, options = {}) => {
|
|
50
|
+
await initPlugins(tsParticles);
|
|
51
|
+
const id = canvas?.getAttribute("id") ?? "ribbons";
|
|
52
|
+
canvas?.setAttribute("id", id);
|
|
53
|
+
await setRibbons(tsParticles, {
|
|
54
|
+
id,
|
|
55
|
+
canvas: canvas ?? undefined,
|
|
56
|
+
options,
|
|
57
|
+
});
|
|
58
|
+
return async (idOrOptions, subRibbonsOptions) => {
|
|
59
|
+
let subOptions, subId;
|
|
60
|
+
if (isString(idOrOptions)) {
|
|
61
|
+
subId = idOrOptions;
|
|
62
|
+
subOptions = subRibbonsOptions ?? options;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
subId = id;
|
|
66
|
+
subOptions = idOrOptions ?? {};
|
|
67
|
+
}
|
|
68
|
+
return setRibbons(tsParticles, {
|
|
69
|
+
id: subId,
|
|
70
|
+
canvas: canvas ?? undefined,
|
|
71
|
+
options: subOptions,
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
ribbons.init = async () => {
|
|
76
|
+
await initPlugins(tsParticles);
|
|
77
|
+
};
|
|
78
|
+
ribbons.version = "4.0.5";
|
|
79
|
+
globalThis.ribbons = ribbons;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { isString, tsParticles } from "@tsparticles/engine/lazy";
|
|
2
|
+
import { setRibbons } from "./utils.js";
|
|
3
|
+
let initPromise = null;
|
|
4
|
+
async function doInitPlugins(engine) {
|
|
5
|
+
engine.checkVersion("4.0.5");
|
|
6
|
+
await engine.pluginManager.register(async (e) => {
|
|
7
|
+
const [{ loadBasic }, { loadEmittersPluginSimple }, { loadEmittersShapeSquare }, { loadMotionPlugin }, { loadRibbonShape }, { loadLifeUpdater },] = await Promise.all([
|
|
8
|
+
import("@tsparticles/basic/lazy"),
|
|
9
|
+
import("@tsparticles/plugin-emitters/plugin/lazy"),
|
|
10
|
+
import("@tsparticles/plugin-emitters-shape-square/lazy"),
|
|
11
|
+
import("@tsparticles/plugin-motion/lazy"),
|
|
12
|
+
import("@tsparticles/shape-ribbon/lazy"),
|
|
13
|
+
import("@tsparticles/updater-life/lazy"),
|
|
14
|
+
]), emittersRegister = async (engine) => {
|
|
15
|
+
await loadEmittersPluginSimple(engine);
|
|
16
|
+
await loadEmittersShapeSquare(engine);
|
|
17
|
+
};
|
|
18
|
+
await Promise.all([
|
|
19
|
+
loadBasic(e),
|
|
20
|
+
loadMotionPlugin(e),
|
|
21
|
+
emittersRegister(e),
|
|
22
|
+
loadRibbonShape(e),
|
|
23
|
+
loadLifeUpdater(e),
|
|
24
|
+
]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async function initPlugins(engine) {
|
|
28
|
+
if (initPromise) {
|
|
29
|
+
return initPromise;
|
|
30
|
+
}
|
|
31
|
+
initPromise = doInitPlugins(engine);
|
|
32
|
+
return initPromise;
|
|
33
|
+
}
|
|
34
|
+
export async function ribbons(idOrOptions, ribbonsOptions) {
|
|
35
|
+
await initPlugins(tsParticles);
|
|
36
|
+
let options, id;
|
|
37
|
+
if (isString(idOrOptions)) {
|
|
38
|
+
id = idOrOptions;
|
|
39
|
+
options = ribbonsOptions ?? {};
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
id = "ribbons";
|
|
43
|
+
options = idOrOptions ?? {};
|
|
44
|
+
}
|
|
45
|
+
return setRibbons(tsParticles, {
|
|
46
|
+
id,
|
|
47
|
+
options,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
ribbons.create = async (canvas, options = {}) => {
|
|
51
|
+
await initPlugins(tsParticles);
|
|
52
|
+
const id = canvas?.getAttribute("id") ?? "ribbons";
|
|
53
|
+
canvas?.setAttribute("id", id);
|
|
54
|
+
await setRibbons(tsParticles, {
|
|
55
|
+
id,
|
|
56
|
+
canvas: canvas ?? undefined,
|
|
57
|
+
options,
|
|
58
|
+
});
|
|
59
|
+
return async (idOrOptions, subRibbonsOptions) => {
|
|
60
|
+
let subOptions, subId;
|
|
61
|
+
if (isString(idOrOptions)) {
|
|
62
|
+
subId = idOrOptions;
|
|
63
|
+
subOptions = subRibbonsOptions ?? options;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
subId = id;
|
|
67
|
+
subOptions = idOrOptions ?? {};
|
|
68
|
+
}
|
|
69
|
+
return setRibbons(tsParticles, {
|
|
70
|
+
id: subId,
|
|
71
|
+
canvas: canvas ?? undefined,
|
|
72
|
+
options: subOptions,
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
ribbons.init = async () => {
|
|
77
|
+
await initPlugins(tsParticles);
|
|
78
|
+
};
|
|
79
|
+
ribbons.version = "4.0.5";
|
|
80
|
+
globalThis.ribbons = ribbons;
|
package/esm/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/utils.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { RibbonsOptions } from "./RibbonsOptions.js";
|
|
2
|
+
const sizeFactor = 8, emitterTop = 0, ids = new Map();
|
|
3
|
+
export async function addEmitter(container, actualOptions) {
|
|
4
|
+
await container.addEmitter?.({
|
|
5
|
+
startCount: actualOptions.count,
|
|
6
|
+
position: {
|
|
7
|
+
x: actualOptions.position.x,
|
|
8
|
+
y: emitterTop,
|
|
9
|
+
},
|
|
10
|
+
shape: {
|
|
11
|
+
type: "square",
|
|
12
|
+
},
|
|
13
|
+
size: {
|
|
14
|
+
width: actualOptions.emitterSize.width,
|
|
15
|
+
height: actualOptions.emitterSize.height,
|
|
16
|
+
},
|
|
17
|
+
rate: {
|
|
18
|
+
delay: 0,
|
|
19
|
+
quantity: 0,
|
|
20
|
+
},
|
|
21
|
+
life: {
|
|
22
|
+
duration: 0.1,
|
|
23
|
+
count: 1,
|
|
24
|
+
},
|
|
25
|
+
particles: {
|
|
26
|
+
paint: {
|
|
27
|
+
fill: {
|
|
28
|
+
color: {
|
|
29
|
+
value: actualOptions.colors,
|
|
30
|
+
},
|
|
31
|
+
enable: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
shape: {
|
|
35
|
+
type: "ribbon",
|
|
36
|
+
options: {
|
|
37
|
+
ribbon: actualOptions.ribbonOptions,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
life: {
|
|
41
|
+
count: 1,
|
|
42
|
+
},
|
|
43
|
+
size: {
|
|
44
|
+
value: sizeFactor * actualOptions.scalar,
|
|
45
|
+
},
|
|
46
|
+
move: {
|
|
47
|
+
direction: "bottom",
|
|
48
|
+
enable: true,
|
|
49
|
+
outModes: {
|
|
50
|
+
top: "none",
|
|
51
|
+
default: "destroy",
|
|
52
|
+
},
|
|
53
|
+
speed: {
|
|
54
|
+
min: 4,
|
|
55
|
+
max: 6,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
roll: {
|
|
59
|
+
enable: false,
|
|
60
|
+
},
|
|
61
|
+
rotate: {
|
|
62
|
+
value: 0,
|
|
63
|
+
move: false,
|
|
64
|
+
animation: {
|
|
65
|
+
enable: false,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
tilt: {
|
|
69
|
+
enable: false,
|
|
70
|
+
},
|
|
71
|
+
wobble: {
|
|
72
|
+
enable: false,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
export function convertOptions(actualOptions, params) {
|
|
78
|
+
return {
|
|
79
|
+
fullScreen: {
|
|
80
|
+
enable: !params.canvas,
|
|
81
|
+
zIndex: actualOptions.zIndex,
|
|
82
|
+
},
|
|
83
|
+
fpsLimit: 120,
|
|
84
|
+
particles: {
|
|
85
|
+
number: {
|
|
86
|
+
value: 0,
|
|
87
|
+
},
|
|
88
|
+
paint: {
|
|
89
|
+
fill: {
|
|
90
|
+
color: {
|
|
91
|
+
value: actualOptions.colors,
|
|
92
|
+
},
|
|
93
|
+
enable: true,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
shape: {
|
|
97
|
+
type: "ribbon",
|
|
98
|
+
options: {
|
|
99
|
+
ribbon: actualOptions.ribbonOptions,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
size: {
|
|
103
|
+
value: sizeFactor * actualOptions.scalar,
|
|
104
|
+
},
|
|
105
|
+
links: {
|
|
106
|
+
enable: false,
|
|
107
|
+
},
|
|
108
|
+
life: {
|
|
109
|
+
count: 1,
|
|
110
|
+
},
|
|
111
|
+
move: {
|
|
112
|
+
direction: "bottom",
|
|
113
|
+
enable: true,
|
|
114
|
+
outModes: {
|
|
115
|
+
top: "none",
|
|
116
|
+
default: "destroy",
|
|
117
|
+
},
|
|
118
|
+
speed: {
|
|
119
|
+
min: 4,
|
|
120
|
+
max: 6,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
roll: {
|
|
124
|
+
enable: false,
|
|
125
|
+
},
|
|
126
|
+
rotate: {
|
|
127
|
+
value: 0,
|
|
128
|
+
move: false,
|
|
129
|
+
animation: {
|
|
130
|
+
enable: false,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
tilt: {
|
|
134
|
+
enable: false,
|
|
135
|
+
},
|
|
136
|
+
wobble: {
|
|
137
|
+
enable: false,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
motion: {
|
|
141
|
+
disable: actualOptions.disableForReducedMotion,
|
|
142
|
+
},
|
|
143
|
+
emitters: {
|
|
144
|
+
name: "ribbons",
|
|
145
|
+
startCount: actualOptions.count,
|
|
146
|
+
position: {
|
|
147
|
+
x: actualOptions.position.x,
|
|
148
|
+
y: emitterTop,
|
|
149
|
+
},
|
|
150
|
+
shape: {
|
|
151
|
+
type: "square",
|
|
152
|
+
},
|
|
153
|
+
size: {
|
|
154
|
+
width: actualOptions.emitterSize.width,
|
|
155
|
+
height: actualOptions.emitterSize.height,
|
|
156
|
+
},
|
|
157
|
+
rate: {
|
|
158
|
+
delay: 0,
|
|
159
|
+
quantity: 0,
|
|
160
|
+
},
|
|
161
|
+
life: {
|
|
162
|
+
duration: 0.1,
|
|
163
|
+
count: 1,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
export async function setRibbons(engine, params) {
|
|
169
|
+
const actualOptions = new RibbonsOptions();
|
|
170
|
+
actualOptions.load(params.options);
|
|
171
|
+
let containerOrPromise = ids.get(params.id);
|
|
172
|
+
if (containerOrPromise instanceof Promise) {
|
|
173
|
+
await containerOrPromise;
|
|
174
|
+
containerOrPromise = ids.get(params.id);
|
|
175
|
+
}
|
|
176
|
+
const container = containerOrPromise;
|
|
177
|
+
if (container && !container.destroyed) {
|
|
178
|
+
const alias = container;
|
|
179
|
+
if ("addEmitter" in alias) {
|
|
180
|
+
await addEmitter(alias, actualOptions);
|
|
181
|
+
return container;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const create = async () => {
|
|
185
|
+
const particlesOptions = convertOptions(actualOptions, params), newContainer = await engine.load({
|
|
186
|
+
id: params.id,
|
|
187
|
+
element: params.canvas,
|
|
188
|
+
options: particlesOptions,
|
|
189
|
+
});
|
|
190
|
+
ids.set(params.id, newContainer);
|
|
191
|
+
return newContainer;
|
|
192
|
+
}, createPromise = create();
|
|
193
|
+
ids.set(params.id, createPromise);
|
|
194
|
+
return createPromise;
|
|
195
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tsparticles/ribbons",
|
|
3
|
+
"version": "4.0.5",
|
|
4
|
+
"description": "Easily create ready to use animated ribbons effects.",
|
|
5
|
+
"homepage": "https://particles.js.org",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/tsparticles/tsparticles.git",
|
|
9
|
+
"directory": "bundles/ribbons"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"front-end",
|
|
13
|
+
"frontend",
|
|
14
|
+
"tsparticles",
|
|
15
|
+
"particles.js",
|
|
16
|
+
"particlesjs",
|
|
17
|
+
"particles",
|
|
18
|
+
"particle",
|
|
19
|
+
"canvas",
|
|
20
|
+
"typescript",
|
|
21
|
+
"javascript",
|
|
22
|
+
"animation",
|
|
23
|
+
"web",
|
|
24
|
+
"html5",
|
|
25
|
+
"animated",
|
|
26
|
+
"background",
|
|
27
|
+
"ribbon",
|
|
28
|
+
"ribbons",
|
|
29
|
+
"confetti",
|
|
30
|
+
"canvas-confetti"
|
|
31
|
+
],
|
|
32
|
+
"author": "Matteo Bruni <matteo.bruni@me.com>",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/tsparticles/tsparticles/issues"
|
|
36
|
+
},
|
|
37
|
+
"funding": [
|
|
38
|
+
{
|
|
39
|
+
"type": "github",
|
|
40
|
+
"url": "https://github.com/sponsors/matteobruni"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "github",
|
|
44
|
+
"url": "https://github.com/sponsors/tsparticles"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"type": "buymeacoffee",
|
|
48
|
+
"url": "https://www.buymeacoffee.com/matteobruni"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"sideEffects": false,
|
|
52
|
+
"jsdelivr": "tsparticles.ribbons.bundle.min.js",
|
|
53
|
+
"unpkg": "tsparticles.ribbons.bundle.min.js",
|
|
54
|
+
"browser": "browser/index.js",
|
|
55
|
+
"main": "cjs/index.js",
|
|
56
|
+
"module": "esm/index.js",
|
|
57
|
+
"types": "types/index.d.ts",
|
|
58
|
+
"exports": {
|
|
59
|
+
".": {
|
|
60
|
+
"types": "./types/index.d.ts",
|
|
61
|
+
"browser": "./browser/index.js",
|
|
62
|
+
"import": "./esm/index.js",
|
|
63
|
+
"require": "./cjs/index.js",
|
|
64
|
+
"default": "./esm/index.js"
|
|
65
|
+
},
|
|
66
|
+
"./lazy": {
|
|
67
|
+
"types": "./types/index.lazy.d.ts",
|
|
68
|
+
"browser": "./browser/index.lazy.js",
|
|
69
|
+
"import": "./esm/index.lazy.js",
|
|
70
|
+
"require": "./cjs/index.lazy.js",
|
|
71
|
+
"default": "./esm/index.lazy.js"
|
|
72
|
+
},
|
|
73
|
+
"./package.json": "./package.json"
|
|
74
|
+
},
|
|
75
|
+
"dependencies": {
|
|
76
|
+
"@tsparticles/basic": "4.0.5",
|
|
77
|
+
"@tsparticles/engine": "4.0.5",
|
|
78
|
+
"@tsparticles/plugin-emitters": "4.0.5",
|
|
79
|
+
"@tsparticles/plugin-emitters-shape-square": "4.0.5",
|
|
80
|
+
"@tsparticles/plugin-motion": "4.0.5",
|
|
81
|
+
"@tsparticles/shape-ribbon": "4.0.5",
|
|
82
|
+
"@tsparticles/updater-life": "4.0.5"
|
|
83
|
+
},
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public"
|
|
86
|
+
},
|
|
87
|
+
"type": "module"
|
|
88
|
+
}
|