mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-14 12:08:27 +08:00
fix($anchorScroll): don't scroll to top when initializing and location hash is empty
Closes #8848 Closes #9393
This commit is contained in:
@@ -94,7 +94,10 @@ function $AnchorScrollProvider() {
|
||||
// (no url change, no $location.hash() change), browser native does scroll
|
||||
if (autoScrollingEnabled) {
|
||||
$rootScope.$watch(function autoScrollWatch() {return $location.hash();},
|
||||
function autoScrollWatchAction() {
|
||||
function autoScrollWatchAction(newVal, oldVal) {
|
||||
// skip the initial scroll if $location.hash is empty
|
||||
if (newVal === oldVal && newVal === '') return;
|
||||
|
||||
$rootScope.$evalAsync(scroll);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user