Example usage for com.google.gwt.user.client Element setScrollTop

List of usage examples for com.google.gwt.user.client Element setScrollTop

Introduction

In this page you can find the example usage for com.google.gwt.user.client Element setScrollTop.

Prototype

@Override
    public void setScrollTop(int scrollTop) 

Source Link

Usage

From source file:com.haulmont.cuba.web.toolkit.ui.client.scrollboxlayout.CubaScrollBoxLayoutConnector.java

License:Apache License

@Override
public void layout() {
    CubaScrollBoxLayoutWidget widget = getWidget();
    Element element = widget.getElement();

    element.setScrollTop(getState().scrollTop);
    element.setScrollLeft(getState().scrollLeft);

    widget.onScrollHandler = (scrollTop, scrollLeft) -> getRpcProxy(CubaScrollBoxLayoutServerRpc.class)
            .setScroll(scrollTop, scrollLeft);
}

From source file:com.vaadin.terminal.gwt.client.Util.java

License:Open Source License

/**
 * Run workaround for webkits overflow auto issue.
 * //from  w  w w . j av a 2 s .  co  m
 * See: our bug #2138 and https://bugs.webkit.org/show_bug.cgi?id=21462
 * 
 * @param elem
 *            with overflow auto
 */
public static void runWebkitOverflowAutoFix(final Element elem) {
    // Add max version if fix lands sometime to Webkit
    // Starting from Opera 11.00, also a problem in Opera
    if ((BrowserInfo.get().getWebkitVersion() > 0 || BrowserInfo.get().getOperaVersion() >= 11)
            && getNativeScrollbarSize() > 0) {
        final String originalOverflow = elem.getStyle().getProperty("overflow");
        if ("hidden".equals(originalOverflow)) {
            return;
        }

        // check the scrolltop value before hiding the element
        final int scrolltop = elem.getScrollTop();
        final int scrollleft = elem.getScrollLeft();
        elem.getStyle().setProperty("overflow", "hidden");

        Scheduler.get().scheduleDeferred(new Command() {
            public void execute() {
                // Dough, Safari scroll auto means actually just a moped
                elem.getStyle().setProperty("overflow", originalOverflow);

                if (scrolltop > 0 || elem.getScrollTop() > 0) {
                    int scrollvalue = scrolltop;
                    if (scrollvalue == 0) {
                        // mysterious are the ways of webkits scrollbar
                        // handling. In some cases webkit reports bad (0)
                        // scrolltop before hiding the element temporary,
                        // sometimes after.
                        scrollvalue = elem.getScrollTop();
                    }
                    // fix another bug where scrollbar remains in wrong
                    // position
                    elem.setScrollTop(scrollvalue - 1);
                    elem.setScrollTop(scrollvalue);
                }

                // fix for #6940 : Table horizontal scroll sometimes not
                // updated when collapsing/expanding columns
                // Also appeared in Safari 5.1 with webkit 534 (#7667)
                if ((BrowserInfo.get().isChrome()
                        || (BrowserInfo.get().isSafari() && BrowserInfo.get().getWebkitVersion() >= 534))
                        && (scrollleft > 0 || elem.getScrollLeft() > 0)) {
                    int scrollvalue = scrollleft;

                    if (scrollvalue == 0) {
                        // mysterious are the ways of webkits scrollbar
                        // handling. In some cases webkit may report a bad
                        // (0) scrollleft before hiding the element
                        // temporary, sometimes after.
                        scrollvalue = elem.getScrollLeft();
                    }
                    // fix another bug where scrollbar remains in wrong
                    // position
                    elem.setScrollLeft(scrollvalue - 1);
                    elem.setScrollLeft(scrollvalue);
                }
            }
        });
    }

}

From source file:com.zipsoft.widgets.client.lazylayout.VLazyLayout.java

License:Apache License

private void setScrollTop(final int topPx) {
    com.google.gwt.dom.client.Element parent = getElement();
    while (parent != null && parent.getScrollTop() <= 0) {
        parent = parent.getOffsetParent();
    }/*from w  w  w  . jav  a  2 s.  co m*/
    if (parent != null) {
        parent.setScrollTop(topPx);
        debug("setting scrolltop to " + topPx);
    } else {
        final int currentScrollLeft = Window.getScrollLeft();
        Window.scrollTo(currentScrollLeft, topPx);
        debug("setting scrolltop for window to " + topPx);
    }
    scrollingWasProgrammaticallyAdjusted = true;
}