-1

How to implement ion scroll in such a way that when we click on right arrow button it should move to the next element in the div in ion content in ionic 3. I don't want any scollbar in th UI. It should be hidden.

I already referred this link. How can I use content.scrollTo() for ion-scroll in ionic2?

This is not helping me bcoz when I run scrollElement is not getting recognized in ionic3. It has been deprecated.

Please add a StackBlitz link for the answer.

My code structure looks like

<ion-content>
<ion-row>
<ion-col>
<button ion-button>Left</button>
</ion-col>
<ion-scroll scrollX="true">
<div ngFor="let item of itemlist>
<button>{{item}}</button>
<div>
</ion-scroll>
</ion-col>
<ion-col>
<button ion-button>Right</button>
</ion-col>
</ion-row>
</ion-content>
Suraj Rao
  • 28,186
  • 10
  • 88
  • 94
Chaitra R
  • 9
  • 7

2 Answers2

0

First your code is wrong, it should be like this;

    <ion-content>    
      <ion-row>
         <ion-col>
           <button ion-button>Left</button>
         </ion-col>
         <ion-scroll scrollX="true">
           <div ngFor="let item of itemlist">
             <button ion-button>{{item}}</button>
           </div>
         </ion-scroll>
         <ion-col>
           <button ion-button>Right</button>
         </ion-col>
     </ion-row>
   </ion-content>

You look this topic

Omsl
  • 170
  • 1
  • 12
0

First, plase examine this document.

For example:

in home.html

<ion-header>
  <ion-navbar>
    <ion-title>
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
  <div style="text-align: center;">
    <button ion-button (click)="scrollToBottom()">Scroll Bottom</button>

    <h1>Ionic 3 test</h1>
    <div *ngFor="let item of contentData">
      test content - {{item}}
    </div>
    <button ion-button (click)="scrollToTop()">Scroll Top</button>
  </div>
</ion-content>

in home.ts

import { Component, ViewChild } from '@angular/core';
import { NavController, Content } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  @ViewChild(Content) content: Content;

  public contentData = [];

  constructor(public navCtrl: NavController) {
    for(let i = 0; i < 301; i++) {
      this.contentData.push(i);
    }
  }

  scrollToTop() {
    this.content.scrollToTop();
  }
  scrollToBottom() {
    this.content.scrollToBottom();
  }


}

We created a example data with for loop. After we have 2 buttons. Plase check to my code a new ionic project. You can shape it the way you want after reading the source you share.

Omsl
  • 170
  • 1
  • 12