とんたんの技術メモ

注)ただのメモです。

vue v-scroll スクロールイベントのメモ

最後尾でイベントを発火させる方法

<v-btn
  v-show="showBtn"
  v-scroll="onScroll"
  fab
  dark
  depressed
  @click="$vuetify.goTo(to)"
>{{ label }}</v-btn>

private onScroll(e: any) {
  if (typeof window === 'undefined') return

  const { scrollTop, clientHeight, scrollHeight } = e.target.scrollingElement
  if (scrollTop + clientHeight >= scrollHeight) {
    this.showBtn = false
    return
  }
  this.showBtn = true
}