Fix Location#get function to work with body element in IE
When Location#get is called for body element with "scroll" mode in IE,
the returned value is not correct (the scroll offset is not taken into
account).
In IE body.scrollTop/Left always return zero.
To fix the issue, for body element only, use
rwt.html.Viewport.getScrollTop/Left instead.
Change-Id: I7207797da1117b39a120c0e51d6f608c8c1a971a
Signed-off-by: Elshad Seyidmammadov <elshad@eclipsesource.com>
diff --git a/bundles/org.eclipse.rap.rwt/js/rwt/html/Location.js b/bundles/org.eclipse.rap.rwt/js/rwt/html/Location.js
index 27d93db..af4012e 100644
--- a/bundles/org.eclipse.rap.rwt/js/rwt/html/Location.js
+++ b/bundles/org.eclipse.rap.rwt/js/rwt/html/Location.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright: 2004, 2015 1&1 Internet AG, Germany, http://www.1und1.de,
+ * Copyright: 2004, 2016 1&1 Internet AG, Germany, http://www.1und1.de,
* and EclipseSource
*
* This program and the accompanying materials are made available under the
@@ -359,8 +359,8 @@
get : function(elem, mode)
{
var body = this.__computeBody(elem);
-
- if (elem.tagName == "BODY")
+ var isBody = elem.tagName == "BODY";
+ if (isBody)
{
var left = body.left;
var top = body.top;
@@ -401,10 +401,10 @@
bottom -= this.__num(elem, "paddingBottom");
}
if( mode === "padding" || mode === "scroll" ) {
- left -= elem.scrollLeft;
- top -= elem.scrollTop;
- right -= elem.scrollLeft;
- bottom -= elem.scrollTop;
+ left -= isBody ? rwt.html.Viewport.getScrollLeft() : elem.scrollLeft;
+ top -= isBody ? rwt.html.Viewport.getScrollTop() : elem.scrollTop;
+ right -= isBody ? rwt.html.Viewport.getScrollLeft() : elem.scrollLeft;
+ bottom -= isBody ? rwt.html.Viewport.getScrollTop() : elem.scrollTop;
}
if( mode === "padding" || mode === "scroll" || mode === "border" ) {
left += this.__num(elem, "borderLeftWidth");