Search in sources :

Example 6 with ClientRect

use of elemental.html.ClientRect in project che by eclipse.

the class PositionController method ensureVisibleAndGetRect.

/**
     * Ensures that an element is not display: none and is just visibility hidden so we can get an
     * accurate client rect.
     */
private static ClientRect ensureVisibleAndGetRect(Element element) {
    // Try to get rect and see if it isn't all 0's
    ClientRect rect = element.getBoundingClientRect();
    double rectSum = rect.getBottom() + rect.getTop() + rect.getLeft() + rect.getRight() + rect.getHeight() + rect.getWidth();
    if (rectSum != 0) {
        return rect;
    }
    // We make an attempt to get an accurate measurement of the element
    CSSStyleDeclaration style = element.getStyle();
    String visibility = CssUtils.setAndSaveProperty(element, "visibility", "hidden");
    String display = style.getDisplay();
    // if display set to none we remove it and let its normal style show through
    if (style.getDisplay().equals("none")) {
        style.removeProperty("display");
    } else {
        // it's likely display: none in a css class so we just have to guess.
        // We guess display:block since that's common on containers.
        style.setDisplay("block");
    }
    rect = element.getBoundingClientRect();
    style.setDisplay(display);
    style.setVisibility(visibility);
    return rect;
}
Also used : ClientRect(elemental.html.ClientRect) RelativeClientRect(org.eclipse.che.ide.util.RelativeClientRect) CSSStyleDeclaration(elemental.css.CSSStyleDeclaration)

Example 7 with ClientRect

use of elemental.html.ClientRect in project che by eclipse.

the class QuickAssistAssistantImpl method showPossibleQuickAssists.

@Override
public void showPossibleQuickAssists(final int line, final Element anchorElement) {
    final ClientRect anchorRect = anchorElement.getBoundingClientRect();
    showPossibleQuickAssists(line, anchorRect.getRight(), anchorRect.getBottom());
}
Also used : ClientRect(elemental.html.ClientRect)

Aggregations

ClientRect (elemental.html.ClientRect)7 RelativeClientRect (org.eclipse.che.ide.util.RelativeClientRect)3 Scheduler (com.google.gwt.core.client.Scheduler)1 CSSStyleDeclaration (elemental.css.CSSStyleDeclaration)1 Element (elemental.dom.Element)1 Window (elemental.html.Window)1