Scroll event @scroll="onScroll"
in div not working. I need to detect when scroll is on bottom of div.
<template>
<div>
<button @click="showCountries = !showCountries">Show countries</button>
<div
v-bind:class="countriesContainerClass"
v-if="showCountries"
@scroll="onScroll"
>
<ul>
<li
v-for="country in createChunk(countries, 20)"
v-bind:key="country.iso2"
v-bind:class="countryItemClass"
>
<div v-bind:class="countryFlagClass">
<img class="product_image" :src="country.flag" />
</div>
<div v-bind:class="countryNameClass">{{ country.name }}</div>
</li>
</ul>
</div>
</div>
</template>
This is my onScroll method.
onScroll({ target: { scrollTop, clientHeight, scrollHeight } }) {
console.log("scroll"); // I don't get "scroll" in console.
if (scrollTop + clientHeight >= scrollHeight) {
console.log("bottom");
}
},