diff --git a/lib/angular-smooth-scroll.js b/lib/angular-smooth-scroll.js index df0c269..177b2af 100644 --- a/lib/angular-smooth-scroll.js +++ b/lib/angular-smooth-scroll.js @@ -87,7 +87,7 @@ do { location += element.offsetTop; element = element.offsetParent; - } while (element); + } while (element && element !== container); } location = Math.max(location - offset, 0); return location; @@ -120,14 +120,15 @@ if ( ( // condition 1 - position == endLocation - ) || + Math.abs(position - endLocation) < 0.001 + ) || ( // condition 2 - currentLocation == endLocation + Math.abs(currentLocation - endLocation) < 0.001 ) || ( // condition 3 - internalHeight >= scrollHeight - ) + !containerPresent && + internalHeight >= scrollHeight + ) ) { // stop clearInterval(runAnimation); callbackAfter(element); diff --git a/package.json b/package.json new file mode 100644 index 0000000..d913647 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "ng-smooth-scroll", + "version": "2.0.0", + "description": "A pure-javascript library and set of directives to scroll smoothly to an element with easing.", + "main": "lib/angular-smooth-scroll.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/d-oliveros/ngSmoothScroll.git" + }, + "keywords": [ + "angularjs", + "smooth scroll", + "scrolling", + "scroll effects", + "scroll animations", + "smooth", + "scroll" + ], + "author": "David Oliveros ", + "license": "MIT", + "bugs": { + "url": "https://github.com/d-oliveros/ngSmoothScroll/issues" + }, + "homepage": "https://github.com/d-oliveros/ngSmoothScroll#readme" +}