Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!