How to scroll a list to a specific item in ionic

In ionic 2 beta 6 I’m trying to scroll to a specific card in a list of cards:

<ion-card *ngFor="#item of items" [attr.id]="item.name" >

To do this i’m using the lifecycle hook onPageDidEnter, so that I will scrollTop when the page has fully entered ( as per the docs). My code looks like this:

onPageDidEnter() {

  var el = document.getElementById(this.currentItem);
  if (el !== null) {
    el.scrollTop=0;
  }
}

When I debug I can see how the view scrolls to the item right after el.scrollTop=0 but when I continue execution, somehow the view returns to the top and refuses to stay in the current item.

I have also tried several other angular 2 and ionic 2 hooks, but the behaviour remains the same; is there something I’m not seeing here?

3 Likes

I have the same problem, any help? How to scroll to the bottom of the list? :frowning:

has anyone come up with the solution yet? :slight_smile:

2 Likes

Some news about this? :smiley:

Try this: https://www.npmjs.com/package/ng2-page-scroll

How did you solve it?