Skip to content

Instantly share code, notes, and snippets.

@HelgaZhizhka
Forked from aschmelyun/DetectScroll.vue
Created November 5, 2020 12:55
Show Gist options
  • Save HelgaZhizhka/79be499749e536784f4c00113913dae6 to your computer and use it in GitHub Desktop.
Save HelgaZhizhka/79be499749e536784f4c00113913dae6 to your computer and use it in GitHub Desktop.
Detect scrolling to the bottom of a div in Vue.js
<template>
<div class="wrapper">
<div class="box" @scroll="handleScroll">
<p>Your content here...</p>
</div>
<a href="#" v-if="hasScrolledToBottom">Show After Scrolling</a>
</div>
</template>
<script>
export default {
data() {
return {
hasScrolledToBottom: false
}
},
methods: {
handleScroll: function(el) {
if((el.srcElement.offsetHeight + el.srcElement.scrollTop) >= el.srcElement.scrollHeight) {
this.hasScrolledToBottom = true;
}
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment