aboutsummaryrefslogtreecommitdiffstats
path: root/src/service
diff options
context:
space:
mode:
Diffstat (limited to 'src/service')
-rw-r--r--src/service/anchorScroll.js (renamed from src/service/autoScroll.js)22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/service/autoScroll.js b/src/service/anchorScroll.js
index 223400f4..19a09498 100644
--- a/src/service/autoScroll.js
+++ b/src/service/anchorScroll.js
@@ -1,6 +1,6 @@
/**
* @ngdoc function
- * @name angular.module.ng.$autoScroll
+ * @name angular.module.ng.$anchorScroll
* @requires $window
* @requires $location
* @requires $rootScope
@@ -11,14 +11,14 @@
* {@link http://dev.w3.org/html5/spec/Overview.html#the-indicated-part-of-the-document Html5 spec}.
*
* It also watches the `$location.hash()` and scroll whenever it changes to match any anchor.
- *
- * You can disable `$autoScroll` service by calling `disable()` on `$autoScrollProvider`.
- * Note: disabling is only possible before the service is instantiated !
+ * This can be disabled by calling `$anchorScrollProvider.disableAutoScrolling()`.
*/
-function $AutoScrollProvider() {
+function $AnchorScrollProvider() {
+
+ var autoScrollingEnabled = true;
- this.disable = function() {
- this.$get = function() {return noop;};
+ this.disableAutoScrolling = function() {
+ autoScrollingEnabled = false;
};
this.$get = ['$window', '$location', '$rootScope', function($window, $location, $rootScope) {
@@ -54,9 +54,11 @@ function $AutoScrollProvider() {
// does not scroll when user clicks on anchor link that is currently on
// (no url change, no $locaiton.hash() change), browser native does scroll
- $rootScope.$watch(function() {return $location.hash();}, function() {
- $rootScope.$evalAsync(scroll);
- });
+ if (autoScrollingEnabled) {
+ $rootScope.$watch(function() {return $location.hash();}, function() {
+ $rootScope.$evalAsync(scroll);
+ });
+ }
return scroll;
}];