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:
-
Add code widget
-
In Code widget, add below code to
Widget Codetab
<p class="text-console">Scrolled: 0px</p> -
In Code widget, add below code to
Before </BODY>tab
<script>
window.addEventListener("scroll", () => {
document.querySelector(".text").textContent = 'Scrolled: '+window.scrollY + 'px';
});
</script>