Angularjs $ anchorScroll滚动所有内容

时间:2015-07-01 14:00:34

标签: javascript jquery angularjs anchor-scroll

我在一个带滚动条的窗口中有一个带滚动条的列表。

当用户选择列表中的元素时,我使用$ anchorScroll将该项目滚动到列表顶部。

一个不幸的副作用是整个窗口也会滚动,直到该项目位于窗口的顶部。

如何获得滚动列表?

var newHash = 'cite' + dp.reference.id;
if ($location.hash() !== newHash) {
    // set the $location.hash to `newHash` and
    // $anchorScroll will automatically scroll to it
    $location.hash(newHash);
} else {
    // call $anchorScroll() explicitly,
    // since $location.hash hasn't changed
    $anchorScroll();
}

0 个答案:

没有答案