+ 17

Particles Animation Not Working Well

https://code.sololearn.com/WNIUUpKd7C9h/?ref=app i am using javascript Canvas to make a animation effect on mouseover, means when you start touching in screen particle size will start increase and when you go far from that particle than it will regain its initial size, But it is not working properly, means in JavaScript line 58 else statement not running when mouse go far from particle🙁 Please answer As Soon As Possible

13th Aug 2021, 5:25 PM
Mask Man(What's in a name?)
Mask Man(What's in a name?) - avatar
9 Respostas
+ 5
Actually, everything is working perfectly, your problem is that you are not clearing the canvas. So the partciples are returning to the right size but you cant tell because the big ones are still there. Add this to the very top of your animate function: ctx.clearRect(0, 0, innerWidth, innerHeight); Happy coding 😉 Ps. You might want to change your canvas position from absolute to fixed. It works better on iOS
13th Aug 2021, 5:53 PM
Brain & Bones
Brain & Bones - avatar
+ 4
You should clear canvas everytime animate is called, otherwise you are just drawing on top of it . Place the following line at the very top of animate function. ctx.clearRect(0,0,canvas.width,canvas.height);
13th Aug 2021, 5:54 PM
Abhay
Abhay - avatar
+ 2
Lol Abhay did we post our answers at the same time? 😂
13th Aug 2021, 5:58 PM
Brain & Bones
Brain & Bones - avatar
+ 2
Alternatively, you can try this: ctx.fillStyle = "rgba(0,0,0,0.05)"; ctx.fillRect(0,0,canvas.width,canvas.height);
14th Aug 2021, 9:08 AM
Nor'wester đŸŒȘ đŸ‡§đŸ‡© (INACTIVE)
Nor'wester đŸŒȘ đŸ‡§đŸ‡© (INACTIVE) - avatar
+ 1
Brain & Bones Abhay đŸ€Ż Thanks, I thought it was a big mistake, but 🙁, Thank You Very Much
13th Aug 2021, 5:55 PM
Mask Man(What's in a name?)
Mask Man(What's in a name?) - avatar
+ 1
Brain & Bones yes Abhay was just 3,4 second late, that's why i marked Your answer as best
13th Aug 2021, 6:02 PM
Mask Man(What's in a name?)
Mask Man(What's in a name?) - avatar
0
Ok
14th Aug 2021, 9:51 AM
Gangotri Agarwal
0
Gsm
14th Aug 2021, 9:51 AM
Gangotri Agarwal
0
what is the animation in particle.
14th Aug 2021, 10:52 AM
Shubham Bhatia
Shubham Bhatia - avatar