diff options
author | Artur Signell <artur.signell@itmill.com> | 2011-06-07 14:54:41 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2011-06-07 14:54:41 +0000 |
commit | 0d4fd529749e962316cdd2caafe15ec697ff6644 (patch) | |
tree | 7064d2862037a91062c17de510c9c3429c1e493d | |
parent | 11b7d55d90176db9b9dd99b5a3ccd82e91abd9b6 (diff) | |
download | vaadin-framework-0d4fd529749e962316cdd2caafe15ec697ff6644.tar.gz vaadin-framework-0d4fd529749e962316cdd2caafe15ec697ff6644.zip |
#7115 Fixes VOverlay offset in IE6/IE7 when body is set to position: relative
svn changeset:19270/svn branch:6.6
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VOverlay.java | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java b/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java index ae8b2dd9c3..b301fd3861 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java @@ -155,18 +155,32 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { private static int adjustByRelativeTopBodyMargin() { if (topFix == -1) { - topFix = detectRelativeBodyFixes("top"); + boolean ie6OrIe7 = BrowserInfo.get().isIE() + && BrowserInfo.get().getIEVersion() <= 7; + topFix = detectRelativeBodyFixes("top", ie6OrIe7); } return topFix; } - private native static int detectRelativeBodyFixes(String axis) + private native static int detectRelativeBodyFixes(String axis, + boolean removeClientLeftOrTop) /*-{ try { var b = $wnd.document.body; var cstyle = b.currentStyle ? b.currentStyle : getComputedStyle(b); if(cstyle && cstyle.position == 'relative') { - return b.getBoundingClientRect()[axis]; + var offset = b.getBoundingClientRect()[axis]; + if (removeClientLeftOrTop) { + // IE6 and IE7 include the top left border of the client area into the boundingClientRect + var clientTopOrLeft = 0; + if (axis == "top") + clientTopOrLeft = $wnd.document.documentElement.clientTop; + else + clientTopOrLeft = $wnd.document.documentElement.clientLeft; + + offset -= clientTopOrLeft; + } + return offset; } } catch(e){} return 0; @@ -174,7 +188,10 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { private static int adjustByRelativeLeftBodyMargin() { if (leftFix == -1) { - leftFix = detectRelativeBodyFixes("left"); + boolean ie6OrIe7 = BrowserInfo.get().isIE() + && BrowserInfo.get().getIEVersion() <= 7; + leftFix = detectRelativeBodyFixes("left", ie6OrIe7); + } return leftFix; } |