Created
January 29, 2018 10:53
-
-
Save DmitriyRF/9b6bee66577be9f825ae59fbb7ab4a00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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