@tsparticles/updater-life
Advanced tools
Comparing version 3.0.3 to 3.1.0
@@ -1,3 +0,4 @@ | ||
import { getRandom, getRangeValue, randomInRange, setRangeValue, } from "@tsparticles/engine"; | ||
import { getRandom, getRangeValue, millisecondsToSeconds, randomInRange, setRangeValue, } from "@tsparticles/engine"; | ||
import { Life } from "./Options/Classes/Life.js"; | ||
const noTime = 0, identity = 1, infiniteValue = -1, noLife = 0, minCanvasSize = 0; | ||
export class LifeUpdater { | ||
@@ -14,23 +15,23 @@ constructor(container) { | ||
delay: container.retina.reduceFactor | ||
? ((getRangeValue(lifeOptions.delay.value) * (lifeOptions.delay.sync ? 1 : getRandom())) / | ||
? ((getRangeValue(lifeOptions.delay.value) * (lifeOptions.delay.sync ? identity : getRandom())) / | ||
container.retina.reduceFactor) * | ||
1000 | ||
: 0, | ||
delayTime: 0, | ||
millisecondsToSeconds | ||
: noTime, | ||
delayTime: noTime, | ||
duration: container.retina.reduceFactor | ||
? ((getRangeValue(lifeOptions.duration.value) * (lifeOptions.duration.sync ? 1 : getRandom())) / | ||
? ((getRangeValue(lifeOptions.duration.value) * (lifeOptions.duration.sync ? identity : getRandom())) / | ||
container.retina.reduceFactor) * | ||
1000 | ||
: 0, | ||
time: 0, | ||
millisecondsToSeconds | ||
: noTime, | ||
time: noTime, | ||
count: lifeOptions.count, | ||
}; | ||
if (particle.life.duration <= 0) { | ||
particle.life.duration = -1; | ||
if (particle.life.duration <= noTime) { | ||
particle.life.duration = infiniteValue; | ||
} | ||
if (particle.life.count <= 0) { | ||
particle.life.count = -1; | ||
if (particle.life.count <= noTime) { | ||
particle.life.count = infiniteValue; | ||
} | ||
if (particle.life) { | ||
particle.spawning = particle.life.delay > 0; | ||
particle.spawning = particle.life.delay > noTime; | ||
} | ||
@@ -60,4 +61,4 @@ } | ||
particle.spawning = false; | ||
life.delayTime = 0; | ||
life.time = 0; | ||
life.delayTime = noTime; | ||
life.time = noTime; | ||
} | ||
@@ -68,3 +69,3 @@ else { | ||
} | ||
if (life.duration === -1) { | ||
if (life.duration === infiniteValue) { | ||
return; | ||
@@ -76,3 +77,3 @@ } | ||
if (justSpawned) { | ||
life.time = 0; | ||
life.time = noTime; | ||
} | ||
@@ -85,23 +86,23 @@ else { | ||
} | ||
life.time = 0; | ||
if (particle.life.count > 0) { | ||
life.time = noTime; | ||
if (particle.life.count > noLife) { | ||
particle.life.count--; | ||
} | ||
if (particle.life.count === 0) { | ||
if (particle.life.count === noLife) { | ||
particle.destroy(); | ||
return; | ||
} | ||
const canvasSize = this.container.canvas.size, widthRange = setRangeValue(0, canvasSize.width), heightRange = setRangeValue(0, canvasSize.width); | ||
const canvasSize = this.container.canvas.size, widthRange = setRangeValue(minCanvasSize, canvasSize.width), heightRange = setRangeValue(minCanvasSize, canvasSize.width); | ||
particle.position.x = randomInRange(widthRange); | ||
particle.position.y = randomInRange(heightRange); | ||
particle.spawning = true; | ||
life.delayTime = 0; | ||
life.time = 0; | ||
life.delayTime = noTime; | ||
life.time = noTime; | ||
particle.reset(); | ||
const lifeOptions = particle.options.life; | ||
if (lifeOptions) { | ||
life.delay = getRangeValue(lifeOptions.delay.value) * 1000; | ||
life.duration = getRangeValue(lifeOptions.duration.value) * 1000; | ||
life.delay = getRangeValue(lifeOptions.delay.value) * millisecondsToSeconds; | ||
life.duration = getRangeValue(lifeOptions.duration.value) * millisecondsToSeconds; | ||
} | ||
} | ||
} |
@@ -6,2 +6,3 @@ "use strict"; | ||
const Life_js_1 = require("./Options/Classes/Life.js"); | ||
const noTime = 0, identity = 1, infiniteValue = -1, noLife = 0, minCanvasSize = 0; | ||
class LifeUpdater { | ||
@@ -18,23 +19,23 @@ constructor(container) { | ||
delay: container.retina.reduceFactor | ||
? (((0, engine_1.getRangeValue)(lifeOptions.delay.value) * (lifeOptions.delay.sync ? 1 : (0, engine_1.getRandom)())) / | ||
? (((0, engine_1.getRangeValue)(lifeOptions.delay.value) * (lifeOptions.delay.sync ? identity : (0, engine_1.getRandom)())) / | ||
container.retina.reduceFactor) * | ||
1000 | ||
: 0, | ||
delayTime: 0, | ||
engine_1.millisecondsToSeconds | ||
: noTime, | ||
delayTime: noTime, | ||
duration: container.retina.reduceFactor | ||
? (((0, engine_1.getRangeValue)(lifeOptions.duration.value) * (lifeOptions.duration.sync ? 1 : (0, engine_1.getRandom)())) / | ||
? (((0, engine_1.getRangeValue)(lifeOptions.duration.value) * (lifeOptions.duration.sync ? identity : (0, engine_1.getRandom)())) / | ||
container.retina.reduceFactor) * | ||
1000 | ||
: 0, | ||
time: 0, | ||
engine_1.millisecondsToSeconds | ||
: noTime, | ||
time: noTime, | ||
count: lifeOptions.count, | ||
}; | ||
if (particle.life.duration <= 0) { | ||
particle.life.duration = -1; | ||
if (particle.life.duration <= noTime) { | ||
particle.life.duration = infiniteValue; | ||
} | ||
if (particle.life.count <= 0) { | ||
particle.life.count = -1; | ||
if (particle.life.count <= noTime) { | ||
particle.life.count = infiniteValue; | ||
} | ||
if (particle.life) { | ||
particle.spawning = particle.life.delay > 0; | ||
particle.spawning = particle.life.delay > noTime; | ||
} | ||
@@ -64,4 +65,4 @@ } | ||
particle.spawning = false; | ||
life.delayTime = 0; | ||
life.time = 0; | ||
life.delayTime = noTime; | ||
life.time = noTime; | ||
} | ||
@@ -72,3 +73,3 @@ else { | ||
} | ||
if (life.duration === -1) { | ||
if (life.duration === infiniteValue) { | ||
return; | ||
@@ -80,3 +81,3 @@ } | ||
if (justSpawned) { | ||
life.time = 0; | ||
life.time = noTime; | ||
} | ||
@@ -89,21 +90,21 @@ else { | ||
} | ||
life.time = 0; | ||
if (particle.life.count > 0) { | ||
life.time = noTime; | ||
if (particle.life.count > noLife) { | ||
particle.life.count--; | ||
} | ||
if (particle.life.count === 0) { | ||
if (particle.life.count === noLife) { | ||
particle.destroy(); | ||
return; | ||
} | ||
const canvasSize = this.container.canvas.size, widthRange = (0, engine_1.setRangeValue)(0, canvasSize.width), heightRange = (0, engine_1.setRangeValue)(0, canvasSize.width); | ||
const canvasSize = this.container.canvas.size, widthRange = (0, engine_1.setRangeValue)(minCanvasSize, canvasSize.width), heightRange = (0, engine_1.setRangeValue)(minCanvasSize, canvasSize.width); | ||
particle.position.x = (0, engine_1.randomInRange)(widthRange); | ||
particle.position.y = (0, engine_1.randomInRange)(heightRange); | ||
particle.spawning = true; | ||
life.delayTime = 0; | ||
life.time = 0; | ||
life.delayTime = noTime; | ||
life.time = noTime; | ||
particle.reset(); | ||
const lifeOptions = particle.options.life; | ||
if (lifeOptions) { | ||
life.delay = (0, engine_1.getRangeValue)(lifeOptions.delay.value) * 1000; | ||
life.duration = (0, engine_1.getRangeValue)(lifeOptions.duration.value) * 1000; | ||
life.delay = (0, engine_1.getRangeValue)(lifeOptions.delay.value) * engine_1.millisecondsToSeconds; | ||
life.duration = (0, engine_1.getRangeValue)(lifeOptions.duration.value) * engine_1.millisecondsToSeconds; | ||
} | ||
@@ -110,0 +111,0 @@ } |
@@ -1,3 +0,4 @@ | ||
import { getRandom, getRangeValue, randomInRange, setRangeValue, } from "@tsparticles/engine"; | ||
import { getRandom, getRangeValue, millisecondsToSeconds, randomInRange, setRangeValue, } from "@tsparticles/engine"; | ||
import { Life } from "./Options/Classes/Life.js"; | ||
const noTime = 0, identity = 1, infiniteValue = -1, noLife = 0, minCanvasSize = 0; | ||
export class LifeUpdater { | ||
@@ -14,23 +15,23 @@ constructor(container) { | ||
delay: container.retina.reduceFactor | ||
? ((getRangeValue(lifeOptions.delay.value) * (lifeOptions.delay.sync ? 1 : getRandom())) / | ||
? ((getRangeValue(lifeOptions.delay.value) * (lifeOptions.delay.sync ? identity : getRandom())) / | ||
container.retina.reduceFactor) * | ||
1000 | ||
: 0, | ||
delayTime: 0, | ||
millisecondsToSeconds | ||
: noTime, | ||
delayTime: noTime, | ||
duration: container.retina.reduceFactor | ||
? ((getRangeValue(lifeOptions.duration.value) * (lifeOptions.duration.sync ? 1 : getRandom())) / | ||
? ((getRangeValue(lifeOptions.duration.value) * (lifeOptions.duration.sync ? identity : getRandom())) / | ||
container.retina.reduceFactor) * | ||
1000 | ||
: 0, | ||
time: 0, | ||
millisecondsToSeconds | ||
: noTime, | ||
time: noTime, | ||
count: lifeOptions.count, | ||
}; | ||
if (particle.life.duration <= 0) { | ||
particle.life.duration = -1; | ||
if (particle.life.duration <= noTime) { | ||
particle.life.duration = infiniteValue; | ||
} | ||
if (particle.life.count <= 0) { | ||
particle.life.count = -1; | ||
if (particle.life.count <= noTime) { | ||
particle.life.count = infiniteValue; | ||
} | ||
if (particle.life) { | ||
particle.spawning = particle.life.delay > 0; | ||
particle.spawning = particle.life.delay > noTime; | ||
} | ||
@@ -60,4 +61,4 @@ } | ||
particle.spawning = false; | ||
life.delayTime = 0; | ||
life.time = 0; | ||
life.delayTime = noTime; | ||
life.time = noTime; | ||
} | ||
@@ -68,3 +69,3 @@ else { | ||
} | ||
if (life.duration === -1) { | ||
if (life.duration === infiniteValue) { | ||
return; | ||
@@ -76,3 +77,3 @@ } | ||
if (justSpawned) { | ||
life.time = 0; | ||
life.time = noTime; | ||
} | ||
@@ -85,23 +86,23 @@ else { | ||
} | ||
life.time = 0; | ||
if (particle.life.count > 0) { | ||
life.time = noTime; | ||
if (particle.life.count > noLife) { | ||
particle.life.count--; | ||
} | ||
if (particle.life.count === 0) { | ||
if (particle.life.count === noLife) { | ||
particle.destroy(); | ||
return; | ||
} | ||
const canvasSize = this.container.canvas.size, widthRange = setRangeValue(0, canvasSize.width), heightRange = setRangeValue(0, canvasSize.width); | ||
const canvasSize = this.container.canvas.size, widthRange = setRangeValue(minCanvasSize, canvasSize.width), heightRange = setRangeValue(minCanvasSize, canvasSize.width); | ||
particle.position.x = randomInRange(widthRange); | ||
particle.position.y = randomInRange(heightRange); | ||
particle.spawning = true; | ||
life.delayTime = 0; | ||
life.time = 0; | ||
life.delayTime = noTime; | ||
life.time = noTime; | ||
particle.reset(); | ||
const lifeOptions = particle.options.life; | ||
if (lifeOptions) { | ||
life.delay = getRangeValue(lifeOptions.delay.value) * 1000; | ||
life.duration = getRangeValue(lifeOptions.duration.value) * 1000; | ||
life.delay = getRangeValue(lifeOptions.delay.value) * millisecondsToSeconds; | ||
life.duration = getRangeValue(lifeOptions.duration.value) * millisecondsToSeconds; | ||
} | ||
} | ||
} |
{ | ||
"name": "@tsparticles/updater-life", | ||
"version": "3.0.3", | ||
"version": "3.1.0", | ||
"description": "tsParticles particles life updater", | ||
@@ -90,3 +90,3 @@ "homepage": "https://particles.js.org", | ||
"dependencies": { | ||
"@tsparticles/engine": "^3.0.3" | ||
"@tsparticles/engine": "^3.1.0" | ||
}, | ||
@@ -93,0 +93,0 @@ "publishConfig": { |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v3.0.3 | ||
* v3.1.0 | ||
*/ | ||
@@ -157,2 +157,7 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
const noTime = 0, | ||
identity = 1, | ||
infiniteValue = -1, | ||
noLife = 0, | ||
minCanvasSize = 0; | ||
class LifeUpdater { | ||
@@ -170,16 +175,16 @@ constructor(container) { | ||
particle.life = { | ||
delay: container.retina.reduceFactor ? (0,engine_root_window_.getRangeValue)(lifeOptions.delay.value) * (lifeOptions.delay.sync ? 1 : (0,engine_root_window_.getRandom)()) / container.retina.reduceFactor * 1000 : 0, | ||
delayTime: 0, | ||
duration: container.retina.reduceFactor ? (0,engine_root_window_.getRangeValue)(lifeOptions.duration.value) * (lifeOptions.duration.sync ? 1 : (0,engine_root_window_.getRandom)()) / container.retina.reduceFactor * 1000 : 0, | ||
time: 0, | ||
delay: container.retina.reduceFactor ? (0,engine_root_window_.getRangeValue)(lifeOptions.delay.value) * (lifeOptions.delay.sync ? identity : (0,engine_root_window_.getRandom)()) / container.retina.reduceFactor * engine_root_window_.millisecondsToSeconds : noTime, | ||
delayTime: noTime, | ||
duration: container.retina.reduceFactor ? (0,engine_root_window_.getRangeValue)(lifeOptions.duration.value) * (lifeOptions.duration.sync ? identity : (0,engine_root_window_.getRandom)()) / container.retina.reduceFactor * engine_root_window_.millisecondsToSeconds : noTime, | ||
time: noTime, | ||
count: lifeOptions.count | ||
}; | ||
if (particle.life.duration <= 0) { | ||
particle.life.duration = -1; | ||
if (particle.life.duration <= noTime) { | ||
particle.life.duration = infiniteValue; | ||
} | ||
if (particle.life.count <= 0) { | ||
particle.life.count = -1; | ||
if (particle.life.count <= noTime) { | ||
particle.life.count = infiniteValue; | ||
} | ||
if (particle.life) { | ||
particle.spawning = particle.life.delay > 0; | ||
particle.spawning = particle.life.delay > noTime; | ||
} | ||
@@ -209,4 +214,4 @@ } | ||
particle.spawning = false; | ||
life.delayTime = 0; | ||
life.time = 0; | ||
life.delayTime = noTime; | ||
life.time = noTime; | ||
} else { | ||
@@ -216,3 +221,3 @@ return; | ||
} | ||
if (life.duration === -1) { | ||
if (life.duration === infiniteValue) { | ||
return; | ||
@@ -224,3 +229,3 @@ } | ||
if (justSpawned) { | ||
life.time = 0; | ||
life.time = noTime; | ||
} else { | ||
@@ -232,7 +237,7 @@ life.time += delta.value; | ||
} | ||
life.time = 0; | ||
if (particle.life.count > 0) { | ||
life.time = noTime; | ||
if (particle.life.count > noLife) { | ||
particle.life.count--; | ||
} | ||
if (particle.life.count === 0) { | ||
if (particle.life.count === noLife) { | ||
particle.destroy(); | ||
@@ -242,14 +247,14 @@ return; | ||
const canvasSize = this.container.canvas.size, | ||
widthRange = (0,engine_root_window_.setRangeValue)(0, canvasSize.width), | ||
heightRange = (0,engine_root_window_.setRangeValue)(0, canvasSize.width); | ||
widthRange = (0,engine_root_window_.setRangeValue)(minCanvasSize, canvasSize.width), | ||
heightRange = (0,engine_root_window_.setRangeValue)(minCanvasSize, canvasSize.width); | ||
particle.position.x = (0,engine_root_window_.randomInRange)(widthRange); | ||
particle.position.y = (0,engine_root_window_.randomInRange)(heightRange); | ||
particle.spawning = true; | ||
life.delayTime = 0; | ||
life.time = 0; | ||
life.delayTime = noTime; | ||
life.time = noTime; | ||
particle.reset(); | ||
const lifeOptions = particle.options.life; | ||
if (lifeOptions) { | ||
life.delay = (0,engine_root_window_.getRangeValue)(lifeOptions.delay.value) * 1000; | ||
life.duration = (0,engine_root_window_.getRangeValue)(lifeOptions.duration.value) * 1000; | ||
life.delay = (0,engine_root_window_.getRangeValue)(lifeOptions.delay.value) * engine_root_window_.millisecondsToSeconds; | ||
life.duration = (0,engine_root_window_.getRangeValue)(lifeOptions.duration.value) * engine_root_window_.millisecondsToSeconds; | ||
} | ||
@@ -256,0 +261,0 @@ } |
/*! For license information please see tsparticles.updater.life.min.js.LICENSE.txt */ | ||
!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 n="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},n={};function i(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{i.r(o),i.d(o,{loadLifeUpdater:()=>s});var e=i(533);class t extends e.ValueWithRandom{constructor(){super(),this.sync=!1}load(e){e&&(super.load(e),void 0!==e.sync&&(this.sync=e.sync))}}class n extends e.ValueWithRandom{constructor(){super(),this.sync=!1}load(e){e&&(super.load(e),void 0!==e.sync&&(this.sync=e.sync))}}class a{constructor(){this.count=0,this.delay=new t,this.duration=new n}load(e){e&&(void 0!==e.count&&(this.count=e.count),this.delay.load(e.delay),this.duration.load(e.duration))}}class r{constructor(e){this.container=e}init(t){const n=this.container,i=t.options.life;i&&(t.life={delay:n.retina.reduceFactor?(0,e.getRangeValue)(i.delay.value)*(i.delay.sync?1:(0,e.getRandom)())/n.retina.reduceFactor*1e3:0,delayTime:0,duration:n.retina.reduceFactor?(0,e.getRangeValue)(i.duration.value)*(i.duration.sync?1:(0,e.getRandom)())/n.retina.reduceFactor*1e3:0,time:0,count:i.count},t.life.duration<=0&&(t.life.duration=-1),t.life.count<=0&&(t.life.count=-1),t.life&&(t.spawning=t.life.delay>0))}isEnabled(e){return!e.destroyed}loadOptions(e,...t){e.life||(e.life=new a);for(const n of t)e.life.load(n?.life)}update(t,n){if(!this.isEnabled(t)||!t.life)return;const i=t.life;let o=!1;if(t.spawning){if(i.delayTime+=n.value,!(i.delayTime>=t.life.delay))return;o=!0,t.spawning=!1,i.delayTime=0,i.time=0}if(-1===i.duration)return;if(t.spawning)return;if(o?i.time=0:i.time+=n.value,i.time<i.duration)return;if(i.time=0,t.life.count>0&&t.life.count--,0===t.life.count)return void t.destroy();const a=this.container.canvas.size,r=(0,e.setRangeValue)(0,a.width),s=(0,e.setRangeValue)(0,a.width);t.position.x=(0,e.randomInRange)(r),t.position.y=(0,e.randomInRange)(s),t.spawning=!0,i.delayTime=0,i.time=0,t.reset();const l=t.options.life;l&&(i.delay=1e3*(0,e.getRangeValue)(l.delay.value),i.duration=1e3*(0,e.getRangeValue)(l.duration.value))}}async function s(e,t=!0){await e.addParticleUpdater("life",(e=>new r(e)),t)}})(),o})())); | ||
!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 n="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},n={};function i(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{i.r(o),i.d(o,{loadLifeUpdater:()=>s});var e=i(533);class t extends e.ValueWithRandom{constructor(){super(),this.sync=!1}load(e){e&&(super.load(e),void 0!==e.sync&&(this.sync=e.sync))}}class n extends e.ValueWithRandom{constructor(){super(),this.sync=!1}load(e){e&&(super.load(e),void 0!==e.sync&&(this.sync=e.sync))}}class a{constructor(){this.count=0,this.delay=new t,this.duration=new n}load(e){e&&(void 0!==e.count&&(this.count=e.count),this.delay.load(e.delay),this.duration.load(e.duration))}}class r{constructor(e){this.container=e}init(t){const n=this.container,i=t.options.life;i&&(t.life={delay:n.retina.reduceFactor?(0,e.getRangeValue)(i.delay.value)*(i.delay.sync?1:(0,e.getRandom)())/n.retina.reduceFactor*e.millisecondsToSeconds:0,delayTime:0,duration:n.retina.reduceFactor?(0,e.getRangeValue)(i.duration.value)*(i.duration.sync?1:(0,e.getRandom)())/n.retina.reduceFactor*e.millisecondsToSeconds:0,time:0,count:i.count},t.life.duration<=0&&(t.life.duration=-1),t.life.count<=0&&(t.life.count=-1),t.life&&(t.spawning=t.life.delay>0))}isEnabled(e){return!e.destroyed}loadOptions(e,...t){e.life||(e.life=new a);for(const n of t)e.life.load(n?.life)}update(t,n){if(!this.isEnabled(t)||!t.life)return;const i=t.life;let o=!1;if(t.spawning){if(i.delayTime+=n.value,!(i.delayTime>=t.life.delay))return;o=!0,t.spawning=!1,i.delayTime=0,i.time=0}if(-1===i.duration)return;if(t.spawning)return;if(o?i.time=0:i.time+=n.value,i.time<i.duration)return;if(i.time=0,t.life.count>0&&t.life.count--,0===t.life.count)return void t.destroy();const a=this.container.canvas.size,r=(0,e.setRangeValue)(0,a.width),s=(0,e.setRangeValue)(0,a.width);t.position.x=(0,e.randomInRange)(r),t.position.y=(0,e.randomInRange)(s),t.spawning=!0,i.delayTime=0,i.time=0,t.reset();const l=t.options.life;l&&(i.delay=(0,e.getRangeValue)(l.delay.value)*e.millisecondsToSeconds,i.duration=(0,e.getRangeValue)(l.duration.value)*e.millisecondsToSeconds)}}async function s(e,t=!0){await e.addParticleUpdater("life",(e=>new r(e)),t)}})(),o})())); |
@@ -1,1 +0,1 @@ | ||
/*! tsParticles Life Updater v3.0.3 by Matteo Bruni */ | ||
/*! tsParticles Life Updater v3.1.0 by Matteo Bruni */ |
@@ -15,2 +15,3 @@ (function (factory) { | ||
const Life_js_1 = require("./Options/Classes/Life.js"); | ||
const noTime = 0, identity = 1, infiniteValue = -1, noLife = 0, minCanvasSize = 0; | ||
class LifeUpdater { | ||
@@ -27,23 +28,23 @@ constructor(container) { | ||
delay: container.retina.reduceFactor | ||
? (((0, engine_1.getRangeValue)(lifeOptions.delay.value) * (lifeOptions.delay.sync ? 1 : (0, engine_1.getRandom)())) / | ||
? (((0, engine_1.getRangeValue)(lifeOptions.delay.value) * (lifeOptions.delay.sync ? identity : (0, engine_1.getRandom)())) / | ||
container.retina.reduceFactor) * | ||
1000 | ||
: 0, | ||
delayTime: 0, | ||
engine_1.millisecondsToSeconds | ||
: noTime, | ||
delayTime: noTime, | ||
duration: container.retina.reduceFactor | ||
? (((0, engine_1.getRangeValue)(lifeOptions.duration.value) * (lifeOptions.duration.sync ? 1 : (0, engine_1.getRandom)())) / | ||
? (((0, engine_1.getRangeValue)(lifeOptions.duration.value) * (lifeOptions.duration.sync ? identity : (0, engine_1.getRandom)())) / | ||
container.retina.reduceFactor) * | ||
1000 | ||
: 0, | ||
time: 0, | ||
engine_1.millisecondsToSeconds | ||
: noTime, | ||
time: noTime, | ||
count: lifeOptions.count, | ||
}; | ||
if (particle.life.duration <= 0) { | ||
particle.life.duration = -1; | ||
if (particle.life.duration <= noTime) { | ||
particle.life.duration = infiniteValue; | ||
} | ||
if (particle.life.count <= 0) { | ||
particle.life.count = -1; | ||
if (particle.life.count <= noTime) { | ||
particle.life.count = infiniteValue; | ||
} | ||
if (particle.life) { | ||
particle.spawning = particle.life.delay > 0; | ||
particle.spawning = particle.life.delay > noTime; | ||
} | ||
@@ -73,4 +74,4 @@ } | ||
particle.spawning = false; | ||
life.delayTime = 0; | ||
life.time = 0; | ||
life.delayTime = noTime; | ||
life.time = noTime; | ||
} | ||
@@ -81,3 +82,3 @@ else { | ||
} | ||
if (life.duration === -1) { | ||
if (life.duration === infiniteValue) { | ||
return; | ||
@@ -89,3 +90,3 @@ } | ||
if (justSpawned) { | ||
life.time = 0; | ||
life.time = noTime; | ||
} | ||
@@ -98,21 +99,21 @@ else { | ||
} | ||
life.time = 0; | ||
if (particle.life.count > 0) { | ||
life.time = noTime; | ||
if (particle.life.count > noLife) { | ||
particle.life.count--; | ||
} | ||
if (particle.life.count === 0) { | ||
if (particle.life.count === noLife) { | ||
particle.destroy(); | ||
return; | ||
} | ||
const canvasSize = this.container.canvas.size, widthRange = (0, engine_1.setRangeValue)(0, canvasSize.width), heightRange = (0, engine_1.setRangeValue)(0, canvasSize.width); | ||
const canvasSize = this.container.canvas.size, widthRange = (0, engine_1.setRangeValue)(minCanvasSize, canvasSize.width), heightRange = (0, engine_1.setRangeValue)(minCanvasSize, canvasSize.width); | ||
particle.position.x = (0, engine_1.randomInRange)(widthRange); | ||
particle.position.y = (0, engine_1.randomInRange)(heightRange); | ||
particle.spawning = true; | ||
life.delayTime = 0; | ||
life.time = 0; | ||
life.delayTime = noTime; | ||
life.time = noTime; | ||
particle.reset(); | ||
const lifeOptions = particle.options.life; | ||
if (lifeOptions) { | ||
life.delay = (0, engine_1.getRangeValue)(lifeOptions.delay.value) * 1000; | ||
life.duration = (0, engine_1.getRangeValue)(lifeOptions.duration.value) * 1000; | ||
life.delay = (0, engine_1.getRangeValue)(lifeOptions.delay.value) * engine_1.millisecondsToSeconds; | ||
life.duration = (0, engine_1.getRangeValue)(lifeOptions.duration.value) * engine_1.millisecondsToSeconds; | ||
} | ||
@@ -119,0 +120,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
323601
1110
Updated@tsparticles/engine@^3.1.0