Skip to content

Commit

Permalink
Checking if the image is hidden before doing anything else
Browse files Browse the repository at this point in the history
This way we avoid doing unnecessary work in case the image is actually
hidden
  • Loading branch information
luis-almeida committed Sep 21, 2013
1 parent f8dda0a commit ebd5ed9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "jquery-unveil",
"version": "1.2.0",
"version": "1.3.0",
"main": ["jquery.unveil.js"]
}
7 changes: 4 additions & 3 deletions jquery.unveil.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@

function unveil() {
var inview = images.filter(function() {
var $e = $(this),
wt = $w.scrollTop(),
var $e = $(this);
if ($e.is(":hidden")) return;

var wt = $w.scrollTop(),
wb = wt + $w.height(),
et = $e.offset().top,
eb = et + $e.height();

if ($e.is(':hidden')) return;
return eb >= wt - th && et <= wb + th;
});

Expand Down

0 comments on commit ebd5ed9

Please sign in to comment.