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