Angular Circular Carousel
Create customizable Angular2+ Slideshow/ Carousel that can works as a circular slideshow with no constraints on styles.
Install
npm install ng2-slideshow
Usage
Import CarouselModule
into your module
your-module.module.ts
import { CarouselModule } from 'ng2-slideshow';
@NgModule({
imports: [
...
CarouselModule,
],
Import Settings
and Image
interface into your component class for providing settings configuration and list of Images for your carousel.
your-component.component.ts
import { Settings, Image } from 'ng2-slideshow';
...
export class YourComponent {
settings: Settings;
images: Image[];
}
Settings interface
interface Settings {
height: String;
width: String;
carouselDotClass?: String;
prevIconClass?: String;
nextIconClass?: String;
transitionDuration: Number;
transitionDelay: Number;
}
Image interface
interface Image {
caption: String;
media: String;
}
It takes two inputs and emits click event to parent component.
Inputs:
images: Image[];
settings: Settings;
Now you can use carousel selector in your component template as shown below
your-component.component.html
<ng2-slideshow [IMAGES]="images" [SETTINGS]="settings" (onclick)=handler($event)></ng2-slideshow>
It emits onclick event to the parent component, So there should be an event handler in parent component class. $event omits the 'index' of the image that user has clicked. From this handler, You can navigate user to corresponding page or show modal or something else.
Styling
For styling of carousel, SCSS or CSS can be written as global styles for uniform styling across the project, or you can write styles inside your parent component styles using /deep/
selector.
Note: Please maintain the hierarchy of classes while writing style and don't forget to add /deep/
before .carousel-wrapper
in case you are writing styles inside your parent component.
sample.style.scss
.carousel-wrapper {
...
.carousel {
....
}
}
License
MIT © Uttam Pratap Choudhary