@tsparticles/updater-out-modes 3.0.0-alpha.1 → 3.0.0-beta.1
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/BounceOutMode.js +2 -2
- package/browser/DestroyOutMode.js +2 -2
- package/browser/NoneOutMode.js +1 -1
- package/browser/OutOfCanvasUpdater.js +13 -14
- package/browser/Utils.js +14 -12
- package/browser/index.js +3 -3
- package/browser/package.json +1 -0
- package/cjs/BounceOutMode.js +3 -3
- package/cjs/DestroyOutMode.js +1 -1
- package/cjs/OutOfCanvasUpdater.js +17 -18
- package/cjs/Utils.js +14 -12
- package/cjs/index.js +3 -14
- package/cjs/package.json +1 -0
- package/esm/BounceOutMode.js +2 -2
- package/esm/DestroyOutMode.js +2 -2
- package/esm/NoneOutMode.js +1 -1
- package/esm/OutOfCanvasUpdater.js +13 -14
- package/esm/Utils.js +14 -12
- package/esm/index.js +3 -3
- package/esm/package.json +1 -0
- package/package.json +19 -6
- package/report.html +4 -4
- package/tsparticles.updater.out-modes.js +24 -25
- package/tsparticles.updater.out-modes.min.js +1 -1
- package/tsparticles.updater.out-modes.min.js.LICENSE.txt +1 -8
- package/types/BounceOutMode.d.ts +2 -3
- package/types/DestroyOutMode.d.ts +3 -4
- package/types/IBounceData.d.ts +1 -2
- package/types/NoneOutMode.d.ts +2 -3
- package/types/OutOfCanvasUpdater.d.ts +3 -3
- package/types/OutOutMode.d.ts +2 -3
- package/types/Utils.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/umd/BounceOutMode.js +4 -4
- package/umd/DestroyOutMode.js +1 -1
- package/umd/OutOfCanvasUpdater.js +18 -19
- package/umd/Utils.js +14 -12
- package/umd/index.js +4 -4
|
@@ -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.1
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -91,7 +91,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
91
91
|
|
|
92
92
|
// EXPORTS
|
|
93
93
|
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
-
|
|
94
|
+
loadOutModesUpdater: () => (/* binding */ loadOutModesUpdater)
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
@@ -99,12 +99,12 @@ var engine_root_window_ = __webpack_require__(533);
|
|
|
99
99
|
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
100
100
|
|
|
101
101
|
function bounceHorizontal(data) {
|
|
102
|
-
if (data.outMode !== "bounce" && data.outMode !== "bounce-horizontal" && data.outMode !== "bounceHorizontal" && data.outMode !== "split") {
|
|
102
|
+
if (data.outMode !== "bounce" && data.outMode !== "bounce-horizontal" && data.outMode !== "bounceHorizontal" && data.outMode !== "split" || data.direction !== "left" && data.direction !== "right") {
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
if (data.bounds.right < 0) {
|
|
105
|
+
if (data.bounds.right < 0 && data.direction === "left") {
|
|
106
106
|
data.particle.position.x = data.size + data.offset.x;
|
|
107
|
-
} else if (data.bounds.left > data.canvasSize.width) {
|
|
107
|
+
} else if (data.bounds.left > data.canvasSize.width && data.direction === "right") {
|
|
108
108
|
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x;
|
|
109
109
|
}
|
|
110
110
|
const velocity = data.particle.velocity.x;
|
|
@@ -118,9 +118,9 @@ function bounceHorizontal(data) {
|
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
const minPos = data.offset.x + data.size;
|
|
121
|
-
if (data.bounds.right >= data.canvasSize.width) {
|
|
121
|
+
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") {
|
|
122
122
|
data.particle.position.x = data.canvasSize.width - minPos;
|
|
123
|
-
} else if (data.bounds.left <= 0) {
|
|
123
|
+
} else if (data.bounds.left <= 0 && data.direction === "left") {
|
|
124
124
|
data.particle.position.x = minPos;
|
|
125
125
|
}
|
|
126
126
|
if (data.outMode === "split") {
|
|
@@ -128,12 +128,12 @@ function bounceHorizontal(data) {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
function bounceVertical(data) {
|
|
131
|
-
if (data.outMode !== "bounce" && data.outMode !== "bounce-vertical" && data.outMode !== "bounceVertical" && data.outMode !== "split") {
|
|
131
|
+
if (data.outMode !== "bounce" && data.outMode !== "bounce-vertical" && data.outMode !== "bounceVertical" && data.outMode !== "split" || data.direction !== "bottom" && data.direction !== "top") {
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
|
-
if (data.bounds.bottom < 0) {
|
|
134
|
+
if (data.bounds.bottom < 0 && data.direction === "top") {
|
|
135
135
|
data.particle.position.y = data.size + data.offset.y;
|
|
136
|
-
} else if (data.bounds.top > data.canvasSize.height) {
|
|
136
|
+
} else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") {
|
|
137
137
|
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y;
|
|
138
138
|
}
|
|
139
139
|
const velocity = data.particle.velocity.y;
|
|
@@ -147,9 +147,9 @@ function bounceVertical(data) {
|
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
149
|
const minPos = data.offset.y + data.size;
|
|
150
|
-
if (data.bounds.bottom >= data.canvasSize.height) {
|
|
150
|
+
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") {
|
|
151
151
|
data.particle.position.y = data.canvasSize.height - minPos;
|
|
152
|
-
} else if (data.bounds.top <= 0) {
|
|
152
|
+
} else if (data.bounds.top <= 0 && data.direction === "top") {
|
|
153
153
|
data.particle.position.y = minPos;
|
|
154
154
|
}
|
|
155
155
|
if (data.outMode === "split") {
|
|
@@ -213,7 +213,7 @@ class DestroyOutMode {
|
|
|
213
213
|
this.container = container;
|
|
214
214
|
this.modes = ["destroy"];
|
|
215
215
|
}
|
|
216
|
-
update(particle, direction,
|
|
216
|
+
update(particle, direction, _delta, outMode) {
|
|
217
217
|
if (!this.modes.includes(outMode)) {
|
|
218
218
|
return;
|
|
219
219
|
}
|
|
@@ -407,6 +407,11 @@ class OutOutMode {
|
|
|
407
407
|
class OutOfCanvasUpdater {
|
|
408
408
|
constructor(container) {
|
|
409
409
|
this.container = container;
|
|
410
|
+
this._updateOutMode = (particle, delta, outMode, direction) => {
|
|
411
|
+
for (const updater of this.updaters) {
|
|
412
|
+
updater.update(particle, direction, delta, outMode);
|
|
413
|
+
}
|
|
414
|
+
};
|
|
410
415
|
this.updaters = [new BounceOutMode(container), new DestroyOutMode(container), new OutOutMode(container), new NoneOutMode(container)];
|
|
411
416
|
}
|
|
412
417
|
init() {}
|
|
@@ -414,23 +419,17 @@ class OutOfCanvasUpdater {
|
|
|
414
419
|
return !particle.destroyed && !particle.spawning;
|
|
415
420
|
}
|
|
416
421
|
update(particle, delta) {
|
|
417
|
-
var _a, _b, _c, _d;
|
|
418
422
|
const outModes = particle.options.move.outModes;
|
|
419
|
-
this.
|
|
420
|
-
this.
|
|
421
|
-
this.
|
|
422
|
-
this.
|
|
423
|
-
}
|
|
424
|
-
updateOutMode(particle, delta, outMode, direction) {
|
|
425
|
-
for (const updater of this.updaters) {
|
|
426
|
-
updater.update(particle, direction, delta, outMode);
|
|
427
|
-
}
|
|
423
|
+
this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom");
|
|
424
|
+
this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left");
|
|
425
|
+
this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right");
|
|
426
|
+
this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top");
|
|
428
427
|
}
|
|
429
428
|
}
|
|
430
429
|
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
431
430
|
|
|
432
|
-
async function loadOutModesUpdater(engine) {
|
|
433
|
-
await engine.addParticleUpdater("outModes", container => new OutOfCanvasUpdater(container));
|
|
431
|
+
async function loadOutModesUpdater(engine, refresh = true) {
|
|
432
|
+
await engine.addParticleUpdater("outModes", container => new OutOfCanvasUpdater(container), refresh);
|
|
434
433
|
}
|
|
435
434
|
})();
|
|
436
435
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.updater.out-modes.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],o);else{var e="object"==typeof exports?o(require("@tsparticles/engine")):o(t.window);for(var i in e)("object"==typeof exports?exports:t)[i]=e[i]}}(this,(t=>(()=>{"use strict";var o={533:o=>{o.exports=t}},e={};function i(t){var n=e[t];if(void 0!==n)return n.exports;var s=e[t]={exports:{}};return o[t](s,s.exports,i),s.exports}i.d=(t,o)=>{for(var e in o)i.o(o,e)&&!i.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:o[e]})},i.o=(t,o)=>Object.prototype.hasOwnProperty.call(t,o),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{i.r(n),i.d(n,{loadOutModesUpdater:()=>c});var t=i(533);class o{constructor(t){this.container=t,this.modes=["bounce","bounce-vertical","bounce-horizontal","bounceVertical","bounceHorizontal","split"]}update(o,e,i,n){if(!this.modes.includes(n))return;const s=this.container;let
|
|
2
|
+
!function(t,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],o);else{var e="object"==typeof exports?o(require("@tsparticles/engine")):o(t.window);for(var i in e)("object"==typeof exports?exports:t)[i]=e[i]}}(this,(t=>(()=>{"use strict";var o={533:o=>{o.exports=t}},e={};function i(t){var n=e[t];if(void 0!==n)return n.exports;var s=e[t]={exports:{}};return o[t](s,s.exports,i),s.exports}i.d=(t,o)=>{for(var e in o)i.o(o,e)&&!i.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:o[e]})},i.o=(t,o)=>Object.prototype.hasOwnProperty.call(t,o),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{i.r(n),i.d(n,{loadOutModesUpdater:()=>c});var t=i(533);class o{constructor(t){this.container=t,this.modes=["bounce","bounce-vertical","bounce-horizontal","bounceVertical","bounceHorizontal","split"]}update(o,e,i,n){if(!this.modes.includes(n))return;const s=this.container;let r=!1;for(const[,t]of s.plugins)if(void 0!==t.particleBounce&&(r=t.particleBounce(o,i,e)),r)break;if(r)return;const a=o.getPosition(),c=o.offset,d=o.getRadius(),u=(0,t.calculateBounds)(a,d),p=s.canvas.size;!function(o){if("bounce"!==o.outMode&&"bounce-horizontal"!==o.outMode&&"bounceHorizontal"!==o.outMode&&"split"!==o.outMode||"left"!==o.direction&&"right"!==o.direction)return;o.bounds.right<0&&"left"===o.direction?o.particle.position.x=o.size+o.offset.x:o.bounds.left>o.canvasSize.width&&"right"===o.direction&&(o.particle.position.x=o.canvasSize.width-o.size-o.offset.x);const e=o.particle.velocity.x;let i=!1;if("right"===o.direction&&o.bounds.right>=o.canvasSize.width&&e>0||"left"===o.direction&&o.bounds.left<=0&&e<0){const e=(0,t.getValue)(o.particle.options.bounce.horizontal);o.particle.velocity.x*=-e,i=!0}if(!i)return;const n=o.offset.x+o.size;o.bounds.right>=o.canvasSize.width&&"right"===o.direction?o.particle.position.x=o.canvasSize.width-n:o.bounds.left<=0&&"left"===o.direction&&(o.particle.position.x=n),"split"===o.outMode&&o.particle.destroy()}({particle:o,outMode:n,direction:e,bounds:u,canvasSize:p,offset:c,size:d}),function(o){if("bounce"!==o.outMode&&"bounce-vertical"!==o.outMode&&"bounceVertical"!==o.outMode&&"split"!==o.outMode||"bottom"!==o.direction&&"top"!==o.direction)return;o.bounds.bottom<0&&"top"===o.direction?o.particle.position.y=o.size+o.offset.y:o.bounds.top>o.canvasSize.height&&"bottom"===o.direction&&(o.particle.position.y=o.canvasSize.height-o.size-o.offset.y);const e=o.particle.velocity.y;let i=!1;if("bottom"===o.direction&&o.bounds.bottom>=o.canvasSize.height&&e>0||"top"===o.direction&&o.bounds.top<=0&&e<0){const e=(0,t.getValue)(o.particle.options.bounce.vertical);o.particle.velocity.y*=-e,i=!0}if(!i)return;const n=o.offset.y+o.size;o.bounds.bottom>=o.canvasSize.height&&"bottom"===o.direction?o.particle.position.y=o.canvasSize.height-n:o.bounds.top<=0&&"top"===o.direction&&(o.particle.position.y=n),"split"===o.outMode&&o.particle.destroy()}({particle:o,outMode:n,direction:e,bounds:u,canvasSize:p,offset:c,size:d})}}class e{constructor(t){this.container=t,this.modes=["destroy"]}update(o,e,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(o.outType){case"normal":case"outside":if((0,t.isPointInside)(o.position,s.canvas.size,t.Vector.origin,o.getRadius(),e))return;break;case"inside":{const{dx:e,dy:i}=(0,t.getDistances)(o.position,o.moveCenter),{x:n,y:s}=o.velocity;if(n<0&&e>o.moveCenter.radius||s<0&&i>o.moveCenter.radius||n>=0&&e<-o.moveCenter.radius||s>=0&&i<-o.moveCenter.radius)return;break}}s.particles.remove(o,void 0,!0)}}class s{constructor(t){this.container=t,this.modes=["none"]}update(o,e,i,n){if(!this.modes.includes(n))return;if(o.options.move.distance.horizontal&&("left"===e||"right"===e)||o.options.move.distance.vertical&&("top"===e||"bottom"===e))return;const s=o.options.move.gravity,r=this.container,a=r.canvas.size,c=o.getRadius();if(s.enable){const t=o.position;(!s.inverse&&t.y>a.height+c&&"bottom"===e||s.inverse&&t.y<-c&&"top"===e)&&r.particles.remove(o)}else{if(o.velocity.y>0&&o.position.y<=a.height+c||o.velocity.y<0&&o.position.y>=-c||o.velocity.x>0&&o.position.x<=a.width+c||o.velocity.x<0&&o.position.x>=-c)return;(0,t.isPointInside)(o.position,r.canvas.size,t.Vector.origin,c,e)||r.particles.remove(o)}}}class r{constructor(t){this.container=t,this.modes=["out"]}update(o,e,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(o.outType){case"inside":{const{x:e,y:i}=o.velocity,n=t.Vector.origin;n.length=o.moveCenter.radius,n.angle=o.velocity.angle+Math.PI,n.addTo(t.Vector.create(o.moveCenter));const{dx:r,dy:a}=(0,t.getDistances)(o.position,n);if(e<=0&&r>=0||i<=0&&a>=0||e>=0&&r<=0||i>=0&&a<=0)return;o.position.x=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.width})),o.position.y=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.height}));const{dx:c,dy:d}=(0,t.getDistances)(o.position,o.moveCenter);o.direction=Math.atan2(-d,-c),o.velocity.angle=o.direction;break}default:if((0,t.isPointInside)(o.position,s.canvas.size,t.Vector.origin,o.getRadius(),e))return;switch(o.outType){case"outside":{o.position.x=Math.floor((0,t.randomInRange)({min:-o.moveCenter.radius,max:o.moveCenter.radius}))+o.moveCenter.x,o.position.y=Math.floor((0,t.randomInRange)({min:-o.moveCenter.radius,max:o.moveCenter.radius}))+o.moveCenter.y;const{dx:e,dy:i}=(0,t.getDistances)(o.position,o.moveCenter);o.moveCenter.radius&&(o.direction=Math.atan2(i,e),o.velocity.angle=o.direction);break}case"normal":{const i=o.options.move.warp,n=s.canvas.size,r={bottom:n.height+o.getRadius()+o.offset.y,left:-o.getRadius()-o.offset.x,right:n.width+o.getRadius()+o.offset.x,top:-o.getRadius()-o.offset.y},a=o.getRadius(),c=(0,t.calculateBounds)(o.position,a);"right"===e&&c.left>n.width+o.offset.x?(o.position.x=r.left,o.initialPosition.x=o.position.x,i||(o.position.y=(0,t.getRandom)()*n.height,o.initialPosition.y=o.position.y)):"left"===e&&c.right<-o.offset.x&&(o.position.x=r.right,o.initialPosition.x=o.position.x,i||(o.position.y=(0,t.getRandom)()*n.height,o.initialPosition.y=o.position.y)),"bottom"===e&&c.top>n.height+o.offset.y?(i||(o.position.x=(0,t.getRandom)()*n.width,o.initialPosition.x=o.position.x),o.position.y=r.top,o.initialPosition.y=o.position.y):"top"===e&&c.bottom<-o.offset.y&&(i||(o.position.x=(0,t.getRandom)()*n.width,o.initialPosition.x=o.position.x),o.position.y=r.bottom,o.initialPosition.y=o.position.y);break}}}}}class a{constructor(t){this.container=t,this._updateOutMode=(t,o,e,i)=>{for(const n of this.updaters)n.update(t,i,o,e)},this.updaters=[new o(t),new e(t),new r(t),new s(t)]}init(){}isEnabled(t){return!t.destroyed&&!t.spawning}update(t,o){const e=t.options.move.outModes;this._updateOutMode(t,o,e.bottom??e.default,"bottom"),this._updateOutMode(t,o,e.left??e.default,"left"),this._updateOutMode(t,o,e.right??e.default,"right"),this._updateOutMode(t,o,e.top??e.default,"top")}}async function c(t,o=!0){await t.addParticleUpdater("outModes",(t=>new a(t)),o)}})(),n})()));
|
|
@@ -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.1
|
|
8
|
-
*/
|
|
1
|
+
/*! tsParticles Out Modes Updater v3.0.0-beta.1 by Matteo Bruni */
|
package/types/BounceOutMode.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
import type { IOutModeManager } from "./IOutModeManager";
|
|
1
|
+
import { type Container, type IDelta, OutMode, type OutModeAlt, type OutModeDirection, type Particle } from "@tsparticles/engine";
|
|
2
|
+
import type { IOutModeManager } from "./IOutModeManager.js";
|
|
4
3
|
export declare class BounceOutMode implements IOutModeManager {
|
|
5
4
|
private readonly container;
|
|
6
5
|
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
import type { IOutModeManager } from "./IOutModeManager";
|
|
1
|
+
import { type Container, type IDelta, OutMode, type OutModeAlt, type OutModeDirection, type Particle } from "@tsparticles/engine";
|
|
2
|
+
import type { IOutModeManager } from "./IOutModeManager.js";
|
|
4
3
|
export declare class DestroyOutMode implements IOutModeManager {
|
|
5
4
|
private readonly container;
|
|
6
5
|
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
|
|
7
6
|
constructor(container: Container);
|
|
8
|
-
update(particle: Particle, direction: OutModeDirection,
|
|
7
|
+
update(particle: Particle, direction: OutModeDirection, _delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void;
|
|
9
8
|
}
|
package/types/IBounceData.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { IBounds, ICoordinates, IDimension, OutMode, OutModeAlt, OutModeDirection } from "@tsparticles/engine";
|
|
2
|
-
import type { Particle } from "@tsparticles/engine";
|
|
1
|
+
import type { IBounds, ICoordinates, IDimension, OutMode, OutModeAlt, OutModeDirection, Particle } from "@tsparticles/engine";
|
|
3
2
|
export interface IBounceData {
|
|
4
3
|
bounds: IBounds;
|
|
5
4
|
canvasSize: IDimension;
|
package/types/NoneOutMode.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
import type { IOutModeManager } from "./IOutModeManager";
|
|
1
|
+
import { type Container, type IDelta, OutMode, type OutModeAlt, OutModeDirection, type Particle } from "@tsparticles/engine";
|
|
2
|
+
import type { IOutModeManager } from "./IOutModeManager.js";
|
|
4
3
|
export declare class NoneOutMode implements IOutModeManager {
|
|
5
4
|
private readonly container;
|
|
6
5
|
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { IOutModeManager } from "./IOutModeManager";
|
|
1
|
+
import { type Container, type IDelta, type IParticleUpdater, type Particle } from "@tsparticles/engine";
|
|
2
|
+
import type { IOutModeManager } from "./IOutModeManager.js";
|
|
3
3
|
export declare class OutOfCanvasUpdater implements IParticleUpdater {
|
|
4
4
|
private readonly container;
|
|
5
5
|
updaters: IOutModeManager[];
|
|
@@ -7,5 +7,5 @@ export declare class OutOfCanvasUpdater implements IParticleUpdater {
|
|
|
7
7
|
init(): void;
|
|
8
8
|
isEnabled(particle: Particle): boolean;
|
|
9
9
|
update(particle: Particle, delta: IDelta): void;
|
|
10
|
-
private
|
|
10
|
+
private readonly _updateOutMode;
|
|
11
11
|
}
|
package/types/OutOutMode.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
import type { IOutModeManager } from "./IOutModeManager";
|
|
1
|
+
import { type Container, type IDelta, OutMode, type OutModeAlt, OutModeDirection, type Particle } from "@tsparticles/engine";
|
|
2
|
+
import type { IOutModeManager } from "./IOutModeManager.js";
|
|
4
3
|
export declare class OutOutMode implements IOutModeManager {
|
|
5
4
|
private readonly container;
|
|
6
5
|
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
|
package/types/Utils.d.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Engine } from "@tsparticles/engine";
|
|
2
|
-
export declare function loadOutModesUpdater(engine: Engine): Promise<void>;
|
|
2
|
+
export declare function loadOutModesUpdater(engine: Engine, refresh?: boolean): Promise<void>;
|
package/umd/BounceOutMode.js
CHANGED
|
@@ -4,14 +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", "./Utils"], factory);
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Utils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BounceOutMode = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
const
|
|
14
|
+
const Utils_js_1 = require("./Utils.js");
|
|
15
15
|
class BounceOutMode {
|
|
16
16
|
constructor(container) {
|
|
17
17
|
this.container = container;
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = (0, engine_1.calculateBounds)(pos, size), canvasSize = container.canvas.size;
|
|
45
|
-
(0,
|
|
46
|
-
(0,
|
|
45
|
+
(0, Utils_js_1.bounceHorizontal)({ particle, outMode, direction, bounds, canvasSize, offset, size });
|
|
46
|
+
(0, Utils_js_1.bounceVertical)({ particle, outMode, direction, bounds, canvasSize, offset, size });
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
exports.BounceOutMode = BounceOutMode;
|
package/umd/DestroyOutMode.js
CHANGED
|
@@ -4,24 +4,29 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./BounceOutMode", "./DestroyOutMode", "./NoneOutMode", "./OutOutMode"], factory);
|
|
7
|
+
define(["require", "exports", "./BounceOutMode.js", "./DestroyOutMode.js", "./NoneOutMode.js", "./OutOutMode.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.OutOfCanvasUpdater = void 0;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
13
|
+
const BounceOutMode_js_1 = require("./BounceOutMode.js");
|
|
14
|
+
const DestroyOutMode_js_1 = require("./DestroyOutMode.js");
|
|
15
|
+
const NoneOutMode_js_1 = require("./NoneOutMode.js");
|
|
16
|
+
const OutOutMode_js_1 = require("./OutOutMode.js");
|
|
17
17
|
class OutOfCanvasUpdater {
|
|
18
18
|
constructor(container) {
|
|
19
19
|
this.container = container;
|
|
20
|
+
this._updateOutMode = (particle, delta, outMode, direction) => {
|
|
21
|
+
for (const updater of this.updaters) {
|
|
22
|
+
updater.update(particle, direction, delta, outMode);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
20
25
|
this.updaters = [
|
|
21
|
-
new
|
|
22
|
-
new
|
|
23
|
-
new
|
|
24
|
-
new
|
|
26
|
+
new BounceOutMode_js_1.BounceOutMode(container),
|
|
27
|
+
new DestroyOutMode_js_1.DestroyOutMode(container),
|
|
28
|
+
new OutOutMode_js_1.OutOutMode(container),
|
|
29
|
+
new NoneOutMode_js_1.NoneOutMode(container),
|
|
25
30
|
];
|
|
26
31
|
}
|
|
27
32
|
init() {
|
|
@@ -30,17 +35,11 @@
|
|
|
30
35
|
return !particle.destroyed && !particle.spawning;
|
|
31
36
|
}
|
|
32
37
|
update(particle, delta) {
|
|
33
|
-
var _a, _b, _c, _d;
|
|
34
38
|
const outModes = particle.options.move.outModes;
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
}
|
|
40
|
-
updateOutMode(particle, delta, outMode, direction) {
|
|
41
|
-
for (const updater of this.updaters) {
|
|
42
|
-
updater.update(particle, direction, delta, outMode);
|
|
43
|
-
}
|
|
39
|
+
this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom");
|
|
40
|
+
this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left");
|
|
41
|
+
this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right");
|
|
42
|
+
this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top");
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
exports.OutOfCanvasUpdater = OutOfCanvasUpdater;
|
package/umd/Utils.js
CHANGED
|
@@ -12,16 +12,17 @@
|
|
|
12
12
|
exports.bounceVertical = exports.bounceHorizontal = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
function bounceHorizontal(data) {
|
|
15
|
-
if (data.outMode !== "bounce" &&
|
|
15
|
+
if ((data.outMode !== "bounce" &&
|
|
16
16
|
data.outMode !== "bounce-horizontal" &&
|
|
17
17
|
data.outMode !== "bounceHorizontal" &&
|
|
18
|
-
data.outMode !== "split")
|
|
18
|
+
data.outMode !== "split") ||
|
|
19
|
+
(data.direction !== "left" && data.direction !== "right")) {
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
|
-
if (data.bounds.right < 0) {
|
|
22
|
+
if (data.bounds.right < 0 && data.direction === "left") {
|
|
22
23
|
data.particle.position.x = data.size + data.offset.x;
|
|
23
24
|
}
|
|
24
|
-
else if (data.bounds.left > data.canvasSize.width) {
|
|
25
|
+
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") {
|
|
25
26
|
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x;
|
|
26
27
|
}
|
|
27
28
|
const velocity = data.particle.velocity.x;
|
|
@@ -36,10 +37,10 @@
|
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
39
|
const minPos = data.offset.x + data.size;
|
|
39
|
-
if (data.bounds.right >= data.canvasSize.width) {
|
|
40
|
+
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") {
|
|
40
41
|
data.particle.position.x = data.canvasSize.width - minPos;
|
|
41
42
|
}
|
|
42
|
-
else if (data.bounds.left <= 0) {
|
|
43
|
+
else if (data.bounds.left <= 0 && data.direction === "left") {
|
|
43
44
|
data.particle.position.x = minPos;
|
|
44
45
|
}
|
|
45
46
|
if (data.outMode === "split") {
|
|
@@ -48,16 +49,17 @@
|
|
|
48
49
|
}
|
|
49
50
|
exports.bounceHorizontal = bounceHorizontal;
|
|
50
51
|
function bounceVertical(data) {
|
|
51
|
-
if (data.outMode !== "bounce" &&
|
|
52
|
+
if ((data.outMode !== "bounce" &&
|
|
52
53
|
data.outMode !== "bounce-vertical" &&
|
|
53
54
|
data.outMode !== "bounceVertical" &&
|
|
54
|
-
data.outMode !== "split")
|
|
55
|
+
data.outMode !== "split") ||
|
|
56
|
+
(data.direction !== "bottom" && data.direction !== "top")) {
|
|
55
57
|
return;
|
|
56
58
|
}
|
|
57
|
-
if (data.bounds.bottom < 0) {
|
|
59
|
+
if (data.bounds.bottom < 0 && data.direction === "top") {
|
|
58
60
|
data.particle.position.y = data.size + data.offset.y;
|
|
59
61
|
}
|
|
60
|
-
else if (data.bounds.top > data.canvasSize.height) {
|
|
62
|
+
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") {
|
|
61
63
|
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y;
|
|
62
64
|
}
|
|
63
65
|
const velocity = data.particle.velocity.y;
|
|
@@ -72,10 +74,10 @@
|
|
|
72
74
|
return;
|
|
73
75
|
}
|
|
74
76
|
const minPos = data.offset.y + data.size;
|
|
75
|
-
if (data.bounds.bottom >= data.canvasSize.height) {
|
|
77
|
+
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") {
|
|
76
78
|
data.particle.position.y = data.canvasSize.height - minPos;
|
|
77
79
|
}
|
|
78
|
-
else if (data.bounds.top <= 0) {
|
|
80
|
+
else if (data.bounds.top <= 0 && data.direction === "top") {
|
|
79
81
|
data.particle.position.y = minPos;
|
|
80
82
|
}
|
|
81
83
|
if (data.outMode === "split") {
|
package/umd/index.js
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./OutOfCanvasUpdater"], factory);
|
|
7
|
+
define(["require", "exports", "./OutOfCanvasUpdater.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.loadOutModesUpdater = void 0;
|
|
13
|
-
const
|
|
14
|
-
async function loadOutModesUpdater(engine) {
|
|
15
|
-
await engine.addParticleUpdater("outModes", (container) => new
|
|
13
|
+
const OutOfCanvasUpdater_js_1 = require("./OutOfCanvasUpdater.js");
|
|
14
|
+
async function loadOutModesUpdater(engine, refresh = true) {
|
|
15
|
+
await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater_js_1.OutOfCanvasUpdater(container), refresh);
|
|
16
16
|
}
|
|
17
17
|
exports.loadOutModesUpdater = loadOutModesUpdater;
|
|
18
18
|
});
|