Reputation: 2674
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:
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:
Where I am having trouble:
Upvotes: 0
Views: 1604
Reputation: 156
1) Auto-scroll : you can use JS function setInterval to change every x mS the position of your div.
2) you can use the @HostListener annotation (See Angular doc) to watch user interaction and cancel the setInterval with the JS function clearInterval when a click event is triggered
Upvotes: 1