Skip to content
Advertisement

Anchor-like functionality in Vaadin to jump/scroll to a certain point

Is there a way in vaadin to scroll or jump to a certain point (e.g. a Label) inside a view (e.g. a Panel)when a button or link component is clicked? Similar to the anchors functionality on a website?

I’m using Vaadin 7.5.9

EDIT: I have a HorizontalSplitPanel. Its first component is a list of items where a user can make a selection. Is an item selected the second component of the HorizontalSplitPanel opens. The second component consists of a VerticalLayout containing a heading and a menu and a Panel. If there is a selection in the menu the Panel should be scrolled to the referred entry.

Advertisement

Answer

There’s an API on the UI class called scrollIntoView(Component). This is how one calls it

private Label result;

public void scrollToResult() {
  UI.getCurrent().scrollIntoView(result);
}
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement