Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Created July 30, 2018 23:39
Show Gist options
  • Select an option

  • Save gladchinda/103d00efb56b4304eff341e6810a51fd to your computer and use it in GitHub Desktop.

Select an option

Save gladchinda/103d00efb56b4304eff341e6810a51fd to your computer and use it in GitHub Desktop.
function ScrollController(offset) {
this.offsets = { offsetY: offset };
}
ScrollController.prototype.registerScrollHandler = function() {
window.addEventListener('scroll', function(event) {
if (window.scrollY === this.offsets.offsetY) {
console.log(`${this.offsets.offsetY}px`);
}
}, false);
}
var controller = new ScrollController(100);
controller.registerScrollHandler();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment