anchorScroll not working in rc.1?


#1

I have a solution currently working in 1.0.0-beta.13 for an A-Z list of values, when you click on the relevant letter the page will scroll to the first entry starting with that letter (this entry has an id of ‘A’ or whatever the relevant letter is), the code below works perfectly in beta 13 but as soon as I upgrade to rc.1 the scroll only works correctly if you are lower in the page and it is scrolling up to the entry it doesn’t work scrolling down where it goes far beyond the correct letter.

The function I am using is:

$scope.inPageScrollTo = function(id) {
      $location.hash(id);
      $ionicScrollDelegate.anchorScroll([true]);
    }

I can’t see anything wrong with the above code. Has anyone else seen this issue or do you know a solution?


#2

I am also facing the same issue, what i found is if you remove the argument true (Animation ) than it will work fine without showing any animation while scroll to that element.

Don’t know if this is a bug.


#3

Thanks for the reply and apologies for my late reply, I had given up on it until the v1.0.0 release, unfortunately this still seems to be a problem, anchorScroll especially with animation is still not working for me. Are there any examples out there for working versions or did you have any luck with newer releases?

Most searches on the forums have come up with lots of problems but no reliable way to use this.


#4

What platform are you testing it on? I do know they changed some of the android stuff to Native Scrolling in 1.0 by default and that may be causing an issue. I would open an issue up on GitHub so they can fix it


#5

I was testing on iOS and Android, both were the same. I managed to get it working on both using a timeout as follows:

setTimeout(function () {
$location.hash(id);
$ionicScrollDelegate.$getByHandle(‘mainScroll’).anchorScroll([true]);
}, 200);

Not sure why this is but it works now!