Opened 15 years ago
Closed 15 years ago
#1834 closed bug (wontfix)
event.clientX and clientY incorrect for Safari2
Reported by: | jeffkretz | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.2.2 |
Component: | event | Version: | 1.2.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
This is factually a bug/incompatibility in Safari, but the event normalization done in jQuery can address this issue.
For IE6, IE7, FF and Safari, on a click event, the clientX and clientY values are relative to the top left of the viewport. For Safari 2, they are relative to the top left of the document.
If you scroll down or to the right, the clientX and clientY for Safari is different from all the other browsers.
Sample page here:
http://www.scorpiontechnology.com/cobalt/mouseclick.htm
One fix would be to add this right after the pageX/Y normalization script under the event.fix method:
// Fix clientX/Y for Safari. if (jQuery.browser.safari) { var doc = document.documentElement, body = document.body; event.clientX = event.clientX - (doc && doc.scrollLeft || body && body.scrollLeft || 0) + (doc.clientLeft || 0); event.clientY = event.clientY - (doc && doc.scrollTop || body && body.scrollTop || 0) + (doc.clientLeft || 0); }
This can be seen working on this page:
http://www.scorpiontechnology.com/cobalt/mouseclick_fix.htm
JK
Change History (3)
comment:1 Changed 15 years ago by
comment:2 Changed 15 years ago by
Component: | core → event |
---|
comment:3 Changed 15 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
This is resolved in Safari 3
Correction:
For IE6, IE7, FF and Opera, on a click event ...