How to Do Automatic Scrolling

Asked

Viewed 185 times

0

I’m developing an application where the user asks a question and the server delivers an answer, I’m having trouble getting the scrollbar to keep up with the conversation, So far I’m having the conversation history on the screen but I have to drag with the mouse to see the new messages. I am using JSF with AJAX .

<div id="perguntaResposta">
                <ul class="messages">
                    <h:panelGroup id="dialogo">
                        <ui:repeat var="conversa" value="#{chat.conversas}">
                            <h:panelGroup rendered="#{conversa.usuario == 1}">
                                <li class="message right appeared">
                                    <div class="avatar"></div>
                                    <div class="text_wrapper">
                                        <h:outputText value="#{conversa.intereacaoFala}" />
                                    </div>
                                </li>
                            </h:panelGroup>
                            <h:panelGroup rendered="#{conversa.usuario == 2}">
                                <li class="message left appeared">
                                    <div class="avatar"></div>
                                    <div class="text_wrapper">
                                        <h:outputText value="#{conversa.intereacaoFala}"/>
                                    </div>
                                </li>
                            </h:panelGroup>
                        </ui:repeat>
                    </h:panelGroup>
                </ul>
            </div> 

1 answer

0

I tested this way here and it worked, try to see.

<div id="peguntaResposta" style="height:100px;overflow-y:scroll" id="test"></div>

It’s important to remember that you have to have one height initial, the overflow-y, is to display vertical bar only, auto would not appear if not needed, in case it doesn’t work out try too overflow:scroll

  • Thanks for the help Marcos, but it didn’t work :/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.