Answers for "vue on scroll end prevent parent scroll"

1

vue on scroll end prevent parent scroll

<template>
  <div ref="target" @mousewheel="onScroll">
      <!-- HTML Content -->
  </div>
</template>
 
<script>
...
onScroll(e) {
	const target = this.$refs.scroll

    const scrollHeight = target.scrollHeight
    const scrollBottomPoint = target.scrollTop + target.offsetHeight

    if (e.deltaY < 0 && target.scrollTop === 0) {
      e.preventDefault()
      return
    }

    if (e.deltaY > 0 && scrollHeight === scrollBottomPoint) {
      e.preventDefault()
    }
  }
}
</script>
Posted by: Guest on April-03-2022

Browse Popular Code Answers by Language