Skip to content

Instantly share code, notes, and snippets.

@luismartinezs
Created June 18, 2021 07:47
Show Gist options
  • Save luismartinezs/82203d3713f665415c06ffe8fc1a9d4c to your computer and use it in GitHub Desktop.
Save luismartinezs/82203d3713f665415c06ffe8fc1a9d4c to your computer and use it in GitHub Desktop.
Vue scroll event #vue
<script>
export default {
...
methods: {
handleScroll: throttle(() => {
console.log('I get fired every two seconds!')
}, 2000)
},
created () {
window.addEventListener('scroll', this.handleScroll)
},
beforeDestroy () {
window.removeEventListener('scroll', this.handleScroll)
}
...
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment