How to scroll down using Bootstrap chat widget

I am using the default widget with class="panel-collapse collapse" . When there are several elements in the chat and it is open, scrolling starts at the top, not at the bottom (which works fine if it does not crash by default). For example, http://www.bestdealadvisors.com , add some elements, and then refresh the page. When the widget opens, it starts from the top. How can I make this scroll from the bottom when opened?

+6
source share
1 answer

You should listen to the Bootstrap event when something crashes. Here is some information here . Then scroll to the end of the chat window.

This script should be at the end of your page (after the bootstrap and jQuery script tags)

 <script> var panelBody = $("#chat-list") $('#collapseOne').on('shown.bs.collapse', function () { panelBody.stop().animate({scrollTop:panelBody.prop("scrollHeight")}, '100', 'swing') }) </script> 
+5
source

Source: https://habr.com/ru/post/1015071/


All Articles