diff options
| author | Vojta Jina | 2012-01-12 02:29:26 -0800 |
|---|---|---|
| committer | Vojta Jina | 2012-01-13 01:01:26 -0800 |
| commit | 249c89c0911254873c68cd753d903ea5606344ac (patch) | |
| tree | ee89b4d54ce20eabcaad625debbc0b282afdee74 /src | |
| parent | 5164ae545b10723b4e9ec454f436f6698dc93e24 (diff) | |
| download | angular.js-249c89c0911254873c68cd753d903ea5606344ac.tar.bz2 | |
fix($autoScroll): scroll even if $location is in html5 mode
+ use autoscroll in docs (ng:include)
Diffstat (limited to 'src')
| -rw-r--r-- | src/service/autoScroll.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/service/autoScroll.js b/src/service/autoScroll.js index 7b5b28e4..223400f4 100644 --- a/src/service/autoScroll.js +++ b/src/service/autoScroll.js @@ -10,9 +10,7 @@ * according to rules specified in * {@link http://dev.w3.org/html5/spec/Overview.html#the-indicated-part-of-the-document Html5 spec}. * - * If `$location` uses `hashbang` url (running in `hashbang` mode or `html5` mode on browser without - * history API support), `$autoScroll` watches the `$location.hash()` and scroll whenever it - * changes. + * 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 ! @@ -54,12 +52,11 @@ function $AutoScrollProvider() { else if (hash === 'top') $window.scrollTo(0, 0); } - // scroll whenever hash changes (with hashbang url, regular urls are handled by browser) - if ($location instanceof LocationHashbangUrl) { - $rootScope.$watch(function() {return $location.hash();}, function() { - $rootScope.$evalAsync(scroll); - }); - } + // 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); + }); return scroll; }]; |
