From 46d6d99a8d0305fcbf7cd421a99e03ac8d87cd15 Mon Sep 17 00:00:00 2001 From: Marcell Spies Date: Thu, 23 Oct 2014 02:22:05 +0200 Subject: [PATCH] Enabled scroll-glue to work on the body element. --- src/scrollglue.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/scrollglue.js b/src/scrollglue.js index d336af2..b6e4cc9 100644 --- a/src/scrollglue.js +++ b/src/scrollglue.js @@ -78,9 +78,23 @@ activationState.setValue(shouldActivateAutoScroll()); } + function shouldActivateAutoScrollForWindow(){ + var scrollTop = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop; + return (scrollTop + window.innerHeight) >= document.body.scrollHeight; + } + + function onScrollWindow() { + activationState.setValue(shouldActivateAutoScrollForWindow()); + } + scope.$watch(onScopeChanges); - $el.bind('scroll', onScroll); + + if(el.constructor.name === HTMLBodyElement.name) { + window.onscroll = onScrollWindow; + } else { + el.bind('scroll', onScroll); + } } }; }]); -}(angular)); +}(angular)); \ No newline at end of file