From 4275caf1311ef4e22346c683a54c1e9a27195f8c Mon Sep 17 00:00:00 2001 From: Martin Lopez Date: Fri, 13 Sep 2024 14:42:24 -0300 Subject: [PATCH] feat: add support for controlling scrolling of inner virtual list --- .../addons/chatassistant/ChatAssistant.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/com/flowingcode/vaadin/addons/chatassistant/ChatAssistant.java b/src/main/java/com/flowingcode/vaadin/addons/chatassistant/ChatAssistant.java index 9a38575..6387f9f 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/chatassistant/ChatAssistant.java +++ b/src/main/java/com/flowingcode/vaadin/addons/chatassistant/ChatAssistant.java @@ -272,5 +272,32 @@ public Component getFooterComponent() { return footerComponent; } + /** + * Scrolls to the given row index. Scrolls so that the element is shown at + * the start of the visible area whenever possible. + *

+ * If the index parameter exceeds current item set size the grid will scroll + * to the end. + * + * @param rowIndex + * zero based index of the item to scroll to in the current view. + */ + public void scrollToIndex(int position) { + this.content.scrollToIndex(position); + } + + /** + * Scrolls to the first element. + */ + public void scrollToStart() { + this.content.scrollToStart(); + } + + /** + * Scrolls to the last element of the list. + */ + public void scrollToEnd() { + this.content.scrollToEnd(); + } }