Jump to content

[SOLVED] follow the mouse


michaellunsford

Recommended Posts

so, I've made a pretty useful script that's supposed to follow the mouse with a popup div. problem is, I'm using clientY to track the vertical mouse position. It works great at the top, but doesn't take the scroll into account...

 

example:

http://68.228.8.85/CutieContest/index.php

 

mouse over the top section of photos -- works great... scroll down a little and you'll see the scroll start to place the div higher on the screen. If you continue to the bottom, the div eventually doesn't even show up at all.

 

nutshell:

function resetDivPos(event) {
d=document.getElementById("preview_window").style;
y=event.clientY;
x=event.clientX;
d.top = (y + 5) + "px";
d.left = (x + 5 + 450>window.innerWidth? x - 400 - 5 : x + 5) + "px";
}

 

What's missing?

Link to comment
https://forums.phpfreaks.com/topic/74018-solved-follow-the-mouse/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.