allow for speed=0
This commit is contained in:
parent
384589e9a2
commit
3983287420
@ -8,7 +8,7 @@
|
||||
href="css/index.min.css"
|
||||
crossorigin="anonymous"/>
|
||||
</head>
|
||||
<body onload='particles(avoidMouse=false)'>
|
||||
<body onload='particles(avoidMouse=false, speed=5)'>
|
||||
<canvas id="particles"></canvas>
|
||||
<!-- javascript -->
|
||||
<script
|
||||
|
@ -20,7 +20,7 @@ function particles(){
|
||||
canvas.height = window.innerHeight;
|
||||
|
||||
let particlesArray;
|
||||
speed = speed / 100; // index speed to base 100 = 1
|
||||
speed = (speed !== 0) ? (speed / 100) : 0; // index speed to base 100 = 1
|
||||
|
||||
// get mouse position
|
||||
let mousePosition ={
|
||||
@ -84,8 +84,10 @@ function particles(){
|
||||
}
|
||||
|
||||
// move particle
|
||||
this.x += this.directionX * speed;
|
||||
this.y += this.directionY * speed;
|
||||
if (speed !== 0) {
|
||||
this.x += this.directionX * speed;
|
||||
this.y += this.directionY * speed;
|
||||
}
|
||||
|
||||
// draw particle
|
||||
this.draw();
|
||||
@ -224,7 +226,7 @@ function particles(){
|
||||
if (typeof speed == 'undefined'){
|
||||
speed = 50;
|
||||
}
|
||||
if (Number.isInteger(speed) && (1 <= speed && speed <= 1000)){
|
||||
if (Number.isInteger(speed) && (0 <= speed && speed <= 1000)){
|
||||
speed;
|
||||
}
|
||||
else{
|
||||
|
Loading…
Reference in New Issue
Block a user