Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you create "aura" effect from the mouse pointer?

If you open google chrome and open multiple tabs, you see the effect by hovering over a background tab. The pointer will have an "aura" effect which follows it around.

To clarify, I'm NOT asking how to make the entire tab glow a lighter color, I'm asking how to give the pointer the effect within some specified radius of it.

like image 357
CDelaney Avatar asked May 05 '11 18:05

CDelaney


2 Answers

The key part is to get the mouse coordinates, then to place a radial gradient with those coordinates.

var originalBG = $(".nav a").css("background-color");

$('.nav li:not(".active") a').mousemove(function(e) {
    x = e.pageX - this.offsetLeft;
    y = e.pageY - this.offsetTop;
    xy = x + " " + y;
    bgWebKit = "-webkit-gradient(radial, " + xy + ", 0, " + xy + ", 100, from(rgba(255,255,255,0.8)), to(rgba(255,255,255,0.0))), " + originalBG;
    bgMoz = "-moz-radial-gradient(" + x + "px " + y + "px 45deg, circle, " + lightColor + " 0%, " + originalBG + " " + gradientSize + "px)";

    $(this)
        .css({background: bgWebKit})
        .css({background: bgMoz});
    }).mouseleave(function() {
    $(this).css({
        background: originalBG
    });
});

Something like that will do the job.

Check this demo from the illustrious Chris Coyier: http://css-tricks.com/examples/MovingHighlight/

like image 190
Rich Bradshaw Avatar answered Oct 27 '22 18:10

Rich Bradshaw


some ideas --

  1. use javascript to place an absolutely positioned semitransparent png under the cursor position
  2. create a .cur file with your own cursor and some semi-transparent glow under it and hope the browser can render it
  3. replace the entire cursor with javascript
like image 21
davidosomething Avatar answered Oct 27 '22 20:10

davidosomething