Horje
Scroll event throttling JS MDN Code Example
Scroll event throttling JS MDN
// Reference: http://www.html5rocks.com/en/tutorials/speed/animations/

let lastKnownScrollPosition = 0;
let ticking = false;

function doSomething(scrollPos) {
  // Do something with the scroll position
}

document.addEventListener('scroll', function(e) {
  lastKnownScrollPosition = window.scrollY;

  if (!ticking) {
    window.requestAnimationFrame(function() {
      doSomething(lastKnownScrollPosition);
      ticking = false;
    });

    ticking = true;
  }
});




Javascript

Related
Scotch.io - Create a CRUD App with Node and MongoDB 2 App Foundation Code Example Scotch.io - Create a CRUD App with Node and MongoDB 2 App Foundation Code Example
express plus Code Example express plus Code Example
javascript filtrar array string Code Example javascript filtrar array string Code Example
ripedme160 Code Example ripedme160 Code Example
js append html in div after Code Example js append html in div after Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7