[solved] Problem detecting the scroll event (I want to do a Scroll Indicator)


Hi! I want to do a scroll indicator.
the simplest example is this:

this example use this function:

// When the user scrolls the page, execute myFunction 
window.onscroll = function() {myFunction()};

function myFunction() {
  var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
  var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
  var scrolled = (winScroll / height) * 100;
  document.getElementById("myBar").style.width = scrolled + "%";

but the event is not detected. I tried use jquery:


on a div, on the body and it does not work.

Is there something in Framework7 that “blocks” the event? What I can do?

Thank you! Framework7 is impressive every day I like it more!


You should attach scroll handler to current’s page `page-content’, e.g.:

$('.page-content').on('scroll', function () {
  var scrollTop = this.scrollTop;


YOU ARE THE BEST!! I should have tried that, my mistake.
nolimits4web is incredible what you are doing, I take this opportunity to thank you directly.
I’ve been learning your framework for a week and I have nothing but praise.
thank you! and I promise to help in some way this community soon.