Skip to content

Instantly share code, notes, and snippets.

@DmitriyRF
Created January 29, 2018 10:53
Show Gist options
  • Select an option

  • Save DmitriyRF/9b6bee66577be9f825ae59fbb7ab4a00 to your computer and use it in GitHub Desktop.

Select an option

Save DmitriyRF/9b6bee66577be9f825ae59fbb7ab4a00 to your computer and use it in GitHub Desktop.
function onScroll (evt) { // Store the scroll value for laterz.
lastScrollY = window.scrollY; // Prevent multiple rAF callbacks.
if (scheduledAnimationFrame) return;
scheduledAnimationFrame = true;
requestAnimationFrame(updatePage);
}
window.addEventListener('scroll', onScroll, false);
var globalID;
function repeatOften() {
$("<div />").appendTo("body");
globalID = requestAnimationFrame(repeatOften);
}
$("#stop").on("click", function() {
cancelAnimationFrame(globalID);
});
$("#start").on("click", function() {
globalID = requestAnimationFrame(repeatOften);
});
// requestAnimationFrame(repeatOften);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment