#7488 closed bug (worksforme)
.offset() function incorrect when ancestor uses -webkit-transform
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | 1.5 |
Component: | offset | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When an element is transformed with the -webkit-transform attribute, the offset() function no longer works correctly for its child elements.
The -webkit-transform attribute is most notably used in Google Maps v3 on Chrome.
As a very restricted workaround, which ignores scale and rotation but at least works for Google Maps, you can do:
var pos = $elm.offset(); $elm.parents().each(function(n,e) { var wt = e.style.WebkitTransform; if (!wt) return; var match = wt.match(/translate\((.+)px, (.+)px\)/); if (!match) return; pos.top += parseInt(match[2]); pos.left += parseInt(match[1]); });
Change History (6)
comment:1 Changed 12 years ago by
Owner: | set to [email protected]… |
---|---|
Status: | new → pending |
comment:2 Changed 12 years ago by
Component: | unfiled → offset |
---|---|
Priority: | undecided → low |
comment:3 Changed 12 years ago by
Status: | pending → new |
---|
Thank you for your response.
While generating a test case. I seem to have localized the problem. I've reduced my project to contain only google maps and a balloon at http://remaptheworld.com/remap.dev/site/test.html .
The problem is still there but it is gone when you remove the reference to the dimensions plugin. Somehow that plugin interferes with the offset() functionality...
comment:4 Changed 12 years ago by
The problem can also be reproduced by adding the dimensions plugin to the above jsfiddle snippet by boushly.
I understand now that the dimensions plugin has become obsolete. It actually seems to do more harm then good.
I've included it in my project because the tootip plugin stated that it needed it. Maybe it would be good to remove the dimensions plugin from the plugin library or to clarify that it is obsolete, because currently it is listed and referenced by other plugins.
comment:5 Changed 12 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Looking through the dimensions plugin I believe that as you mention it requires an update and is a cause of the issues you've been experiencing with offset() - offset() itself appears to be working fine. As such we will be closing this ticket with that as the reason. On plugins, we are currently re-doing the plugin site and will be relaunching it at some point with a cleaned list of plugins. Thank you for highlighting that this plugin is no longer usable with up to date versions of jQuery.
comment:6 Changed 12 years ago by
Well the dimensions plugin page states
As of jQuery 1.2.6, the dimensions plugin has been merged into core.
And I guess this note is there for a long time now. So you should report to Jörn Zaefferer that he should remove the
Depends on jquery.dimensions.js
note from http://docs.jquery.com/Plugins/Tooltip
Thanks for taking the time to contribute to the jQuery project. I've produced a jsFiddle case for this that seems to work just fine http://jsfiddle.net/boushley/TcbXf/ If you can give us a reduced test case showing the error, then we can work on the issue.