Skip to content

Commit 7eb3d74

Browse files
committed
Merge pull request webpop#15 from cchantep/cchantep-removed-elmt
Workaround for removed elements
2 parents b24657b + 0258ee0 commit 7eb3d74

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

jquery.pin.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,19 @@
4444
if (disabled) { return; }
4545

4646
scrollY = $window.scrollTop();
47-
47+
48+
var elmts = [];
4849
for (var i=0, len=elements.length; i<len; i++) {
4950
var $this = $(elements[i]),
50-
data = $this.data("pin"),
51-
from = data.from,
51+
data = $this.data("pin");
52+
53+
if (!data) { // Removed element
54+
continue;
55+
}
56+
57+
elmts.push($this);
58+
59+
var from = data.from,
5260
to = data.to;
5361

5462
if (from + $this.outerHeight() > data.end) {
@@ -73,6 +81,7 @@
7381
if (options.activeClass) { $this.removeClass(options.activeClass); }
7482
}
7583
}
84+
elements = elmts;
7685
};
7786

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

97106
return this;
98107
};
99-
})(jQuery);
108+
})(jQuery);

0 commit comments

Comments
 (0)