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:com.google.livingstories.client.ui.PartialDisclosurePanel.java

License:Apache License

public void scrollToContainedWidget(final Widget w) {
    Command doScroll = new Command() {
        @Override/*  w  w  w  .  ja  v  a  2s  .c om*/
        public void execute() {
            Window.scrollTo(0, w.getElement().getAbsoluteTop());
            LivingStoryControls.repositionAnchoredPanel();
        }
    };

    if (isOpen()) {
        doScroll.execute();
    } else {
        setOneTimeAnimationCompletionCommand(doScroll);
        setOpen(true);
    }
}

From source file:com.google.lotrepls.client.CommandPrompt.java

License:Apache License

private void resizeInputArea(boolean shrink) {
    final String s = inputArea.getText();
    int numNewlines = s.split("\\n").length;

    inputArea//  w w w.ja  v a 2 s.co m
            .setVisibleLines(shrink ? numNewlines + 1 : Math.max(inputArea.getVisibleLines(), numNewlines + 1));
    Window.scrollTo(0, 100000);
}

From source file:com.google.lotrepls.client.LotREPLs.java

License:Apache License

/**
 * This is the entry point method.//from   w  w w .j  a  v  a  2s  . c  om
 */
public void onModuleLoad() {
    showMotd();

    String language = Location.getParameter("language");

    commandPrompt = new CommandPrompt(language, new CommandEnteredCallback() {
        /**
         * The command entered handler does a little switch-a-roo. It removes the
         * input area and prompt, replacing them with immutable copies, and then
         * waits for the response. Once the script results (or error) are ready,
         * it inserts a result area and then re-adds the command prompt.
         */
        public void onCommandEntered(InterpreterType type, String script) {
            content.remove(commandPrompt.panel());

            Widget enteredScript = commandPrompt.createImmutablePanel();
            content.add(enteredScript);

            commandPrompt.clearInputArea();

            Window.scrollTo(0, 100000);

            try {
                api.eval(type, script, new ScriptCallback());
            } catch (InterpreterException e) {
                setResult(e.getMessage(), false);
            }
        }
    });

    String script = Location.getParameter("script");
    if (script != null && !script.equals("")) {
        commandPrompt.setScript(script);
    }

    content.add(commandPrompt.panel());

    content.setWidth("100%");
    RootPanel.get().add(content);
    commandPrompt.claimFocus();
}

From source file:com.google.lotrepls.client.LotREPLs.java

License:Apache License

private void setResult(String result, boolean succeeded) {
    Element e = Document.get().createPreElement();
    e.setInnerText(result);//www .jav  a2 s  .c om
    e.setClassName(succeeded ? "script" : "error");
    e.setAttribute("tabIndex", "-1");
    content.getElement().appendChild(e);
    content.add(commandPrompt.panel());
    commandPrompt.claimFocus();
    Window.scrollTo(0, 100000);
}

From source file:com.googlecode.mgwt.ui.client.MGWT.java

License:Apache License

/**
 *
 * Considered internal don`t call!//from w w  w.j a v a 2 s  .com
 * <p>
 * fixIOSScrollIssueBlur
 * </p>
 */
public static void fixIOSScrollIssueBlur() {
    if (!scrollingDisabled) {
        return;
    }
    if (timer != null) {
        timer.cancel();

    }

    timer = new Timer() {

        @Override
        public void run() {
            Window.scrollTo(0, 0);

        }

    };

    timer.schedule(100);
}

From source file:com.googlecode.mgwt.ui.client.util.impl.AddressBarUtilIphoneImpl.java

License:Apache License

@Override
public void showAddressBar() {
    Window.scrollTo(0, 0);

}

From source file:com.googlecode.mgwt.ui.client.util.impl.AddressBarUtilIphoneImpl.java

License:Apache License

private static void doScroll() {
    new Timer() {

        @Override//w ww .j a  va  2 s.c  om
        public void run() {
            Window.scrollTo(0, 1);

        }
    }.schedule(1);
}

From source file:com.gwtmobile.ui.client.page.Page.java

License:Apache License

private static void scrollToHideAddressBar() {
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override//from w  w w .  j a v  a  2  s  .  c o  m
        public void execute() {
            Window.scrollTo(0, 1);
        }
    });
}

From source file:com.murrayc.bigoquiz.client.application.quiz.BigOQuizPresenter.java

License:Open Source License

public BigOQuizPresenter(EventBus eventBus, V view, Proxy_ proxy, GwtEvent.Type<RevealContentHandler<?>> slot) {
    super(eventBus, view, proxy, slot);

    // Scroll to the top of the window whenever we reveal a new place.
    // TODO: Would it instead be enough to just call Window.scrollTo() after
    // Presenter.revealPlace()? Maybe not, because the GWTP documentation suggests that
    // revealPlace() is async (it fires an event).
    eventBus.addHandler(NavigationEvent.getType(),
            navigationEvent -> Scheduler.get().scheduleDeferred((Command) () -> {
                // Making the window scroll to top on every page change
                Window.scrollTo(0, 0);
            }));/*from   www.jav  a  2s  .c  o  m*/
}

From source file:com.smartgwt.mobile.client.widgets.Canvas.java

License:Open Source License

@SGWTInternal
protected static void _hideAddressBarNow() {
    // In iOS 7, the scrollTo() hack to hide the address bar does not work anymore.
    // http://www.mobilexweb.com/blog/safari-ios7-html5-problems-apis-review
    // We still run some code in _maybeHideAddressBar() on iPad, however, to work around
    // the issue that 20px is cut off from the top or bottom in landscape mode.
    // Also, on iPhone running in a UIWebView, we need to move up the RootLayoutPanel's
    // bottom coord.
    final Style rootLayoutPanelElementStyle = RootLayoutPanel.get().getElement().getStyle();
    if (IMPL.isIOSMin7_0()) {
        if (!Canvas.isUIWebView()) {
            // Work around an issue with iOS 7 Mobile Safari on an iPad in landscape mode.
            // http://stackoverflow.com/questions/19012135/ios-7-ipad-safari-landscape-innerheight-outerheight-layout-issue
            // http://stackoverflow.com/questions/18855642/ios-7-css-html-height-100-692px
            if (Canvas.isIPad()) {
                if (Page.getOrientation() == PageOrientation.LANDSCAPE) {
                    rootLayoutPanelElementStyle.setHeight(Window.getClientHeight() - 20, Style.Unit.PX);
                } else {
                    rootLayoutPanelElementStyle.setHeight(100, Style.Unit.PCT);
                }/*from  w ww.j a va 2 s  .c o  m*/

                // On iPhone running iOS 7.1 using the 'minimal-ui' viewport parameter, the top 20 CSS pixels
                // in landscape mode should not be used because tapping within this area causes the browser
                // chrome to be revealed: http://www.mobilexweb.com/blog/ios-7-1-safari-minimal-ui-bugs
            } else if (Canvas.isIPhone() && IMPL.isIOSMin7_1()) {
                if (Page.getOrientation() == PageOrientation.LANDSCAPE) {
                    rootLayoutPanelElementStyle.clearHeight();
                    rootLayoutPanelElementStyle.setTop(20, Style.Unit.PX);
                } else {
                    rootLayoutPanelElementStyle.setHeight(100, Style.Unit.PCT);
                    rootLayoutPanelElementStyle.setTop(0, Style.Unit.PX);
                }
            }

            // Since, when running in a UIWebView, the device-width/device-height
            // includes the height of the status bar, set the bottom of the RootLayoutPanel's
            // element to 20px (the standard height of the status bar).
        } else if (Canvas.isUIWebView()) {
            rootLayoutPanelElementStyle.clearHeight();
            rootLayoutPanelElementStyle.setBottom(20.0, Style.Unit.PX);
        }

        Window.scrollTo(0, 0);
    } else if (isIPhone() && !isStandAlone() && !isUIWebView()) {
        rootLayoutPanelElementStyle.setHeight(Window.getClientHeight() + 100 - 40, Style.Unit.PX);
        Window.scrollTo(0, 0);
    } else {
        rootLayoutPanelElementStyle.setHeight(Window.getClientHeight(), Style.Unit.PX);
    }
}