Results 1 to 5 of 5

Thread: VerticalLayoutContainer scroll to bottom

  1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    3
    Vote Rating
    0
      0  

    Default 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:

    Code:
    VerticalLayoutContainer conversationContainer;
    ...
    final ScrollSupport scrollSupport = conversationContainer.getScrollSupport();
    ...
    conversationContainer.add(conversationWidget); 
                    scrollSupport.scrollToBottom();
    And placing the call into an AddHandler:

    Code:
    conversationContainer.addAddHandler(new AddEvent.AddHandler() {
                
                @Override
                public void onAdd(AddEvent event) {
                    scrollSupport.scrollToBottom();
                }
            });
    What is the correct way to implement this behavior?

  2. #2
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    413
    Answers
    20
    Vote Rating
    21
      0  

    Default

    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.

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    3
    Vote Rating
    0
      0  

    Default

    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);
    Code:
    conversationContainer.getElement().scrollTo(ScrollDirection.TOP, conversationWidget.getElement().getTop());
    These all scroll the previous widget into view, just like the code in my first post.

    Code:
    conversationContainer.getElement().scrollIntoView();
    This scrolls the container into view.

    I was thinking that I'm referring to the wrong widget while scrolling, but I included some logging and it all seems OK.

  4. #4
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    413
    Answers
    20
    Vote Rating
    21
      0  

    Default

    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.

  5. #5
    Sencha User
    Join Date
    Jul 2012
    Posts
    3
    Vote Rating
    0
      0  

    Default

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •