Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

224
Visualizações
Ionic2 - programmatically scroll an ion-scroll

I'm having a page with 2 scrollable views next to each other:

<ion-content>
   <ion-scroll></ion-scroll>
   <ion-scroll></ion-scroll>
</ion-content>

I want to programmatically scroll the first one, but it seems the scrollTo is only a method on ion-content (which I ofcourse can not scroll, I need to have the second one independant)

Is there any way to solve this?

update: added a plnkr to show what I need

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

If I am not mistaken you are trying to Scroll the Left Scroller and I see you have a view selector called leftCats.

So if you just change one line you will be able to scroll. Here is my code below:

NOTE: This is just plain javascript. It jumps to the scroll position. You can apply animation if you like later.

import {Component, ViewChild} from '@angular/core';

@Component({
  templateUrl:"home.html"
})
export class HomePage implements AfterViewChecked {

  @ViewChild('content') content;
  @ViewChild('leftCats') leftItems;

  constructor() {

    }

    scroll() {
      //I want to scroll the left pane here
      console.log('scroll');

      this.leftItems.scrollElement.scrollTop += 50; // Change This Line
    }

}

I have also forked it here: DEMO

Hope it helps.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda