Quasar: QScrollArea, scroll to bottom

Created on 21 Jan 2020  ·  2Comments  ·  Source: quasarframework/quasar

Is your feature request related to a problem? Please describe.
In some applications, such as a messaging apps chat box, one would like to scroll to the bottom of a QScrollArea on a new message.

Describe the solution you'd like
An API method for QScrollArea to scroll to the bottom.

Describe alternatives you've considered

      this.$refs.chatScroll.setScrollPosition(this.$refs.chatScroll.$el.scrollHeight, 1)

setScrollPosition is such a method but the above doesn't seem to scroll to bottom correctly all the time.

feature request

Most helpful comment

const scrollArea = this.$refs.chatScroll;
const scrollTarget = scrollArea.getScrollTarget();
const duration = 300; // ms - use 0 to instant scroll
scrollArea.setScrollPosition(scrollTarget.scrollHeight, duration);

https://codepen.io/pdanpdan/pen/yLyQdOz?editors=1010

All 2 comments

const scrollArea = this.$refs.chatScroll;
const scrollTarget = scrollArea.getScrollTarget();
const duration = 300; // ms - use 0 to instant scroll
scrollArea.setScrollPosition(scrollTarget.scrollHeight, duration);

https://codepen.io/pdanpdan/pen/yLyQdOz?editors=1010

data(){
    return {
    scrollsize: 0;
    }
},
watch:{ // 监控滚动条的变化
    scrollsize: function(val){
        this.$refs.chatArea.setScrollPosition(val-500,100); //设置到底部,500是我自己设置的聊天区域高度
    }
},
scrollinfo(info){ 
  const size = info.verticalSize;
  this.scrollsize = size;
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

nueko picture nueko  ·  3Comments

slowaways picture slowaways  ·  3Comments

jippy89 picture jippy89  ·  3Comments

adwidianjaya picture adwidianjaya  ·  3Comments

fnicollier picture fnicollier  ·  3Comments