CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   Is there a better way to capture mouse (http://www.codingforums.com/showthread.php?t=287471)

m2244 02-11-2013 07:59 PM

Is there a better way to capture mouse
 
So I am capturing the mouse X and Y positions like this:
Code:

$(document).ready(function(){
$(document).mousemove(function(e){
        mouseX = e.pageX
  });
});

And then later, when a user hovers over a link, I want to have a tool tip show up near their cursor.

My question is; Is there a better way to capture the mouse position other than constantly listening for the mouse move? Can I add the mouseMove listener to the link in question?

WolfShade 02-11-2013 08:06 PM

There is a library for tooltips called "overLib" that you can set it so that the tooltip follows the mouse around. Much simpler.

rnd me 02-12-2013 03:43 PM

i find it more consistent to inject the tooptip next to the link, so that they share a parent.
i can then use simple relative positioning CSS to show the tip.

with absolute positioning, you have to wrorry about scrolling, zoom, container display mode, and edge of viewport issues, but with simple toggled sibling content, it's magically in the right place every time.


All times are GMT +1. The time now is 02:36 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.