diff --git a/README.md b/README.md new file mode 100644 index 0000000..599f839 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +Improvements on the original plugin (with last update at 2009). + + +Threshold +--------- + +Added threshold by @theluk from https://github.com/tuupola/jquery_viewport/pull/5. +You can now use: + + $("selector:in-viewport(300)"); diff --git a/jquery.viewport.js b/jquery.viewport.js index 7826000..79629f0 100644 --- a/jquery.viewport.js +++ b/jquery.viewport.js @@ -38,19 +38,19 @@ $.extend($.expr[':'], { "below-the-fold": function(a, i, m) { - return $.belowthefold(a, {threshold : 0}); + return $.belowthefold(a, {threshold : parseInt(m[3]) || 0}); }, "above-the-top": function(a, i, m) { - return $.abovethetop(a, {threshold : 0}); + return $.abovethetop(a, {threshold : parseInt(m[3]) || 0}); }, "left-of-screen": function(a, i, m) { - return $.leftofscreen(a, {threshold : 0}); + return $.leftofscreen(a, {threshold : parseInt(m[3]) || 0}); }, "right-of-screen": function(a, i, m) { - return $.rightofscreen(a, {threshold : 0}); + return $.rightofscreen(a, {threshold : parseInt(m[3]) || 0}); }, "in-viewport": function(a, i, m) { - return $.inviewport(a, {threshold : 0}); + return $.inviewport(a, {threshold : parseInt(m[3]) || 0}); } });