Infinite scroll triggered relative to last element top rather than window bottom

closes #6451
This commit is contained in:
augier 2015-10-02 21:00:36 +02:00 committed by Steffen van Bergerem
parent baba71612d
commit 22882aa24d
2 changed files with 5 additions and 5 deletions

View file

@ -1,6 +1,7 @@
# 0.5.4.0
## Refactor
* Improve infinite scroll triggering [#6451](https://github.com/diaspora/diaspora/pull/6451)
## Bug fixes

View file

@ -98,12 +98,11 @@ app.views.InfScroll = app.views.Base.extend({
},
infScroll : function() {
var $window = $(window)
, distFromTop = $window.height() + $window.scrollTop()
, distFromBottom = $(document).height() - distFromTop
, bufferPx = 500;
var $window = $(window),
distFromBottom = $(document).height() - $window.height() - $window.scrollTop(),
elementDistance = this.$el.children().last().offset().top - $window.scrollTop() - 500;
if(distFromBottom < bufferPx) {
if(elementDistance <= 0 || distFromBottom < 500) {
this.trigger("loadMore");
}
}