Skip to content

Commit

Permalink
Merge pull request #15 from cchantep/cchantep-removed-elmt
Browse files Browse the repository at this point in the history
Workaround for removed elements
  • Loading branch information
biilmann committed Nov 15, 2013
2 parents b24657b + 0258ee0 commit 7eb3d74
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions jquery.pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,19 @@
if (disabled) { return; }

scrollY = $window.scrollTop();


var elmts = [];
for (var i=0, len=elements.length; i<len; i++) {
var $this = $(elements[i]),
data = $this.data("pin"),
from = data.from,
data = $this.data("pin");

if (!data) { // Removed element
continue;
}

elmts.push($this);

var from = data.from,
to = data.to;

if (from + $this.outerHeight() > data.end) {
Expand All @@ -73,6 +81,7 @@
if (options.activeClass) { $this.removeClass(options.activeClass); }
}
}
elements = elmts;
};

var update = function () { recalculateLimits(); onScroll(); };
Expand All @@ -96,4 +105,4 @@

return this;
};
})(jQuery);
})(jQuery);

0 comments on commit 7eb3d74

Please sign in to comment.