From e3418b3eacfaa6978bb607c34be9ff2ab4f2e8a4 Mon Sep 17 00:00:00 2001 From: Jonathan Doig Date: Mon, 18 Apr 2016 22:28:16 +1000 Subject: [PATCH] Fix for scrolling body: bind to window scroll --- src/infinite-scroll.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/infinite-scroll.js b/src/infinite-scroll.js index aa1b82c..0f43d06 100644 --- a/src/infinite-scroll.js +++ b/src/infinite-scroll.js @@ -4,6 +4,10 @@ angular.module('infiniteScroll', []) link:function (scope, element, attrs) { var offset = parseInt(attrs.threshold) || 0; var e = element[0]; + + // If scrolling body, bind to window + element = (e.toString() === "[object HTMLBodyElement]") ? + angular.element($window) : element; element.bind('scroll', function () { if (scope.$eval(attrs.canLoad) && e.scrollTop + e.offsetHeight >= e.scrollHeight - offset) {