我有一个html文档,我的聊天在其中运行。在收到一条新消息后,我用.append添加它。之后,我想向下滚动到聊天窗口的底部。但是由于某些原因,nicescroll不能完全向下滚动。
我的html元素:
<div class="chat"> // class chat is unique
<div id="chat_body">
<span id="new_messages">
//messages
</span>
</div>
</div>jquery脚本:
$('#new_messages').append(messagehtml);
$('.chat').getNiceScroll(1).resize();
$('.chat').getNiceScroll(1).doScrollTop($('#chat_body').height() - 1, 1);不错的滚动(1),因为网站上还有另一个nicescroll元素。
在chrome开发人员控制台中使用$('.chat').getNiceScroll(1).doScrollTop($('#chat_body').height() - 1, 1);可以很好地工作。
我想知道为什么。也许.append太慢了?
发布于 2018-10-29 15:42:27
我面临着同样的问题。我克服它的唯一方法是在内容的最后添加一个<br/>。
发布于 2019-12-07 21:17:56
对插件进行更改,替换以下内容
(q=!1,e.stopImmediatePropagation(),e.preventDefault())使用
(q=!1,e.stopImmediatePropagation())https://stackoverflow.com/questions/37037290
复制相似问题