-
26 Jul 2012 4:57 AM #1
Unanswered: VerticalLayoutContainer scroll to bottom
Unanswered: VerticalLayoutContainer scroll to bottom
Hello,
I'm trying to add a list of items to a VerticalLayoutContainer over some time and scroll the container to the bottom after each item, so that the last item is always visible.
However, the container always scrolls to the item before the last, i.e. after adding the 4th item, it scrolls to the 3rd.
I tried to call .scrollToBottom() immediately after adding the widget:
And placing the call into an AddHandler:Code:VerticalLayoutContainer conversationContainer; ... final ScrollSupport scrollSupport = conversationContainer.getScrollSupport(); ... conversationContainer.add(conversationWidget); scrollSupport.scrollToBottom();
What is the correct way to implement this behavior?Code:conversationContainer.addAddHandler(new AddEvent.AddHandler() { @Override public void onAdd(AddEvent event) { scrollSupport.scrollToBottom(); } });
-
27 Jul 2012 9:39 AM #2
What happens if you interact directly with the VLC's XElement? I.e., conversationContainer.getElement().
There are several .scrollXXX methods on the element as well as getScrollXXX() methods.
-
27 Jul 2012 10:57 AM #3
Hi,
I tried the following:
Code:ConversationWidget conversationWidget = new ConversationWidget(next); conversationContainer.add(conversationWidget);
Code:conversationWidget.getElement().scrollIntoView();
Code:conversationWidget.getElement().scrollIntoView(conversationContainer.getElement(), false);
These all scroll the previous widget into view, just like the code in my first post.Code:conversationContainer.getElement().scrollTo(ScrollDirection.TOP, conversationWidget.getElement().getTop());
This scrolls the container into view.Code:conversationContainer.getElement().scrollIntoView();
I was thinking that I'm referring to the wrong widget while scrolling, but I included some logging and it all seems OK.
-
27 Jul 2012 11:10 AM #4
Well, it certainly appears that ScrollSupport delegates to the underlying XElement.
What if you try a lighter weight layout container? Try a FlowLayoutContainer - if it looks funky, ensure that the children have a size.
-
29 Jul 2012 10:10 PM #5
Using FlowLayoutContainer results in the same behavior.
I eventually devised a workaround, by adding an additional iteration that scrolls the container to the bottom, after the last element has been added. It works almost as intended


Reply With Quote