@tsparticles/updater-opacity 3.0.0-alpha.0 → 3.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/README.md +16 -12
- package/browser/OpacityUpdater.js +6 -64
- package/browser/Utils.js +64 -0
- package/browser/index.js +2 -2
- package/cjs/OpacityUpdater.js +6 -64
- package/cjs/Utils.js +68 -0
- package/cjs/index.js +2 -13
- package/esm/OpacityUpdater.js +6 -64
- package/esm/Utils.js +64 -0
- package/esm/index.js +2 -2
- package/package.json +6 -5
- package/report.html +4 -4
- package/tsparticles.updater.opacity.js +39 -30
- package/tsparticles.updater.opacity.min.js +1 -1
- package/tsparticles.updater.opacity.min.js.LICENSE.txt +1 -8
- package/types/OpacityUpdater.d.ts +1 -1
- package/types/Utils.d.ts +2 -0
- package/types/index.d.ts +1 -1
- package/umd/OpacityUpdater.js +7 -65
- package/umd/Utils.js +78 -0
- package/umd/index.js +2 -2
|
@@ -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
|
-
* v3.0.0-
|
|
7
|
+
* v3.0.0-beta.0
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -91,12 +91,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
91
91
|
|
|
92
92
|
// EXPORTS
|
|
93
93
|
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
-
|
|
94
|
+
loadOpacityUpdater: () => (/* binding */ loadOpacityUpdater)
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
98
98
|
var engine_root_window_ = __webpack_require__(533);
|
|
99
|
-
;// CONCATENATED MODULE: ./dist/browser/
|
|
99
|
+
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
100
100
|
|
|
101
101
|
function checkDestroy(particle, value, minValue, maxValue) {
|
|
102
102
|
switch (particle.options.opacity.animation.destroy) {
|
|
@@ -113,48 +113,57 @@ function checkDestroy(particle, value, minValue, maxValue) {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
function updateOpacity(particle, delta) {
|
|
116
|
-
|
|
117
|
-
if (
|
|
116
|
+
const data = particle.opacity;
|
|
117
|
+
if (particle.destroyed || !data?.enable || (data.maxLoops ?? 0) > 0 && (data.loops ?? 0) > (data.maxLoops ?? 0)) {
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
|
-
const minValue =
|
|
121
|
-
maxValue =
|
|
122
|
-
decay =
|
|
123
|
-
if (
|
|
120
|
+
const minValue = data.min,
|
|
121
|
+
maxValue = data.max,
|
|
122
|
+
decay = data.decay ?? 1;
|
|
123
|
+
if (!data.time) {
|
|
124
|
+
data.time = 0;
|
|
125
|
+
}
|
|
126
|
+
if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
|
|
127
|
+
data.time += delta.value;
|
|
128
|
+
}
|
|
129
|
+
if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
|
|
124
130
|
return;
|
|
125
131
|
}
|
|
126
|
-
switch (
|
|
132
|
+
switch (data.status) {
|
|
127
133
|
case "increasing":
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
if (!
|
|
131
|
-
|
|
134
|
+
if (data.value >= maxValue) {
|
|
135
|
+
data.status = "decreasing";
|
|
136
|
+
if (!data.loops) {
|
|
137
|
+
data.loops = 0;
|
|
132
138
|
}
|
|
133
|
-
|
|
139
|
+
data.loops++;
|
|
134
140
|
} else {
|
|
135
|
-
|
|
141
|
+
data.value += (data.velocity ?? 0) * delta.factor;
|
|
136
142
|
}
|
|
137
143
|
break;
|
|
138
144
|
case "decreasing":
|
|
139
|
-
if (
|
|
140
|
-
|
|
141
|
-
if (!
|
|
142
|
-
|
|
145
|
+
if (data.value <= minValue) {
|
|
146
|
+
data.status = "increasing";
|
|
147
|
+
if (!data.loops) {
|
|
148
|
+
data.loops = 0;
|
|
143
149
|
}
|
|
144
|
-
|
|
150
|
+
data.loops++;
|
|
145
151
|
} else {
|
|
146
|
-
|
|
152
|
+
data.value -= (data.velocity ?? 0) * delta.factor;
|
|
147
153
|
}
|
|
148
154
|
break;
|
|
149
155
|
}
|
|
150
|
-
if (
|
|
151
|
-
|
|
156
|
+
if (data.velocity && data.decay !== 1) {
|
|
157
|
+
data.velocity *= decay;
|
|
152
158
|
}
|
|
153
|
-
checkDestroy(particle,
|
|
159
|
+
checkDestroy(particle, data.value, minValue, maxValue);
|
|
154
160
|
if (!particle.destroyed) {
|
|
155
|
-
|
|
161
|
+
data.value = (0,engine_root_window_.clamp)(data.value, minValue, maxValue);
|
|
156
162
|
}
|
|
157
163
|
}
|
|
164
|
+
;// CONCATENATED MODULE: ./dist/browser/OpacityUpdater.js
|
|
165
|
+
|
|
166
|
+
|
|
158
167
|
class OpacityUpdater {
|
|
159
168
|
constructor(container) {
|
|
160
169
|
this.container = container;
|
|
@@ -171,11 +180,11 @@ class OpacityUpdater {
|
|
|
171
180
|
}
|
|
172
181
|
}
|
|
173
182
|
isEnabled(particle) {
|
|
174
|
-
|
|
175
|
-
return !particle.destroyed && !particle.spawning && !!particle.opacity && particle.opacity.enable && (((_a = particle.opacity.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 || ((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0));
|
|
183
|
+
return !particle.destroyed && !particle.spawning && !!particle.opacity && particle.opacity.enable && ((particle.opacity.maxLoops ?? 0) <= 0 || (particle.opacity.maxLoops ?? 0) > 0 && (particle.opacity.loops ?? 0) < (particle.opacity.maxLoops ?? 0));
|
|
176
184
|
}
|
|
177
185
|
reset(particle) {
|
|
178
186
|
if (particle.opacity) {
|
|
187
|
+
particle.opacity.time = 0;
|
|
179
188
|
particle.opacity.loops = 0;
|
|
180
189
|
}
|
|
181
190
|
}
|
|
@@ -188,8 +197,8 @@ class OpacityUpdater {
|
|
|
188
197
|
}
|
|
189
198
|
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
190
199
|
|
|
191
|
-
async function loadOpacityUpdater(engine) {
|
|
192
|
-
await engine.addParticleUpdater("opacity", container => new OpacityUpdater(container));
|
|
200
|
+
async function loadOpacityUpdater(engine, refresh = true) {
|
|
201
|
+
await engine.addParticleUpdater("opacity", container => new OpacityUpdater(container), refresh);
|
|
193
202
|
}
|
|
194
203
|
})();
|
|
195
204
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.updater.opacity.min.js.LICENSE.txt */
|
|
2
|
-
!function(
|
|
2
|
+
!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 o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var a in o)("object"==typeof exports?exports:e)[a]=o[a]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function a(e){var i=o[e];if(void 0!==i)return i.exports;var r=o[e]={exports:{}};return t[e](r,r.exports,a),r.exports}a.d=(e,t)=>{for(var o in t)a.o(t,o)&&!a.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{a.r(i),a.d(i,{loadOpacityUpdater:()=>o});var e=a(533);class t{constructor(e){this.container=e}init(t){const o=t.options.opacity;t.opacity=(0,e.initParticleNumericAnimationValue)(o,1);const a=o.animation;a.enable&&(t.opacity.velocity=(0,e.getRangeValue)(a.speed)/100*this.container.retina.reduceFactor,a.sync||(t.opacity.velocity*=(0,e.getRandom)()))}isEnabled(e){return!e.destroyed&&!e.spawning&&!!e.opacity&&e.opacity.enable&&((e.opacity.maxLoops??0)<=0||(e.opacity.maxLoops??0)>0&&(e.opacity.loops??0)<(e.opacity.maxLoops??0))}reset(e){e.opacity&&(e.opacity.time=0,e.opacity.loops=0)}update(t,o){this.isEnabled(t)&&function(t,o){const a=t.opacity;if(t.destroyed||!a?.enable||(a.maxLoops??0)>0&&(a.loops??0)>(a.maxLoops??0))return;const i=a.min,r=a.max,n=a.decay??1;if(a.time||(a.time=0),(a.delayTime??0)>0&&a.time<(a.delayTime??0)&&(a.time+=o.value),!((a.delayTime??0)>0&&a.time<(a.delayTime??0))){switch(a.status){case"increasing":a.value>=r?(a.status="decreasing",a.loops||(a.loops=0),a.loops++):a.value+=(a.velocity??0)*o.factor;break;case"decreasing":a.value<=i?(a.status="increasing",a.loops||(a.loops=0),a.loops++):a.value-=(a.velocity??0)*o.factor}a.velocity&&1!==a.decay&&(a.velocity*=n),function(e,t,o,a){switch(e.options.opacity.animation.destroy){case"max":t>=a&&e.destroy();break;case"min":t<=o&&e.destroy()}}(t,a.value,i,r),t.destroyed||(a.value=(0,e.clamp)(a.value,i,r))}}(t,o)}}async function o(e,o=!0){await e.addParticleUpdater("opacity",(e=>new t(e)),o)}})(),i})()));
|
|
@@ -1,8 +1 @@
|
|
|
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
|
-
* v3.0.0-alpha.0
|
|
8
|
-
*/
|
|
1
|
+
/*! tsParticles Opacity Updater v3.0.0-beta.0 by Matteo Bruni */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Container, type IDelta, type IParticleUpdater, type Particle } from "@tsparticles/engine";
|
|
2
2
|
export declare class OpacityUpdater implements IParticleUpdater {
|
|
3
3
|
private readonly container;
|
|
4
4
|
constructor(container: Container);
|
package/types/Utils.d.ts
ADDED
package/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Engine } from "@tsparticles/engine";
|
|
2
|
-
export declare function loadOpacityUpdater(engine: Engine): Promise<void>;
|
|
2
|
+
export declare function loadOpacityUpdater(engine: Engine, refresh?: boolean): Promise<void>;
|
package/umd/OpacityUpdater.js
CHANGED
|
@@ -4,72 +4,14 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Utils"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.OpacityUpdater = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
|
|
15
|
-
switch (particle.options.opacity.animation.destroy) {
|
|
16
|
-
case "max":
|
|
17
|
-
if (value >= maxValue) {
|
|
18
|
-
particle.destroy();
|
|
19
|
-
}
|
|
20
|
-
break;
|
|
21
|
-
case "min":
|
|
22
|
-
if (value <= minValue) {
|
|
23
|
-
particle.destroy();
|
|
24
|
-
}
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function updateOpacity(particle, delta) {
|
|
29
|
-
var _a, _b, _c, _d, _e, _f;
|
|
30
|
-
if (!particle.opacity) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const minValue = particle.opacity.min, maxValue = particle.opacity.max, decay = (_a = particle.opacity.decay) !== null && _a !== void 0 ? _a : 1;
|
|
34
|
-
if (particle.destroyed ||
|
|
35
|
-
!particle.opacity.enable ||
|
|
36
|
-
(((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) > ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0))) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
switch (particle.opacity.status) {
|
|
40
|
-
case "increasing":
|
|
41
|
-
if (particle.opacity.value >= maxValue) {
|
|
42
|
-
particle.opacity.status = "decreasing";
|
|
43
|
-
if (!particle.opacity.loops) {
|
|
44
|
-
particle.opacity.loops = 0;
|
|
45
|
-
}
|
|
46
|
-
particle.opacity.loops++;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
particle.opacity.value += ((_e = particle.opacity.velocity) !== null && _e !== void 0 ? _e : 0) * delta.factor;
|
|
50
|
-
}
|
|
51
|
-
break;
|
|
52
|
-
case "decreasing":
|
|
53
|
-
if (particle.opacity.value <= minValue) {
|
|
54
|
-
particle.opacity.status = "increasing";
|
|
55
|
-
if (!particle.opacity.loops) {
|
|
56
|
-
particle.opacity.loops = 0;
|
|
57
|
-
}
|
|
58
|
-
particle.opacity.loops++;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
particle.opacity.value -= ((_f = particle.opacity.velocity) !== null && _f !== void 0 ? _f : 0) * delta.factor;
|
|
62
|
-
}
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
if (particle.opacity.velocity && particle.opacity.decay !== 1) {
|
|
66
|
-
particle.opacity.velocity *= decay;
|
|
67
|
-
}
|
|
68
|
-
checkDestroy(particle, particle.opacity.value, minValue, maxValue);
|
|
69
|
-
if (!particle.destroyed) {
|
|
70
|
-
particle.opacity.value = (0, engine_1.clamp)(particle.opacity.value, minValue, maxValue);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
14
|
+
const Utils_1 = require("./Utils");
|
|
73
15
|
class OpacityUpdater {
|
|
74
16
|
constructor(container) {
|
|
75
17
|
this.container = container;
|
|
@@ -87,17 +29,17 @@
|
|
|
87
29
|
}
|
|
88
30
|
}
|
|
89
31
|
isEnabled(particle) {
|
|
90
|
-
var _a, _b, _c, _d;
|
|
91
32
|
return (!particle.destroyed &&
|
|
92
33
|
!particle.spawning &&
|
|
93
34
|
!!particle.opacity &&
|
|
94
35
|
particle.opacity.enable &&
|
|
95
|
-
((
|
|
96
|
-
((
|
|
97
|
-
(
|
|
36
|
+
((particle.opacity.maxLoops ?? 0) <= 0 ||
|
|
37
|
+
((particle.opacity.maxLoops ?? 0) > 0 &&
|
|
38
|
+
(particle.opacity.loops ?? 0) < (particle.opacity.maxLoops ?? 0))));
|
|
98
39
|
}
|
|
99
40
|
reset(particle) {
|
|
100
41
|
if (particle.opacity) {
|
|
42
|
+
particle.opacity.time = 0;
|
|
101
43
|
particle.opacity.loops = 0;
|
|
102
44
|
}
|
|
103
45
|
}
|
|
@@ -105,7 +47,7 @@
|
|
|
105
47
|
if (!this.isEnabled(particle)) {
|
|
106
48
|
return;
|
|
107
49
|
}
|
|
108
|
-
updateOpacity(particle, delta);
|
|
50
|
+
(0, Utils_1.updateOpacity)(particle, delta);
|
|
109
51
|
}
|
|
110
52
|
}
|
|
111
53
|
exports.OpacityUpdater = OpacityUpdater;
|
package/umd/Utils.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.updateOpacity = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
function checkDestroy(particle, value, minValue, maxValue) {
|
|
15
|
+
switch (particle.options.opacity.animation.destroy) {
|
|
16
|
+
case "max":
|
|
17
|
+
if (value >= maxValue) {
|
|
18
|
+
particle.destroy();
|
|
19
|
+
}
|
|
20
|
+
break;
|
|
21
|
+
case "min":
|
|
22
|
+
if (value <= minValue) {
|
|
23
|
+
particle.destroy();
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function updateOpacity(particle, delta) {
|
|
29
|
+
const data = particle.opacity;
|
|
30
|
+
if (particle.destroyed || !data?.enable || ((data.maxLoops ?? 0) > 0 && (data.loops ?? 0) > (data.maxLoops ?? 0))) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const minValue = data.min, maxValue = data.max, decay = data.decay ?? 1;
|
|
34
|
+
if (!data.time) {
|
|
35
|
+
data.time = 0;
|
|
36
|
+
}
|
|
37
|
+
if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
|
|
38
|
+
data.time += delta.value;
|
|
39
|
+
}
|
|
40
|
+
if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
switch (data.status) {
|
|
44
|
+
case "increasing":
|
|
45
|
+
if (data.value >= maxValue) {
|
|
46
|
+
data.status = "decreasing";
|
|
47
|
+
if (!data.loops) {
|
|
48
|
+
data.loops = 0;
|
|
49
|
+
}
|
|
50
|
+
data.loops++;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
data.value += (data.velocity ?? 0) * delta.factor;
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
case "decreasing":
|
|
57
|
+
if (data.value <= minValue) {
|
|
58
|
+
data.status = "increasing";
|
|
59
|
+
if (!data.loops) {
|
|
60
|
+
data.loops = 0;
|
|
61
|
+
}
|
|
62
|
+
data.loops++;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
data.value -= (data.velocity ?? 0) * delta.factor;
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
if (data.velocity && data.decay !== 1) {
|
|
70
|
+
data.velocity *= decay;
|
|
71
|
+
}
|
|
72
|
+
checkDestroy(particle, data.value, minValue, maxValue);
|
|
73
|
+
if (!particle.destroyed) {
|
|
74
|
+
data.value = (0, engine_1.clamp)(data.value, minValue, maxValue);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.updateOpacity = updateOpacity;
|
|
78
|
+
});
|
package/umd/index.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.loadOpacityUpdater = void 0;
|
|
13
13
|
const OpacityUpdater_1 = require("./OpacityUpdater");
|
|
14
|
-
async function loadOpacityUpdater(engine) {
|
|
15
|
-
await engine.addParticleUpdater("opacity", (container) => new OpacityUpdater_1.OpacityUpdater(container));
|
|
14
|
+
async function loadOpacityUpdater(engine, refresh = true) {
|
|
15
|
+
await engine.addParticleUpdater("opacity", (container) => new OpacityUpdater_1.OpacityUpdater(container), refresh);
|
|
16
16
|
}
|
|
17
17
|
exports.loadOpacityUpdater = loadOpacityUpdater;
|
|
18
18
|
});
|