Created
January 10, 2017 16:05
-
-
Save Shwartz/1e7cd58510cd7bf7e566132c38317b7f to your computer and use it in GitHub Desktop.
addEventListner with requestAnimationFrame
This file contains 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() { | |
"use strict"; | |
var ticking = false; | |
window.addEventListener('scroll', function () { | |
if (!ticking) { | |
window.requestAnimationFrame(function () { | |
runYourMethod(); | |
ticking = false; | |
}); | |
} | |
ticking = true; | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment