I think it would be a good addition to this script, to be able to define which scrolling to listen to.
F.x. with jquery you could do this:
$('.scrolled-element').on('scroll',function(){});
But your script limits us to use the window scroll..
Demo case could be a modal window (the exact case I'm dealing with at the moment), that needs to be internally scrollable