Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lindelof committed Dec 9, 2019
1 parent a9040f1 commit ab01256
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "particles-bg-vue",
"version": "1.1.2",
"version": "1.1.3",
"description": "Vue.js component for particles backgrounds",
"author": "creotip@gmail.com",
"license": "MIT",
Expand Down
3 changes: 2 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div id="app">
<div>
<div>hello world</div>
<particles-bg type="custom" :config="config" :canvas="canvasStyle" :bg="true" />
<particles-bg type="list" :list="list" :config="config" :canvas="canvasStyle" :bg="true" />
</div>
</div>
</template>
Expand All @@ -17,6 +17,7 @@ export default {
},
data() {
return {
list:["lines", "circle"],
config:{},
canvasStyle:{
// height:"199px"
Expand Down
19 changes: 12 additions & 7 deletions src/particles-bg/ParticlesBg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default {
getNum() {
return +this.num;
},
getRandom: function() {
getRandom() {
if (!this.random) {
// Code source from here, thanks author
// https://github.com/a-jie/Proton/blob/gh-pages/source/src/utils/Rand.js
Expand All @@ -82,16 +82,21 @@ export default {
},
getFromList(){
if(!list) return this.getRandom();
return list[Math.floor(Math.random() * list.length)];
if(!this.list) return this.getRandom();
let item = this.list[Math.floor(Math.random() * this.list.length)];
item = this.transformName(item);
return item;
},
setParticles: function() {
const type = this.type;
let name = String(type).toLowerCase() || "random";
transformName(name){
name = String(name).toLowerCase() || "random";
if (name.indexOf("-") <= 0) name += "-particles";
return name;
},
this.particles = name;
setParticles() {
this.particles = this.transformName(this.type);
if (this.particles.indexOf("random") === 0) {
this.particles = this.getRandom();
}
Expand Down

0 comments on commit ab01256

Please sign in to comment.