List of usage examples for com.google.gwt.user.client Element getOffsetTop
@Override public int getOffsetTop()
From source file:com.zipsoft.widgets.client.lazylayout.VLazyLayout.java
License:Apache License
/** * Proveravam u DOM-u koji se widgeti trenutno vide * @param mainWidget To je u stvari ova komponenta * @param child/*from w ww .j a va 2 s .c o m*/ * @param proximity * @return */ private static boolean isBeingShown(final Widget mainWidget, final Widget child, final int proximity) { final Element element = child.getElement(); /* * track the original element's position as we iterate through the DOM * tree */ int originalTopAdjusted = 0; final int originalHeight = element.getOffsetHeight(); int originalLeftAdjusted = 0; final int originalWidth = element.getOffsetWidth(); com.google.gwt.dom.client.Element childElement = element; com.google.gwt.dom.client.Element parentElement = element.getParentElement(); // What part of its canvas the parent shows, relative to its own // coordinates (0,0 is the top left corner) // final int parentTop = parentElement.getScrollTop(); //VEROVATNO MORA DA SE UZME I SKROL POZICIJA ELEMENTA KOJI SKROLUJE final int parentTop = mainWidget.getElement().getScrollTop(); //OVO JE VISINA CELOG KONTEJNERA - ONE JE MAKSIMALNA - MOZDA TREBA MERITI SAMO VISINU KOJA SE VIDI // final int parentBottom = parentTop + parentElement.getClientHeight(); final int parentBottom = parentTop + mainWidget.getElement().getClientHeight(); // debug("Box: top: " + parentTop+ "px, btm: " + parentBottom + "px"); final int parentLeft = parentElement.getScrollLeft(); final int parentRight = parentLeft + parentElement.getClientWidth(); /* * renderbox is the target box that is checked for visibility. If * the renderbox and parent's viewport don't overlap, it should not * be rendered. The renderbox is the child's position with an * adjusted margin. */ final int renderBoxTop = childElement.getOffsetTop() - proximity; final int renderBoxBottom = childElement.getOffsetTop() + childElement.getOffsetHeight() + proximity; final int renderBoxLeft = childElement.getOffsetLeft() - proximity; final int renderBoxRight = childElement.getOffsetLeft() + childElement.getOffsetWidth() + proximity; if (!colliding2D(parentTop, parentRight, parentBottom, parentLeft, renderBoxTop, renderBoxRight, renderBoxBottom, renderBoxLeft)) { return false; } /* * see if the original component is visible from the parent. Move * the object around to correspond the relative changes in position. * The offset is always relative to the parent - not the canvas. */ originalTopAdjusted += childElement.getOffsetTop() - childElement.getScrollTop(); originalLeftAdjusted += childElement.getOffsetLeft() - childElement.getScrollLeft(); if (!colliding2D(parentTop, parentRight, parentBottom, parentLeft, originalTopAdjusted - proximity, originalLeftAdjusted + originalWidth + proximity, originalTopAdjusted + originalHeight + proximity, originalLeftAdjusted - proximity)) { return false; } return true; }
From source file:com.zipsoft.widgets.client.lazylayout.VLazyLayout.java
License:Apache License
@Deprecated private static boolean isBeingShown(final Widget child, final int proximity) { final Element element = child.getElement(); /*/*from w w w .ja va 2 s .c o m*/ * track the original element's position as we iterate through the DOM * tree */ int originalTopAdjusted = 0; final int originalHeight = element.getOffsetHeight(); int originalLeftAdjusted = 0; final int originalWidth = element.getOffsetWidth(); com.google.gwt.dom.client.Element childElement = element; com.google.gwt.dom.client.Element parentElement = element.getParentElement(); // while (parentElement != null) { // clientheight == the height as seen in browser // offsetheight == the DOM element's native height // What part of its canvas the parent shows, relative to its own // coordinates (0,0 is the top left corner) final int parentTop = parentElement.getScrollTop(); //OVO JE VISINA CELOG KONTEJNERA - ONE JE MAKSIMALNA - MOZDA TREBA MERITI SAMO VISINU KOJA SE VIDI // final int parentBottom = parentTop + parentElement.getClientHeight(); final int parentBottom = parentTop + parentElement.getClientHeight(); final int parentLeft = parentElement.getScrollLeft(); final int parentRight = parentLeft + parentElement.getClientWidth(); /* * renderbox is the target box that is checked for visibility. If * the renderbox and parent's viewport don't overlap, it should not * be rendered. The renderbox is the child's position with an * adjusted margin. */ final int renderBoxTop = childElement.getOffsetTop() - proximity; final int renderBoxBottom = childElement.getOffsetTop() + childElement.getOffsetHeight() + proximity; final int renderBoxLeft = childElement.getOffsetLeft() - proximity; final int renderBoxRight = childElement.getOffsetLeft() + childElement.getOffsetWidth() + proximity; if (!colliding2D(parentTop, parentRight, parentBottom, parentLeft, renderBoxTop, renderBoxRight, renderBoxBottom, renderBoxLeft)) { return false; } /* * see if the original component is visible from the parent. Move * the object around to correspond the relative changes in position. * The offset is always relative to the parent - not the canvas. */ originalTopAdjusted += childElement.getOffsetTop() - childElement.getScrollTop(); originalLeftAdjusted += childElement.getOffsetLeft() - childElement.getScrollLeft(); if (!colliding2D(parentTop, parentRight, parentBottom, parentLeft, originalTopAdjusted - proximity, originalLeftAdjusted + originalWidth + proximity, originalTopAdjusted + originalHeight + proximity, originalLeftAdjusted - proximity)) { return false; } // debug("Menjam Parent element - OVO NE BI TREBALO DA SE DOGODI!!!"); // childElement = parentElement; // parentElement = childElement.getOffsetParent(); // } //TODO MISLIM DA OVO NE TREBA VISE // lastly, check the browser itself. // final int parentTop = Window.getScrollTop(); // final int parentBottom = parentTop + Window.getClientHeight(); // final int parentLeft = Window.getScrollLeft(); // final int parentRight = parentLeft + Window.getClientWidth(); // // final int renderBoxTop = childElement.getOffsetTop() - proximity; // final int renderBoxBottom = childElement.getOffsetTop() + childElement.getClientHeight() + proximity; // // final int renderBoxLeft = childElement.getOffsetLeft() - proximity; // final int renderBoxRight = childElement.getOffsetLeft() + childElement.getClientWidth() + proximity; // // if (!colliding2D(parentTop, parentRight, parentBottom, parentLeft, // renderBoxTop, renderBoxRight, renderBoxBottom, renderBoxLeft)) { // return false; // } // // originalTopAdjusted += childElement.getOffsetTop(); // originalLeftAdjusted += childElement.getOffsetLeft(); // if (!colliding2D(parentTop, parentRight, parentBottom, parentLeft, // originalTopAdjusted - proximity, originalLeftAdjusted // + originalWidth + proximity, originalTopAdjusted // + originalHeight + proximity, originalLeftAdjusted // - proximity)) { // return false; // } return true; }
From source file:info.magnolia.ui.vaadin.gwt.client.dialog.connector.DialogContainingFormConnector.java
License:Open Source License
private void doResize() { Widget content = getContent().getWidget(); if (content instanceof FormViewImpl) { FormViewImpl formView = (FormViewImpl) content; Element element = view.asWidget().getElement(); NodeList<Node> childNodes = element.getChild(0).getChildNodes(); int footerHeight = 0, headerHeight = 0, marginHeight = 0; List<String> marginElements = Arrays.asList("dialog-description", "dialog-error", "dialog-content", "dialog-footer"); for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.getItem(i); if (item.getNodeType() == Node.ELEMENT_NODE) { Element child = (Element) item; if (child.getClassName().equalsIgnoreCase("dialog-footer")) { footerHeight = child.getOffsetHeight(); } else if (child.getClassName().isEmpty()) { headerHeight = child.getOffsetHeight(); }//from w w w . j a v a2 s . c o m if (marginElements.contains(child.getClassName())) { marginHeight += 2; } } } int topMargin = element.getOffsetTop(); int bottomMargin = 0; if ("light".equals(getState().modalityLevel)) { bottomMargin = LIGHT_DIALOG_BOTTOM_MARGIN; } formView.setMaxHeight(view.asWidget().getElement().getOffsetHeight() - footerHeight - headerHeight - marginHeight - topMargin - bottomMargin); } }
From source file:org.cruxframework.crux.widgets.client.grid.FrozenCellsScrollHandler.java
License:Apache License
/** * Freezes the header line if the grid is assigned with <code>freezeHeaders=true</code> */// w w w . j av a 2 s .co m private void maybeFreezeHeaders(int newVerticalScrollPosition) { boolean isVerticalScroll = newVerticalScrollPosition != lastVerticalScrollPosition; if (isVerticalScroll && tablelessStruct.getGrid().hasFrozenHeaders()) { Element headerLineElement = tablelessStruct.getLines().getLine(0).getElement(); Style style = headerLineElement.getStyle(); style.setZIndex(3); style.setOpacity(1); VerticalMotionAnimation headerAnimation = new VerticalMotionAnimation(headerLineElement); headerAnimation.move(headerLineElement.getOffsetTop(), newVerticalScrollPosition, -1); } }
From source file:ru.fly.client.ui.FElement.java
License:Apache License
public final int getRelativeTop(Element relative) { int top = getOffsetTop(); Element parent = getOffsetParent().cast(); while (parent != null && parent != relative) { top += parent.getOffsetTop(); parent = parent.getOffsetParent().cast(); }/*from ww w . j a v a 2s. c o m*/ return top; }