$location.hash和$anchorScroll()的偏移量

offset for $location.hash and $anchorScroll()

本文关键字:偏移量 anchorScroll location hash      更新时间:2023-09-26

我有根据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();
      };

(摘自angularjs.org)

由于固定的标头,我必须为此$location.hash('bottom')设置偏移量(偏移html锚点以调整固定标头的常见问题)。

如何获得补偿?

试试这个

$anchorScroll.y偏移=20;