File
Implements
Index
Properties
|
|
Methods
|
|
Inputs
|
|
autoSlide
|
Type : boolean
|
Default value : false
|
|
controls
|
Type : boolean
|
Default value : true
|
|
indicators
|
Type : boolean
|
Default value : true
|
|
slideInterval
|
Type : number
|
Default value : 70
|
|
Methods
autoSlideImages
|
autoSlideImages()
|
|
|
onNextClick
|
onNextClick()
|
|
|
onPrevClick
|
onPrevClick()
|
|
|
selectImage
|
selectImage(index: number)
|
|
Parameters :
Name |
Type |
Optional |
index |
number
|
No
|
|
selectedIndex
|
Type : number
|
Default value : 0
|
|
import { Component, Input, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
interface carouselImage {
imageSrc: string;
imageAlt: string;
}
@Component({
selector: 'bgui-carousel',
standalone: true,
imports: [CommonModule],
templateUrl: './carousel.component.html',
styleUrls: ['./carousel.component.scss'],
})
export class CarouselComponent implements OnInit {
@Input() images: carouselImage[] = [];
@Input() indicators = true;
@Input() controls = true;
@Input() autoSlide = false;
@Input() slideInterval = 70;
selectedIndex = 0;
constructor() {}
ngOnInit(): void {
if (this.autoSlide) {
this.autoSlideImages();
}
}
autoSlideImages(): void {
setInterval(() => {
this.onNextClick();
}, this.slideInterval);
}
selectImage(index: number): void {
this.selectedIndex = index;
}
onPrevClick(): void {
if (this.selectedIndex === 0) {
this.selectedIndex = this.images.length - 1;
} else {
this.selectedIndex--;
}
}
onNextClick(): void {
if (this.selectedIndex === this.images.length - 1) {
this.selectedIndex = 0;
} else {
this.selectedIndex++;
}
}
}
<div *ngIf="images && images.length > 0" class="carousel-container">
<img
*ngFor="let image of images; let i = index"
[src]="image.imageSrc"
[alt]="image.imageAlt"
[ngClass]="{ 'image-active': selectedIndex === i }"
class="" />
<div class="fxt-header">
<div class="fxt-top-content" style="margin-bottom: -35px">
<div class="fxt-transformY-50 fxt-transition-delay-1">
<a href="login-25.html" class="fxt-logo">
<img src="assets/images/logo/auth.png" alt="Logo"/></a>
</div>
<div class="fxt-transformY-50 fxt-transition-delay-2">
<h1>Beasy</h1>
</div>
<div class="fxt-transformY-50 fxt-transition-delay-3">
<p>
Fournit des solutions de bout en bout pour le secteur des paiements
aux institutions financières et aux commerçants.
</p>
</div>
</div>
</div>
<div *ngIf="indicators" class="carousel-dot-container">
<span
*ngFor="let dot of images; let i = index"
class="dot"
[ngClass]="{ active: selectedIndex === i }"
(click)="selectImage(i)">
</span>
</div>
<button *ngIf="controls" class="btn-carousel btn-prev">
<i
class="fas fa-arrow-circle-left icon-carousel icon-prev"
(click)="onPrevClick()"></i>
</button>
<button *ngIf="controls" class="btn-carousel btn-next">
<i
class="fas fa-arrow-circle-right icon-carousel icon-next"
(click)="onNextClick()"></i>
</button>
</div>
.carousel-container{
position: relative;
margin: auto;
text-align: center;
width: 100%;
height: 100%;
border-radius: 14px;
box-shadow: 0 4px 24px 0 rgb(34 41 47 / 10%);
}
.carousel-container img{
display: none;
border-radius: 14px;
}
.carousel-container Img.image-active {
display: block;
width: 100%;
height: 100%;
}
// dots/indicators
.carousel-dot-container {
position: absolute;
right: 0;
left: 0;
bottom: 0;
display: flex;
justify-content: center;
padding: 0;
margin-bottom: 1rem;
}
.dot {
cursor: pointer;
height: 10px;
width: 10px;
margin: 0 5px;
background-color: #fff;
border-radius: .65rem;
display: inline-block;
-webkit-transition: opacity 0.6s ease-in-out;
transition: opacity 0.6s ease-in-out;
opacity: 0.5;
outline: 0!important;
}
.active,
.dot:hover {
opacity: 1;
width: 26px;
transition: all 0.6s ease-in-out;
}
.fade {
animation-name: fade;
animation-duration: 1.5s;
}
@keyframes fade {
from {
opacity: 0.4;
}
to {
opacity: 1;
}
}
.btn-carousel {
position: absolute;
top: 0;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
width: 15%;
padding: 0;
color: #fff;
text-align: center;
background: 0 0;
border: 0;
cursor: pointer;
}
.btn-prev {
left: 0;
}
.icon-carousel {
color: #fff;
opacity: 0.5;
transition: all 0.15s ease;
}
.icon-carousel:hover {
opacity: 0.9;
}
.icon-carousel:active {
opacity: 0.5;
}
.icon-prev {
font-size: 13px;
}
.carousel-container {
.fxt-header {
right: 0;
left: 0;
bottom: 0;
margin-right: 40px;
margin-left: 10px;
position: absolute;
border-radius: 12px;
padding: 0px 40px 1px;
margin-bottom: 60px;
/*background-color: rgba(#000, 0.1);*/
/*-webkit-backdrop-filter: blur(5px);
backdrop-filter: blur(5px);*/
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: start;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
max-width: 660px;
width: 100%;
text-align: left;
@media only screen and (max-width: 575px) {
padding: 50px 15px 30px;
}
.fxt-top-content {
margin-bottom: 3px;
.fxt-logo {
display: block;
margin-bottom: 30px;
max-width: 40vw;
margin-left: auto;
margin-right: auto;
}
h1 {
color: #fff;
font-weight: 700;
}
p {
color: #fff;
}
}
.fxt-bottom-content {
h2 {
color: #fff;
font-size: 20px;
}
p {
color: #bbbbbb;
}
}
}
}
Legend
Html element with directive