Static GitHub Issues

[2329] ScrollY is always equal to 0

prev: Setting new relic agent
next: Static generated site not running on my hosting (bluehost)

Hi all, I'm building a folio using Nuxt and Contentful, and I am encountering some issues on how to get the current vertical scroll position in my layout. The layout is located within the page folder like so:

/pages
|-clients/
|-works/
.       |-_slug.vue
.       |-index.vue
|- ...

and inside the layout _slug.vue

<template>
  <div class="project">
    <div class="project__content w-10 ctr">
      Stuff
    </div>
  </div>
</template>

<script>
export default {
  name: 'SingleProject',
  mounted () {
    if (process.browser) {
      this.eventInitialization()
    }
  },
  methods: {
    eventInitialization () {
      if (process.browser) {
        document.body.addEventListener('scroll', (e) => {
          this.scrollHandler(e)
        }, false)
      }
    },
    scrollHandler (e) {
      if (process.browser) {
        this._domPosPageScroll = document.body.getBoundingClientRect()

        console.log('window.scrollY', window.scrollY)
        console.log('this._domPosPageScroll', this._domPosPageScroll)
        console.log('JQUERY', $(document).scrollTop())
      }
    }
  },
  destroyed () {
    document.body.removeEventListener('scroll', this.scrollHandler)
  },
  validate ({ params }) {
    ...
  },
  asyncData ({ params, env, error }) {
   ...
  },
  head () {
    ...
  }
}
</script>

Jquery is defined as a global module so i can use it everywhere. I'm setting up the handlers in the mounted function and using the process.browser check to ensure that I'm not doing it server-side. When printing the logs in scrollHandler the output is always the same (even on different scroll levels):

window.scrollY = 0
this._domPosPageScroll = DOMRect { bottom: 800, height: 800, left: 0, right: 1280, top: 0, width: 1280, x: 0, y: 0, __proto__: DOMRect }
JQUERY = 0

Could anyone point me a mistake or misusage ? Could it be a bug ? Thanks in advance

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2033">#c2033</a>)</em></sub></div>