mirror of
https://github.com/vaadin/framework.git
synced 2024-09-13 15:46:01 +02:00
Fix for #2253 - Use getBoundingClientRect() for measuring elements when available.
svn changeset:6090/svn branch:trunk
This commit is contained in:
parent
c0d846ba0a
commit
9a602ddcc7
@ -189,8 +189,9 @@ public class ChildComponentContainer extends Panel {
|
||||
* Widget wrapper includes margin which the widget offsetWidth/Height
|
||||
* does not include
|
||||
*/
|
||||
int w = widgetDIV.getOffsetWidth();
|
||||
int h = widgetDIV.getOffsetHeight();
|
||||
int w = getRequiredWidth(widgetDIV);
|
||||
int h = getRequiredHeight(widgetDIV);
|
||||
|
||||
widgetSize.setWidth(w);
|
||||
widgetSize.setHeight(h);
|
||||
|
||||
@ -199,6 +200,32 @@ public class ChildComponentContainer extends Panel {
|
||||
|
||||
}
|
||||
|
||||
public static native int getRequiredWidth(
|
||||
com.google.gwt.dom.client.Element element)
|
||||
/*-{
|
||||
var width;
|
||||
if (element.getBoundingClientRect != null) {
|
||||
var rect = element.getBoundingClientRect();
|
||||
width = Math.ceil(rect.right - rect.left);
|
||||
} else {
|
||||
width = elem.offsetWidth;
|
||||
}
|
||||
return width;
|
||||
}-*/;
|
||||
|
||||
public static native int getRequiredHeight(
|
||||
com.google.gwt.dom.client.Element element)
|
||||
/*-{
|
||||
var height;
|
||||
if (element.getBoundingClientRect != null) {
|
||||
var rect = element.getBoundingClientRect();
|
||||
height = Math.ceil(rect.bottom - rect.top);
|
||||
} else {
|
||||
height = elem.offsetHeight;
|
||||
}
|
||||
return height;
|
||||
}-*/;
|
||||
|
||||
public void setMarginLeft(int marginLeft) {
|
||||
containerMarginLeft = marginLeft;
|
||||
getElement().getStyle().setPropertyPx("paddingLeft", marginLeft);
|
||||
|
Loading…
Reference in New Issue
Block a user