Fix infinite scroll console error

closes #6478
This commit is contained in:
Steffen van Bergerem 2015-10-09 21:57:58 +02:00 committed by Jonne Haß
parent 4e5d09e6c5
commit 2fc7caf0bd

View file

@ -100,7 +100,8 @@ app.views.InfScroll = app.views.Base.extend({
infScroll : function() {
var $window = $(window),
distFromBottom = $(document).height() - $window.height() - $window.scrollTop(),
elementDistance = this.$el.children().last().offset().top - $window.scrollTop() - 500;
lastElOffset = this.$el.children().last().offset(),
elementDistance = lastElOffset ? lastElOffset.top - $window.scrollTop() - 500 : 1;
if(elementDistance <= 0 || distFromBottom < 500) {
this.trigger("loadMore");