mounted () {
window.addEventListener('scroll', this.checkScrollArea, {
capture: true
})
const scrollAreaElement = document.querySelector('.scroll_area')
const scrollAreaScrollHeight = scrollAreaElement.scrollHeight
const scrollAreaClientHeight = scrollAreaElement.clientHeight
// スクロールするテキストが少なくてスクロールできない場合に対応
if (scrollAreaScrollHeight === scrollAreaClientHeight) {
this.isDisabledButton = false
}
},
destroyed () {
window.removeEventListener('scroll', this.checkScrollArea, {
capture: true
})
},
methods: {
checkScrollArea () {
const scrollAreaElement = document.querySelector('.scroll_area')
const scrollAreaScrollTop = scrollAreaElement.scrollTop
const scrollAreaScrollHeight = scrollAreaElement.scrollHeight
const scrollAreaClientHeight = scrollAreaElement.clientHeight
if (scrollAreaScrollHeight - scrollAreaScrollTop <= scrollAreaClientHeight) {
// ここにボタンを有効にする変数などを変える処理をいれる。
this.isDisabledButton = false
}
},
}