Example usage for com.google.gwt.user.client Window scrollTo

List of usage examples for com.google.gwt.user.client Window scrollTo

Introduction

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

Prototype

public static void scrollTo(int left, int top) 

Source Link

Usage

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static void scrollTo(int x, int y) {
    debugScroll("" + x + ":" + y);
    Window.scrollTo(x, y);
    debugScroll("" + x + ":" + y);
}

From source file:ch.sebastienzurfluh.swissmuseum.core.client.view.animations.ScrollToTheTop.java

License:Open Source License

@Override
protected void onUpdate(double progress) {
    Window.scrollTo(0, (int) (origin + (destination - origin) * progress));
}

From source file:ch.unifr.pai.twice.layout.client.mobile.MobileUtils.java

License:Apache License

/**
 * Add necessary html tags to ensure unified initial zoom levels of the web page, fullscreen establishment and add proprietary tags (e.g.
 * "apple-mobile-web-app-capable" for extended functionalities).
 * //from w w  w . ja  v  a 2  s .  co  m
 * The main purpose is to establish a "native" look of the application even within the boundaries of the web browser.
 */
public static void preparePage() {
    RootPanel.getBodyElement().getStyle().setHeight(100, Unit.PCT);
    RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN);
    RootPanel.getBodyElement().getStyle().setMargin(0, Unit.PX);
    RootPanel.getBodyElement().getStyle().setPadding(0, Unit.PX);
    Document.get().getDocumentElement().getStyle().setProperty("minHeight", "300px");
    Document.get().getDocumentElement().getStyle().setHeight(100, Unit.PCT);
    NodeList<Element> tags = Document.get().getElementsByTagName("head");
    Element head;
    if (tags.getLength() > 0) {
        head = tags.getItem(0);
    } else {
        head = DOM.createElement("head");
        Document.get().insertFirst(head);
    }
    Element meta = DOM.createElement("meta");
    meta.setAttribute("name", "viewport");
    meta.setAttribute("content", "width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0");
    head.appendChild(meta);
    LinkElement e = Document.get().createLinkElement();
    e.setRel("stylesheet");
    e.setHref(GWT.getModuleBaseURL() + "master.css");
    head.appendChild(e);

    Element iphoneFullscreen = DOM.createElement("meta");
    iphoneFullscreen.setAttribute("name", "apple-touch-fullscreen");
    iphoneFullscreen.setAttribute("content", "yes");
    head.appendChild(iphoneFullscreen);

    Element iphoneWebAppCapable = DOM.createElement("meta");
    iphoneWebAppCapable.setAttribute("name", "apple-mobile-web-app-capable");
    iphoneWebAppCapable.setAttribute("content", "yes");
    head.appendChild(iphoneWebAppCapable);

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            Window.scrollTo(0, 1);
        }
    });
}

From source file:ch.unifr.pai.twice.mousecontrol.client.TouchPadNintendoDS.java

License:Apache License

@Override
public void start() {
    super.start();
    if (windowScrollHandler != null)
        windowScrollHandler.removeHandler();
    windowScrollHandler = Window.addWindowScrollHandler(new Window.ScrollHandler() {

        @Override/*from ww w.  j  a  v  a  2s  . c o  m*/
        public void onWindowScroll(ScrollEvent event) {
            if (skipEvents > 0)
                skipEvents--;
            l.getElement().getStyle().setLeft(RootPanel.getBodyElement().getScrollLeft(), Unit.PX);
            l.getElement().getStyle().setTop(RootPanel.getBodyElement().getScrollTop(), Unit.PX);
        }
    });
    Timer t2 = new Timer() {

        @Override
        public void run() {
            skipEvents = eventsAfterReset;
            Window.scrollTo(1000, 1000);
            updater.scheduleRepeating(50);
        }
    };
    t2.schedule(1000);
}

From source file:client.application.ApplicationPresenter.java

License:Apache License

@Override
public void onNavigation(NavigationEvent navigationEvent) {
    Window.scrollTo(0, 0);
}

From source file:co.fxl.gui.gwt.GWTDisplay.java

License:Open Source License

void resetScrollPanelTop() {
    if (isChrome && !scrolling && Window.getScrollTop() != 0) {
        Window.scrollTo(Window.getScrollLeft(), 0);
    }
}

From source file:com.alkacon.acacia.client.ui.InlineEntityWidget.java

License:Open Source License

/**
 * Positions the given pop-up relative to the reference element.<p>
 *//*w  w w.j  a  v a 2s .  c o m*/
void positionPopup() {

    if (m_referenceElement != null) {
        PositionBean referencePosition = PositionBean.getInnerDimensions(m_referenceElement);
        int currentTop = m_popup.getAbsoluteTop();
        int windowHeight = Window.getClientHeight();
        int scrollTop = Window.getScrollTop();
        int contentHeight = m_popup.getOffsetHeight();
        int top = referencePosition.getTop();
        if (((windowHeight + scrollTop) < (top + referencePosition.getHeight() + contentHeight + 20))
                && ((contentHeight + 40) < top)) {
            top = top - contentHeight - 5;
            if ((currentTop < top) && ((top - currentTop) < 200)) {
                // keep the current position
                top = currentTop;
            }
        } else {
            top = top + referencePosition.getHeight() + 5;
            if ((currentTop > top) && ((currentTop - top) < 200)) {
                // keep the current position
                top = currentTop;
            }
        }
        m_popup.center();
        m_popup.setPopupPosition(m_popup.getPopupLeft(), top);
        if (((contentHeight + top) - scrollTop) > windowHeight) {
            Window.scrollTo(Window.getScrollLeft(), ((contentHeight + top) - windowHeight) + 20);
        }
    } else {
        m_popup.center();
    }
}

From source file:com.alkacon.geranium.client.dnd.DNDHandler.java

License:Open Source License

/**
 * Execute on mouse wheel event.<p>
 * /* ww  w . ja  va  2 s.  c om*/
 * @param event the native event
 */
protected void onMouseWheelScroll(Event event) {

    int scrollStep = event.getMouseWheelVelocityY() * 5;
    Element scrollTarget;
    if (getCurrentTarget() != null) {
        scrollTarget = getCurrentTarget().getElement();
    } else {
        scrollTarget = RootPanel.getBodyElement();
    }
    while ((scrollTarget.getScrollHeight() == scrollTarget.getClientHeight())
            && (scrollTarget != RootPanel.getBodyElement())) {
        scrollTarget = scrollTarget.getParentElement();
    }
    if (scrollTarget == RootPanel.getBodyElement()) {
        int top = Window.getScrollTop() + scrollStep;
        int left = Window.getScrollLeft();
        if (top < 0) {
            top = 0;
        }
        Window.scrollTo(left, top);
    } else {
        int top = scrollTarget.getScrollTop() + scrollStep;
        if (top < 0) {
            top = 0;
        }
        scrollTarget.setScrollTop(top);
    }
    onMove(event);
}

From source file:com.arcbees.bourseje.client.application.ApplicationView.java

License:Apache License

private void show(final IsWidget content) {
    Window.scrollTo(0, 0);

    $(content).hide();/* w ww .  ja  v a 2 s . c o  m*/

    if (main.getWidget() == null) {
        setAndShow(content);
    } else {
        $(main.getWidget()).animate("opacity: 'hide'", 150, EasingCurve.easeInOut, new Function() {
            @Override
            public void f() {
                $(main).scrollTop(0);
                setAndShow(content);
            }
        });
    }
}

From source file:com.arcbees.website.client.application.ApplicationView.java

License:Apache License

@Override
public void setInSlot(Object slot, IsWidget content) {
    main.setWidget(content);
    Window.scrollTo(0, 0);
}