Scroll to specific position in the page


#1

Hy guys, I have a little issue.

I want to scroll my page a certain point, for example 100px to top.

I have this template:

<ion-content class="ion_content" #container>
	<ion-refresher (ionRefresh)="forceRefreshAll($event)">
      <ion-refresher-content></ion-refresher-content>
    </ion-refresher> 


    <div class="image__grid" *ngIf="!isListView()">		
        <div class="image__square" *ngFor="let photo of photos">
         			
         <img [defaultImage]="defaultImage" [lazyLoad]="photo.thumbPath" [offset]="offset" [scrollTarget]="container._scroll._el"
             imageViewer="photo.thumbPath"
            (close)="callbackAfterImageViewerCloses()" 
            (click)="unlockScreenOrientation()" />
        </div>
	</div>		

    <div *ngIf="isListView()">
        <div class="container_card" *ngFor="let photo of photos;">
			<h2 padding>{{ photo.author }} - {{ photo.createdAt | date : 'medium'}}</h2>
			<div class="container_photo">
				<div class="image__card">

                  <div class="image__square">
                  
                    <img [defaultImage]="defaultImage" [lazyLoad]="photo.thumbPath" [offset]="offset" [scrollTarget]="container._scroll._el"
                    imageViewer="photo.thumbPath"
                      (close)="callbackAfterImageViewerCloses()" 
                      (click)="unlockScreenOrientation()" />
                  </div>	
                
                </div>
			</div>
        </div>
	</div>
       
	<ion-infinite-scroll (ionInfinite)="doInfinite($event)">
		<ion-infinite-scroll-content></ion-infinite-scroll-content>
	</ion-infinite-scroll>
 
</ion-content>

My typescript class is:

export class PhotosPage {

  @ViewChild(Content) content: Content;

  constructor( ... ) { }

  ionViewWillEnter() {

    this.scrollToTop();
  }


  scrollTo() {
    this.content.scrollTo(0, 100 , 0 );
  }  

}

Just I enter in the page I scroll the content of 0px to horizontally, 100px vertically, with a duration of 0 seconds.

But, unfortunatelly, it doesn’t work…

Help me please