diff --git a/lib/angular-smooth-scroll.js b/lib/angular-smooth-scroll.js index df0c269..a2c628e 100644 --- a/lib/angular-smooth-scroll.js +++ b/lib/angular-smooth-scroll.js @@ -90,6 +90,11 @@ } while (element); } location = Math.max(location - offset, 0); + /* + * If element location is at the bottom and withing the last window height, then we have to set end location to the highest possible and valid scroll position. + * This fixes the problem that animated scrolls are abruptedly stopped because the location was higher than the latest possible scroll location. + */ + location = Math.min(location, document.body.scrollHeight - window.innerHeight); return location; };