Search code examples
vaadinvaadin7

window. scrollBy value for Vaadin Application


Is it possible to set the 'scrollBy' value in a vaadin application? 'scrollBy' = amount of pixels by which the scroll occurs.

I tried UI.getCurrent().setScrollTop() but it didnt have any effect. My views are loaded inside a Panel. I tried setting scrollTop to that also but didn't work.


Solution

  • If all your Views are located inside a Panel, the Panel itself will have a scrollbar. Therefore you can call setScrollTop() on the panel.

    int offset = 30;
    Panel p = new Panel();
    p.setScrollTop(offset);