I need the scroll position for a Vaadin 24 grid. Is there a V24 version

I need the scroll position for a Vaadin 24 grid. Is there a V24 version for this add-on?


No, there is not. The Vaadin 24 Grid is very different. But you can get the scroll position by row index with it by using JavaScript.


private int index;
...
        // JavaScript that listens scrolling and calls server with the index and debounce
        grid.getElement().executeJs(
                "function debounce(func, wait) {let timeout; return () => {if (timeout) {clearTimeout(timeout);} timeout = setTimeout(func, wait);}} const onScroll = debounce(() => $0.$server.firstIndex($1._firstVisibleIndex), 100); $1.$.table.addEventListener('scroll', onScroll);",
                getElement(), grid.getElement());


// Add this in the same class to to update the current index
@ClientCallable
private void firstIndex(JsonValue index) {
this.index = Integer.valueOf(index.toJson());
}