Content stuck after anchorscroll

I’m using anchorscroll to scroll to an element on the page.

View:

     <a ng-click="scrollTo('foo')">Click me!</a>
<SOME CONTENT>
<div id="foo">Here you are.</div>

Controller:

.controller('MyCtrl', function($scope, $location, $anchorScroll) {
  $scope.title = 'Ionic';

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

After clicking the link, the content view seems to get stuck. You can scroll down further than the element, but you can’t scroll up past the element.

I’ve tried reproducing this on vanilla Angular, and it doesn’t seem to occur there. Any way to ‘unstick’ the content after using anchorscroll?

Hey @coen_warmer, unfortunately anchorScroll won’t work with our scroll system, but we are working on a separate solution: https://github.com/driftyco/ionic/issues/508

Great. Following this with interest!

In the mean time, you can add ‘overflow-scroll=true’ to the <content> tag to make the scroll not stick after using anchorscroll.

1 Like