J'utlise angular, je voudrais un carousel automatique sur 3s sur liste d'images, avec…
- User
J'utlise angular, je voudrais un carousel automatique sur 3s sur liste d'images, avec des flêches avance récule. Le carousel s'arrete lorsque la souris est dessus de l'image avec des boutons + et - qui apparaissent servant à faire du Zoom In et Zoom Out.
- Assistant
- User
continue
- Assistant
zoomButtonsVisible = false;
constructor() { }
ngOnInit(): void { this.startCarousel(); }
ngOnDestroy(): void { this.stopCarousel(); }
startCarousel(): void { this.carouselInterval = interval(3000).subscribe(() => { this.nextSlide(); }); }
stopCarousel(): void { if (this.carouselInterval) { this.carouselInterval.unsubscribe(); } }
nextSlide(): void { this.currentIndex = (this.currentIndex + 1) % this.images.length; }
prevSlide(): void { this.currentIndex = (this.currentIndex - 1 + this.images.length) % this.images.length; }
showZoomButtons(): void { this.zoomButtonsVisible = true; }
hideZoomButtons(): void { this.zoomButtonsVisible = false; }
zoomIn(): void { this.zoom = Math.min(this.zoom + 0.1, 2); }
zoomOut(): void { this.zoom = Math.max(this.zoom - 0.1, 1); }
}
vbnetNotez que ce code nécessite l'installation de la bibliothèque Font Awesome pour utiliser les icônes de flèche. Pour l'installer, ajoutez la ligne suivante dans le fichier `index.html` de votre application : ```html <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css" />