javascript 自动向下滚动 angularjs
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19871470/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Autoscroll down angularjs
提问by user1424508
Hi I'm creating a chat app with angularjs that autoscrolls down when a user messages another user. I'm not sure how to implement this as my chat window is a fixed ul element. I'm thinking I will need to implement a directive to do this (inboxmsg-scroll on the ul element)
嗨,我正在创建一个带有 angularjs 的聊天应用程序,当用户向另一个用户发送消息时,它会自动向下滚动。我不确定如何实现这一点,因为我的聊天窗口是一个固定的 ul 元素。我想我需要实现一个指令来做到这一点(在 ul 元素上的 inboxmsg-scroll)
Any help? thanks.
有什么帮助吗?谢谢。
HTML
HTML
<ul class="chatting-window" inboxmsg-scroll>
<li data-ng-repeat="messageinfo in messages">
<div class="message-date">
{{messageinfo[0]}}
</div>
</li>
</ul>
回答by R?zvan Flavius Panda
angularjs-scroll-glue
angularjs-scroll-glue
An AngularJs directive that automatically scrolls to the bottom of an element on changes in it's scope.
一个 AngularJs 指令,它会在元素范围发生变化时自动滚动到元素的底部。