2014-09-11 44 views
0

我有錨滾動根據id - 因爲這 -

function ($scope, $location, $anchorScroll) { 
     $scope.gotoBottom = function() { 
     // set the location.hash to the id of 
     // the element you wish to scroll to. 
     $location.hash('bottom'); 

     // call $anchorScroll() 
     $anchorScroll(); 
     }; 

(taken from angularjs.org)

我必須設置一個用於此$location.hash('bottom')偏移因固定標題(常見問題offsetting an html anchor to adjust for fixed header)。

如何獲得偏移量?

+0

或者,您可以使用'$ window.scrollTo(x-coord,y-coord)' – Satpal 2014-09-11 12:02:42

+0

我以前遇到過這個問題,所以我必須window.location.hash ='bottom',然後調用它兩次。 – 2014-09-11 12:06:26

回答

0

嘗試這一個

$ anchorScroll.yOffset = 20;