dev_cs_new
杨树明 6 years ago
parent c245781db7
commit 65dce68b92

@ -11,7 +11,7 @@ import Leftdialogue from './Leftdialogue'
class MessagChat extends Component{ class MessagChat extends Component{
constructor(props) { constructor(props) {
super(props); super(props);
this.messageRef = React.createRef();
this.state={ this.state={
isSpin:false, isSpin:false,
isSpins:false, isSpins:false,
@ -53,8 +53,12 @@ class MessagChat extends Component{
} }
scrollToBottom() { scrollToBottom() {
this.el.scrollIntoView({ behavior: 'smooth' }); const scrollHeight = this.messageList.scrollHeight;
const height = this.messageList.clientHeight;
const maxScrollTop = scrollHeight - height;
this.messageList.scrollTop = maxScrollTop > 0 ? maxScrollTop : 0;
} }
// 滑动刷新 // 滑动刷新
contentViewScrolledit=(e)=>{ contentViewScrolledit=(e)=>{
@ -351,6 +355,8 @@ class MessagChat extends Component{
messages:this.state.messages, messages:this.state.messages,
isSpin:false, isSpin:false,
}) })
this.scrollToBottom()
} }
} }
} }
@ -391,10 +397,13 @@ class MessagChat extends Component{
{myuserl!==undefined?myuserl.name:""}与你的私信 {myuserl!==undefined?myuserl.name:""}与你的私信
</p> </p>
{/*聊天页面*/} {/*聊天页面*/}
<div className="dialogPanel"> <div className="dialogPanel"
ref={(div) => {
this.messageList = div;
}}>
<div > <div >
<Spin size="large" className="myw100baifenbi" spinning={isSpin}> <Spin size="large" className="myw100baifenbi" spinning={isSpin}>
<div id="yslysl" ref={el => { this.el = el; }}> <div id="yslysl" >
{ {
messages===undefined? messages===undefined?
"" ""

Loading…
Cancel
Save