tholman / cursor-effects

Old-school cursor effects for your browser built with modern JavaScript
https://tholman.com/cursor-effects
3.41k stars 252 forks source link

Too many particles are created when Chrome DevTools is opened #10

Closed MichaelMandel26 closed 4 years ago

MichaelMandel26 commented 5 years ago

Hey I figured out, that if you open Chromes DevTools on a site, where your particle code is applied, there are too many particles being created.

I dont know why it happens but it does. Although it is not really a dealbreaker I thought that you may be interested in taking a look at it.

Bob-Wright commented 5 years ago

modified bubble generation rate to burp a bubble on 1% of screen width or height cursor motion.

function onMouseMove(e) {
//cursor.x = e.clientX; //cursor.y = e.clientY; // burp a bubble every time cursor is moved 1% or more of width or height if ((Math.abs(cursor.x - e.clientX) > (width .01)) || (Math.abs(cursor.y - e.clientY) > (width .01))) { cursor.y = e.clientY; cursor.x = e.clientX; addParticle( cursor.x, cursor.y); } } also, above that you need to mod the screen size get // get viewport dimensions //var width = window.innerWidth; //var height = window.innerHeight; var width = Math.min(document.documentElement.clientWidth, window.innerWidth || 0); var height = Math.min(document.documentElement.clientHeight, window.innerHeight || 0); var cursor = {x: width, y: height};

hope that helps. i have some mods to the cursor files i'd like to share but clueless how. cheers!

tholman commented 4 years ago

fixed in the rewrite, folded on keeping the shifty 90's era dom element style and used canvas.