[jQuery] Re: finding mouse position within a div with a scrollbar

2009-04-24 Thread Charlie Park
Marv - I could be mistaken here, but I think your solution's really good so long as the entire sub-element (the DIV or image or whatever) is visible. But if there's a scrollbar on that element, I think your code will only tell you where you clicked in terms of the position on the page (relative t

[jQuery] Re: finding mouse position within a div with a scrollbar

2009-04-23 Thread Marv
Here's an excerpt from my click event that determines the mouse coordinates for a click regardless of horizontal / vertical scrolling of the page or the clicked image: $('#img1').live('click', function(e) { var locX = Math.round(e.pageX - $(this).offset().left); var locY = Math.

[jQuery] Re: finding mouse position within a div with a scrollbar

2009-04-22 Thread Charlie Park
We ended up using scrollTop to determine the amount of the div that was obscured. I'm new to jQuery (and javascript in general), so my code could probably stand to be refactored a bit. But here's the solution we came up with. The relevant structure of the page is: ... (this runs horizontally,