File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ function addLinkItem(uid, file) {
222222 <div class="chat-item_content">${ contentHtml } </div>
223223 ` ;
224224
225- // 如果是图片,添加点击事件
225+ // 如果是图片,添加点击事件和加载完成后的滚动
226226 if ( isImage ) {
227227 const img = chatItem . querySelector ( 'img' ) ;
228228 img . onclick = function ( ) {
@@ -266,10 +266,19 @@ function addLinkItem(uid, file) {
266266 }
267267 } ;
268268 } ;
269+
270+ // 等待图片加载完成后再滚动
271+ img . onload = function ( ) {
272+ chatBox . scrollTop = chatBox . scrollHeight ;
273+ } ;
269274 }
270275
271276 chatBox . appendChild ( chatItem ) ;
272- chatBox . scrollTop = chatBox . scrollHeight ;
277+
278+ // 如果不是图片,立即滚动
279+ if ( ! isImage ) {
280+ chatBox . scrollTop = chatBox . scrollHeight ;
281+ }
273282}
274283
275284function addChatItem ( uid , message ) {
You can’t perform that action at this time.
0 commit comments