1
我在我的應用程序中有一些聊天功能,當輸入新消息時,它會自動滾動到<ion-content>
的底部,但是,像許多聊天應用程序一樣,如果您在聊天中滾動閱讀最新消息之前的內容,我不想滾動。只有當用戶位於屏幕的最底部時,我才喜歡滾動到底部,一旦新消息進入,我還沒有解決這個問題。離子 - 如何確定滾動是否在內容的底部
這裏是我當前的代碼:
scrollToBottom() {
// If the scrollTop is greater than the height, we are at the bottom,
// in which case, show scrolling animation
let dimensions = this.content.getContentDimensions();
let scrollHeight = dimensions.scrollHeight;
let scrollTop = dimensions.scrollTop;
let contentHeight = dimensions.contentHeight;
let heightAndScrollTop = contentHeight + scrollTop;
// This is the best I can get, assuming that the screen is in a consistent dimension, which we all know is basically non-existent due to all the different types of screens
if((scrollHeight - heightAndScrollTop) <= 39 && (scrollHeight - heightAndScrollTop) >= 0) {
this.content.scrollToBottom(300);
}
}
任何想法,我能做些什麼來解決這個問題?