Created
January 16, 2015 16:30
-
-
Save rogeriolino/f291f4f1ba958393b336 to your computer and use it in GitHub Desktop.
jQuery window scroll helper
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($) { | |
$.winscroll = function(fn, restrictions) { | |
restrictions = $.extend({ minY: 0, minX: 0, maxY: Infinity, maxX: Infinity }, restrictions); | |
$(window).on('scroll', function() { | |
var y = $(document).scrollTop(), | |
x = $(document).scrollLeft(); | |
if (y >= restrictions.minY && y <= restrictions.maxY && x >= restrictions.minX && x <= restrictions.maxX) | |
{ | |
fn(x, y); | |
} | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using: