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

162
Visualizações
Horizontally scroll div with Angular4

I have the following HTML code:

<div class="card-deck" fxLayout.xs="row" style="overflow: scroll; height:100%">
    <md-card style="width:10rem" *ngFor="let make of filteredMakes" (click)="goToModels(make.niceName)"
             class="page-card mat-card">
      <img md-card-image=""  src="assets/img/gallery/brands/256/{{make.name}}.png" class="mat-card-image" />
      <md-card-subtitle  class="mat-card-title text-center">{{ make.name }}</md-card-subtitle>
    </md-card>
</div>

This is how it looks like on mobile:

Mobile First

I would like to create an animation that scrolls horizontally automatically to the last manufacturer, but stops when a user interacts with it.

In other words:

  1. User opens page, sees automatic scroll
  2. User understands that this is a scrolling div, begins to scroll with his finger.
  3. Auto-Scrolling is now disabled on the page (until the user resets the state of the page)

Where I am having trouble:

  1. How do I automatically scroll with javascript? (ideally I would like to control how much pixels to scroll in a time frame, 50px/sec for example)
  2. How do I detect when a user interacts with "card-deck" div (like gestures: touch, slide, etc.)
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

1) Auto Scroll: You can use the JS setInterval function to change every x mS the position of your div.

2) you can use @HostListener annotation ( see Angular doc ) to watch user interaction and cancel setInterval with clearInterval JS function when a click event is fired

over 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