From abec1332894f7067ba0909364fe0e02cdc34430d Mon Sep 17 00:00:00 2001 From: lindelof Date: Fri, 29 Nov 2019 11:07:40 +0800 Subject: [PATCH] add random --- src/particles-bg/ParticlesBg.vue | 28 +++++++++++++++------------- src/particles-bg/utils/Rand.js | 2 ++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/particles-bg/ParticlesBg.vue b/src/particles-bg/ParticlesBg.vue index 16d0ac9..07d4932 100644 --- a/src/particles-bg/ParticlesBg.vue +++ b/src/particles-bg/ParticlesBg.vue @@ -56,20 +56,22 @@ export default { return +this.num; }, getRandom: function() { - if (!this.rand) { - this.rand = new Rand(); - this.rand.set(0.25, "color-particles"); - this.rand.set(0.2, "ball-particles"); - this.rand.set(0.2, "circle-particles"); - this.rand.set(0.2, "cobweb-particles"); - this.rand.set(0.2, "thick-particles"); - this.rand.set(0.2, "lines-particles"); - this.rand.set(0.2, "fountain-particles"); - this.rand.set(0.2, "polygon-particles"); - this.rand.set(0.2, "square-particles"); - this.rand.set(0.2, "tadpole-particles"); + if (!this.random) { + // Code source from here, thanks author + // https://github.com/a-jie/Proton/blob/gh-pages/source/src/utils/Rand.js + this.random = new Rand(); + this.random.set(0.25, "color-particles"); + this.random.set(0.2, "ball-particles"); + this.random.set(0.2, "circle-particles"); + this.random.set(0.2, "cobweb-particles"); + this.random.set(0.2, "thick-particles"); + this.random.set(0.2, "lines-particles"); + this.random.set(0.2, "fountain-particles"); + this.random.set(0.2, "polygon-particles"); + this.random.set(0.2, "square-particles"); + this.random.set(0.2, "tadpole-particles"); } - return this.rand.getResult(); + return this.random.getResult(); }, setParticles: function() { diff --git a/src/particles-bg/utils/Rand.js b/src/particles-bg/utils/Rand.js index 1d9482a..b82b885 100755 --- a/src/particles-bg/utils/Rand.js +++ b/src/particles-bg/utils/Rand.js @@ -1,3 +1,5 @@ +// Code source from here, thanks author +// https://github.com/a-jie/Proton/blob/gh-pages/source/src/utils/Rand.js class Rand { constructor() {