How to show scroll distance

How to show scroll distance in readymag?

I have create the sample in jsfiddle and works well:

But, when i tried in readymag with the code widget, the text to show scroll distance just doesn’t update.

Steps to reproduce:

  1. Add code widget

  2. In Code widget, add below code to Widget Code tab
    <p class="text-console">Scrolled: 0px</p>

  3. In Code widget, add below code to Before </BODY> tab

<script>
  window.addEventListener("scroll", () => {
    document.querySelector(".text").textContent = 'Scrolled: '+window.scrollY + 'px';
  });
</script>
1 Like

Hi @ado code looks good, I wonder if it’s to do with the z-index or if you have inserted this into a code element. Would you mind sharing more information on where you have inserted this code, was it into the head of the project?