Ionic: Can't scroll up while using anchorScrol

2019-05-16 08:10发布

问题:

We are using scrollTo functionality in ionic application by setting the $location.hash(id) and $anchorScroll(). The scroll to bottom is working fine, but we can't scroll up the page once the page scrolled to some location using $anchorScroll and $location.hash().

See the issue clearly in codepen. Click on To Bottom button and try to scroll up back.

Please provide a solution to fix this scroll issue.

回答1:

On "ion-content" div add overflow-scroll="true"

<ion-content overflow-scroll="true">

then in your controller:

$scope.scrollTo = function(id) {
    $location.hash(id);
    $ionicScrollDelegate.anchorScroll();
};

Further information for this issue in Ionic Framework can be found here: http://forum.ionicframework.com/t/content-stuck-after-anchorscroll/776