Check out example codes for "mouse scroll event html". It will help you in understanding the concepts better.

Code Example 1

window.onscroll = function() {myFunction()};

function myFunction() {

    if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) {
    document.getElementById("myP").className = "test";
  } else {
    document.getElementById("myP").className = "";

    }
}

Code Example 2

element.onscroll = function() {
  // Code here
}

Learn ReactJs, React Native from akashmittal.com