When using AngularJs for instant messaging, you need to fix the scroll bar of p to the bottom.
I tried the following method now, but no response.
//----p滚动条置底
$scope.scrollWindow=function(){
var _el = document.getElementById('chat_history');
_el.scrollTop = _el.scrollHeight;
};
//----使用方法
$timeout(function(){
$scope.scrollWindow();
},500);
给我你的怀抱2017-05-15 17:02:33
Answers that have been successfully implemented. HTML5
的API DOMNodeInserted
is used to detect changes in element content.
$scope.scroll_go=function(){
var _childEl=jQuery(".chat-history"),_el=jQuery("#chat_history");
if(_childEl.height()>(_documentSize.height - 50)){
_el.scrollTop(_childEl.height());
}
//----检测元素内容变动
_childEl.bind('DOMNodeInserted',function(){
_el.scrollTop(_childEl.height());
});
};
阿神2017-05-15 17:02:33
$scope.scrollWindow=function(){
var _el = document.getElementById('chat_history');
_el.scrollTop = _el.scrollHeight - _el.height;
};