@tsparticles/updater-out-modes 3.0.0-beta.2 → 3.0.0-beta.4
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/browser/Utils.js +3 -3
- package/cjs/Utils.js +2 -2
- package/esm/Utils.js +3 -3
- package/package.json +3 -3
- package/report.html +4 -22
- package/tsparticles.updater.out-modes.js +3 -3
- package/tsparticles.updater.out-modes.min.js +1 -1
- package/tsparticles.updater.out-modes.min.js.LICENSE.txt +1 -1
- package/umd/Utils.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-beta.
|
|
7
|
+
* v3.0.0-beta.4
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -110,7 +110,7 @@ function bounceHorizontal(data) {
|
|
|
110
110
|
const velocity = data.particle.velocity.x;
|
|
111
111
|
let bounced = false;
|
|
112
112
|
if (data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity > 0 || data.direction === "left" && data.bounds.left <= 0 && velocity < 0) {
|
|
113
|
-
const newVelocity = (0,engine_root_window_.
|
|
113
|
+
const newVelocity = (0,engine_root_window_.getRangeValue)(data.particle.options.bounce.horizontal.value);
|
|
114
114
|
data.particle.velocity.x *= -newVelocity;
|
|
115
115
|
bounced = true;
|
|
116
116
|
}
|
|
@@ -139,7 +139,7 @@ function bounceVertical(data) {
|
|
|
139
139
|
const velocity = data.particle.velocity.y;
|
|
140
140
|
let bounced = false;
|
|
141
141
|
if (data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity > 0 || data.direction === "top" && data.bounds.top <= 0 && velocity < 0) {
|
|
142
|
-
const newVelocity = (0,engine_root_window_.
|
|
142
|
+
const newVelocity = (0,engine_root_window_.getRangeValue)(data.particle.options.bounce.vertical.value);
|
|
143
143
|
data.particle.velocity.y *= -newVelocity;
|
|
144
144
|
bounced = true;
|
|
145
145
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.updater.out-modes.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,
|
|
2
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var o="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var i in o)("object"==typeof exports?exports:t)[i]=o[i]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},o={};function i(t){var n=o[t];if(void 0!==n)return n.exports;var s=o[t]={exports:{}};return e[t](s,s.exports,i),s.exports}i.d=(t,e)=>{for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),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 e{constructor(t){this.container=t,this.modes=["bounce","bounce-vertical","bounce-horizontal","bounceVertical","bounceHorizontal","split"]}update(e,o,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(e,i,o)),r)break;if(r)return;const a=e.getPosition(),c=e.offset,d=e.getRadius(),u=(0,t.calculateBounds)(a,d),p=s.canvas.size;!function(e){if("bounce"!==e.outMode&&"bounce-horizontal"!==e.outMode&&"bounceHorizontal"!==e.outMode&&"split"!==e.outMode||"left"!==e.direction&&"right"!==e.direction)return;e.bounds.right<0&&"left"===e.direction?e.particle.position.x=e.size+e.offset.x:e.bounds.left>e.canvasSize.width&&"right"===e.direction&&(e.particle.position.x=e.canvasSize.width-e.size-e.offset.x);const o=e.particle.velocity.x;let i=!1;if("right"===e.direction&&e.bounds.right>=e.canvasSize.width&&o>0||"left"===e.direction&&e.bounds.left<=0&&o<0){const o=(0,t.getRangeValue)(e.particle.options.bounce.horizontal.value);e.particle.velocity.x*=-o,i=!0}if(!i)return;const n=e.offset.x+e.size;e.bounds.right>=e.canvasSize.width&&"right"===e.direction?e.particle.position.x=e.canvasSize.width-n:e.bounds.left<=0&&"left"===e.direction&&(e.particle.position.x=n),"split"===e.outMode&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d}),function(e){if("bounce"!==e.outMode&&"bounce-vertical"!==e.outMode&&"bounceVertical"!==e.outMode&&"split"!==e.outMode||"bottom"!==e.direction&&"top"!==e.direction)return;e.bounds.bottom<0&&"top"===e.direction?e.particle.position.y=e.size+e.offset.y:e.bounds.top>e.canvasSize.height&&"bottom"===e.direction&&(e.particle.position.y=e.canvasSize.height-e.size-e.offset.y);const o=e.particle.velocity.y;let i=!1;if("bottom"===e.direction&&e.bounds.bottom>=e.canvasSize.height&&o>0||"top"===e.direction&&e.bounds.top<=0&&o<0){const o=(0,t.getRangeValue)(e.particle.options.bounce.vertical.value);e.particle.velocity.y*=-o,i=!0}if(!i)return;const n=e.offset.y+e.size;e.bounds.bottom>=e.canvasSize.height&&"bottom"===e.direction?e.particle.position.y=e.canvasSize.height-n:e.bounds.top<=0&&"top"===e.direction&&(e.particle.position.y=n),"split"===e.outMode&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d})}}class o{constructor(t){this.container=t,this.modes=["destroy"]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(e.outType){case"normal":case"outside":if((0,t.isPointInside)(e.position,s.canvas.size,t.Vector.origin,e.getRadius(),o))return;break;case"inside":{const{dx:o,dy:i}=(0,t.getDistances)(e.position,e.moveCenter),{x:n,y:s}=e.velocity;if(n<0&&o>e.moveCenter.radius||s<0&&i>e.moveCenter.radius||n>=0&&o<-e.moveCenter.radius||s>=0&&i<-e.moveCenter.radius)return;break}}s.particles.remove(e,void 0,!0)}}class s{constructor(t){this.container=t,this.modes=["none"]}update(e,o,i,n){if(!this.modes.includes(n))return;if(e.options.move.distance.horizontal&&("left"===o||"right"===o)||e.options.move.distance.vertical&&("top"===o||"bottom"===o))return;const s=e.options.move.gravity,r=this.container,a=r.canvas.size,c=e.getRadius();if(s.enable){const t=e.position;(!s.inverse&&t.y>a.height+c&&"bottom"===o||s.inverse&&t.y<-c&&"top"===o)&&r.particles.remove(e)}else{if(e.velocity.y>0&&e.position.y<=a.height+c||e.velocity.y<0&&e.position.y>=-c||e.velocity.x>0&&e.position.x<=a.width+c||e.velocity.x<0&&e.position.x>=-c)return;(0,t.isPointInside)(e.position,r.canvas.size,t.Vector.origin,c,o)||r.particles.remove(e)}}}class r{constructor(t){this.container=t,this.modes=["out"]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(e.outType){case"inside":{const{x:o,y:i}=e.velocity,n=t.Vector.origin;n.length=e.moveCenter.radius,n.angle=e.velocity.angle+Math.PI,n.addTo(t.Vector.create(e.moveCenter));const{dx:r,dy:a}=(0,t.getDistances)(e.position,n);if(o<=0&&r>=0||i<=0&&a>=0||o>=0&&r<=0||i>=0&&a<=0)return;e.position.x=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.width})),e.position.y=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.height}));const{dx:c,dy:d}=(0,t.getDistances)(e.position,e.moveCenter);e.direction=Math.atan2(-d,-c),e.velocity.angle=e.direction;break}default:if((0,t.isPointInside)(e.position,s.canvas.size,t.Vector.origin,e.getRadius(),o))return;switch(e.outType){case"outside":{e.position.x=Math.floor((0,t.randomInRange)({min:-e.moveCenter.radius,max:e.moveCenter.radius}))+e.moveCenter.x,e.position.y=Math.floor((0,t.randomInRange)({min:-e.moveCenter.radius,max:e.moveCenter.radius}))+e.moveCenter.y;const{dx:o,dy:i}=(0,t.getDistances)(e.position,e.moveCenter);e.moveCenter.radius&&(e.direction=Math.atan2(i,o),e.velocity.angle=e.direction);break}case"normal":{const i=e.options.move.warp,n=s.canvas.size,r={bottom:n.height+e.getRadius()+e.offset.y,left:-e.getRadius()-e.offset.x,right:n.width+e.getRadius()+e.offset.x,top:-e.getRadius()-e.offset.y},a=e.getRadius(),c=(0,t.calculateBounds)(e.position,a);"right"===o&&c.left>n.width+e.offset.x?(e.position.x=r.left,e.initialPosition.x=e.position.x,i||(e.position.y=(0,t.getRandom)()*n.height,e.initialPosition.y=e.position.y)):"left"===o&&c.right<-e.offset.x&&(e.position.x=r.right,e.initialPosition.x=e.position.x,i||(e.position.y=(0,t.getRandom)()*n.height,e.initialPosition.y=e.position.y)),"bottom"===o&&c.top>n.height+e.offset.y?(i||(e.position.x=(0,t.getRandom)()*n.width,e.initialPosition.x=e.position.x),e.position.y=r.top,e.initialPosition.y=e.position.y):"top"===o&&c.bottom<-e.offset.y&&(i||(e.position.x=(0,t.getRandom)()*n.width,e.initialPosition.x=e.position.x),e.position.y=r.bottom,e.initialPosition.y=e.position.y);break}}}}}class a{constructor(t){this.container=t,this._updateOutMode=(t,e,o,i)=>{for(const n of this.updaters)n.update(t,i,e,o)},this.updaters=[new e(t),new o(t),new r(t),new s(t)]}init(){}isEnabled(t){return!t.destroyed&&!t.spawning}update(t,e){const o=t.options.move.outModes;this._updateOutMode(t,e,o.bottom??o.default,"bottom"),this._updateOutMode(t,e,o.left??o.default,"left"),this._updateOutMode(t,e,o.right??o.default,"right"),this._updateOutMode(t,e,o.top??o.default,"top")}}async function c(t,e=!0){await t.addParticleUpdater("outModes",(t=>new a(t)),e)}})(),n})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Out Modes Updater v3.0.0-beta.
|
|
1
|
+
/*! tsParticles Out Modes Updater v3.0.0-beta.4 by Matteo Bruni */
|
package/umd/Utils.js
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
let bounced = false;
|
|
30
30
|
if ((data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity > 0) ||
|
|
31
31
|
(data.direction === "left" && data.bounds.left <= 0 && velocity < 0)) {
|
|
32
|
-
const newVelocity = (0, engine_1.
|
|
32
|
+
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.horizontal.value);
|
|
33
33
|
data.particle.velocity.x *= -newVelocity;
|
|
34
34
|
bounced = true;
|
|
35
35
|
}
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
let bounced = false;
|
|
67
67
|
if ((data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity > 0) ||
|
|
68
68
|
(data.direction === "top" && data.bounds.top <= 0 && velocity < 0)) {
|
|
69
|
-
const newVelocity = (0, engine_1.
|
|
69
|
+
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.vertical.value);
|
|
70
70
|
data.particle.velocity.y *= -newVelocity;
|
|
71
71
|
bounced = true;
|
|
72
72
|
}
|