Hashbang scroll - can't scroll up to top of content manually

I have a list. On each I put an ID (lets call them 1, 2, 3)

A <a id="1">
B <a id="2">
C <a id="3">

I can scroll the a specific item in the list using the following within a controller

$location.hash(“2”);
$anchorScroll();

However, say I with this code scroll to 2, Ionic now counts 2 as the top of the content, and I can’t MANUALLY scroll up to 1 (what I get is an Ionic bounce back down to 2 at the top again)

Is there any means to set a scroll position to 2, without locking the top of the content to 2

(Using this approach to see if I can come up with another way of solving the maintain back position problem that is being discussed in the forums - as I know the ID of the detail view that was just visited - so happy to scroll with that at the top, when they come back to the list)

Thanks!

I may be wrong but I’m not sure using this method would work if you have multiple pages. Scroll halfway down A, move to B scroll two-thirds down B and more to C. Press back to B and then to A. Would the scroll position be maintained per page?

Hey @alexb, anchor scrolling won’t work in Ionic as is since we are using a custom scrolling mechanism. I’m looking into exposing something to you through the $ionicScrollDelegate though, issue filed here: https://github.com/driftyco/ionic/issues/463

Hi @gregorypratt yeah I was going to do some custom business rules on top, I was just giving an explanation that made sense to describe the technical hurdle

1 Like

As mentioned on the github ticket, I’d love to see this too. I can jump to locations with the following gotoHash() but if I scroll the page at all the position is off and obviously gotoTop() doesn’t work.

$scope.gotoHash = function(thehash) {

var old = $location.hash();
$location.hash(thehash);
$anchorScroll();
$location.hash(old);


};

$scope.gotoTop = function() {

$location.hash('card-chapter-wrapper');
$anchorScroll();


};