Gathering detailed insights and metrics for ngx-image-gallery
Gathering detailed insights and metrics for ngx-image-gallery
Gathering detailed insights and metrics for ngx-image-gallery
Gathering detailed insights and metrics for ngx-image-gallery
ngx-gallery
Responsive Angular 2 / 4 image gallery plugin
ngx-gallery-9
Angular image gallery plugin Based on [NgxGallery](https://github.com/lukasz-galka/ngx-gallery), Compatible with Angular 9+
ngx-gallery-gocodee
Responsive Angular 2 / 4 image gallery plugin
@ks89/angular-modal-gallery
Image gallery for Angular
npm install ngx-image-gallery
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
5
Due to my hectic schedule, it is getting hard to maintain this repository. If anybody is interested to work on this project, please give a pull request to fix some critical issues and enhancements.
Probably the best Angular 4+ modal and inline image gallery. Angular upgrade for ng-image-gallery.
npm i -S hammerjs lodash
Then import hammerjs into your project (tip: in you main.ts file), e.g:
import 'hammerjs';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
document.addEventListener('DOMContentLoaded', () => {
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.log(err));
});
1npm install --save ngx-image-gallery
1import { NgxImageGalleryModule } from 'ngx-image-gallery'; 2 3@NgModule({ 4 ..., 5 imports: [ 6 NgxImageGalleryModule, 7 ... 8 ] 9}) 10export class AppModule { }
1// app.component.html 2 3<ngx-image-gallery 4[images]="images" 5[conf]="conf" 6(onOpen)="galleryOpened($event)" 7(onClose)="galleryClosed()" 8(onImageClicked)="galleryImageClicked($event)" 9(onImageChange)="galleryImageChanged($event)" 10(onDelete)="deleteImage($event)" 11></ngx-image-gallery>
1import { Component, OnInit, ViewChild } from '@angular/core'; 2import { NgxImageGalleryComponent, GALLERY_IMAGE, GALLERY_CONF } from "ngx-image-gallery"; 3 4@Component({ 5 selector: 'app-root', 6 templateUrl: './app.component.html', 7 styleUrls: ['./app.component.scss'] 8}) 9export class AppComponent implements OnInit { 10 // get reference to gallery component 11 @ViewChild(NgxImageGalleryComponent) ngxImageGallery: NgxImageGalleryComponent; 12 13 // gallery configuration 14 conf: GALLERY_CONF = { 15 imageOffset: '0px', 16 showDeleteControl: false, 17 showImageTitle: false, 18 }; 19 20 // gallery images 21 images: GALLERY_IMAGE[] = [ 22 { 23 url: "https://images.pexels.com/photos/669013/pexels-photo-669013.jpeg?w=1260", 24 altText: 'woman-in-black-blazer-holding-blue-cup', 25 title: 'woman-in-black-blazer-holding-blue-cup', 26 thumbnailUrl: "https://images.pexels.com/photos/669013/pexels-photo-669013.jpeg?w=60" 27 }, 28 { 29 url: "https://images.pexels.com/photos/669006/pexels-photo-669006.jpeg?w=1260", 30 altText: 'two-woman-standing-on-the-ground-and-staring-at-the-mountain', 31 extUrl: 'https://www.pexels.com/photo/two-woman-standing-on-the-ground-and-staring-at-the-mountain-669006/', 32 thumbnailUrl: "https://images.pexels.com/photos/669006/pexels-photo-669006.jpeg?w=60" 33 }, 34 ]; 35 36 constructor(){} 37 38 ngOnInit() {} 39 40 // METHODS 41 // open gallery 42 openGallery(index: number = 0) { 43 this.ngxImageGallery.open(index); 44 } 45 46 // close gallery 47 closeGallery() { 48 this.ngxImageGallery.close(); 49 } 50 51 // set new active(visible) image in gallery 52 newImage(index: number = 0) { 53 this.ngxImageGallery.setActiveImage(index); 54 } 55 56 // next image in gallery 57 nextImage(index: number = 0) { 58 this.ngxImageGallery.next(); 59 } 60 61 // prev image in gallery 62 prevImage(index: number = 0) { 63 this.ngxImageGallery.prev(); 64 } 65 66 /**************************************************/ 67 68 // EVENTS 69 // callback on gallery opened 70 galleryOpened(index) { 71 console.info('Gallery opened at index ', index); 72 } 73 74 // callback on gallery closed 75 galleryClosed() { 76 console.info('Gallery closed.'); 77 } 78 79 // callback on gallery image clicked 80 galleryImageClicked(index) { 81 console.info('Gallery image clicked with index ', index); 82 } 83 84 // callback on gallery image changed 85 galleryImageChanged(index) { 86 console.info('Gallery image changed to index ', index); 87 } 88 89 // callback on user clicked delete button 90 deleteImage(index) { 91 console.info('Delete image at index ', index); 92 } 93}
1// gallery configuration 2export interface GALLERY_CONF { 3 imageBorderRadius?: string; // css border radius of image (default 3px) 4 imageOffset?: string; // add gap between image and it's container (default 20px) 5 imagePointer? :boolean; // show a pointer on image, should be true when handling onImageClick event (default false) 6 showDeleteControl?: boolean; // show image delete icon (default false) 7 showCloseControl?: boolean; // show gallery close icon (default true) 8 showExtUrlControl?: boolean; // show image external url icon (default true) 9 showImageTitle?: boolean; // show image title text (default true) 10 showThumbnails?: boolean; // show thumbnails (default true) 11 closeOnEsc?: boolean; // close gallery on `Esc` button press (default true) 12 reactToKeyboard?: boolean; // change image on keyboard arrow press (default true) 13 reactToMouseWheel?: boolean; // change image on mouse wheel scroll (default true) 14 reactToRightClick?: boolean; // disable right click on gallery (default false) 15 thumbnailSize?: number; // thumbnail size (default 30) 16 backdropColor?: string; // gallery backdrop (background) color (default rgba(13,13,14,0.85)) 17 inline?: boolean; // make gallery inline (default false) 18 showArrows?: boolean; // show prev / next arrows (default true) 19} 20 21// gallery image 22export interface GALLERY_IMAGE { 23 url: string; // url of the image 24 thumbnailUrl?: string; // thumbnail url (recommended), if not present, gallery will use `url` property to get thumbnail image. 25 altText?: string; // alt text for image 26 title?: string; // title of the image 27 extUrl?: string; // external url of image 28 extUrlTarget?: string; // external url target e.g. '_blank', '_self' etc. 29}
All properties ending with
?
are optional.
You can make gallery inline like a carousel by setting conf.inline
to true
but make sure to change conf.backdropColor
as well if you need white backdrop color. Also width
and height
of the gallery can be adjusted by manually applying css styles with !important
flag on gallery element.
You can update gallery images images
and gallery configuration conf
anytime you want even when gallery is opened but due to Angular's change detection restrictions you must assign these variable to new value instead of changing internal properties as mentioned below.
1// change images 2this.images = this.images.concat([...]); 3 4// change conf 5this.conf = {...};
No vulnerabilities found.
No security vulnerabilities found.