19.0.0 • Published 8 months ago

ngx-cdk-lightbox v19.0.0

Weekly downloads
92
License
MIT
Repository
github
Last release
8 months ago

ngx-cdk-lightbox

Custom implementation of CDK to display image gallery in lightbox.

Demo

https://www.davidmyska.com/ngx-cdk-lightbox/

Installation

1. Install npm package

npm

npm install ngx-cdk-lightbox --save

yarn

yarn add ngx-cdk-lightbox

2. Import library to your module

import { NgxCdkLightboxModule } from 'ngx-cdk-lightbox';

3. Import NgxCdkLightboxModule into your module

@NgModule({
	imports: [...NgxCdkLightboxModule],
})
export class SomeModule {}

Usage

this.lightboxService.open(TGalleryDisplayObject[], IGalleryConfig);
type TGalleryDisplayObject = IGalleryImage | IGalleryVideo;
interface IGalleryImage {
	type: 'image';
	source: string;
	description?: string;
	copyright?: string;
}
type TVideoResolutions = 240 | 360 | 480 | 720 | 1080 | 2160 | 4320;
export interface IGalleryVideo {
	type: 'video';
	mp4Source: string | Partial<Record<TVideoResolutions, string>>;
	description?: string;
	copyright?: string;
	resolution?: {
		width: number;
		height: number;
	};
}
interface IGalleryConfig {
	enableZoom?: boolean;
	zoomSize?: number | 'originalSize';
	enableImageClick?: boolean;
	loopGallery?: boolean;
	enableImageCounter?: boolean;
	imageCounterText?: string;
	enableCloseIcon?: boolean;
	closeIcon?: string;
	enableArrows?: boolean;
	arrowRight?: string;
	arrowLeft?: string;
	loaderTemplate?: TemplateRef<unknown>;
	enableImagePreloading?: boolean;
	startingIndex?: number;
	enableAnimations?: boolean;
}

IGalleryImage

keyvalue
type'image'
sourcepath to image
descriptionoptional - description of image
copyrightoptional - copyright info

IGalleryVideo

keyvalue
type'video'
mp4Sourcepath to video source/sources
descriptionoptional - description of video
copyrightoptional - copyright info
resolutionwidth and height of video

IGalleryConfig

keytypedefaultvalue
enableZoombooleanfalsedisplay zoom on mouse hover over image
zoomSizenumber, 'originalSize''originalSize'zoom size, number for zoom multiplication, originalSize for original image size
enableImageClickbooleantrueenable click on image to navigate to next or previous image
loopGallerybooleantrueloop gallery after last image or before first image
enableImageCounterbooleantruedisplay current image counter
imageCounterTextstring'IMAGE_INDEX photo of IMAGE_COUNT'format for image counter
enableCloseIconbooleantruedisplay close icon
closeIconstringhttps://material.io/tools/icons/?icon=close&style=baselineHTML string containing close icon
enableArrowsbooleantruedisplay next/prev icons
arrowRightstringhttps://material.io/tools/icons/?icon=keyboard_arrow_right&style=baselineHTML string containing right arrow
arrowLeftstringhttps://material.io/tools/icons/?icon=keyboard_arrow_left&style=baselineHTML string containing left arrow
loaderTemplateTemplateRefnullSet custom loader by providing template reference
enableImagePreloadingbooleanenable/disable image preloading
startingIndexnumber0index of starting image
enableAnimationsbooleantrueenable/disable animations
ariaLabelNextstring'Next'Aria label for next button
ariaLabelPrevstring'Previous'Aria label for previous button

Usage example

@Component({
	...
})
export class SomeComponent
{
	constructor(private readonly lightboxService: NgxCdkLightboxService) {}

	public openLightbox(): void {
		this.lightboxService.open([
			{source: 'assets/images/image1.jpg', copyright: 'unknown'},
			{source: 'assets/images/image5.jpg', copyright: 'unknown'},
		], {
			enableAnimations: false,
		});
	}
}

ToDo

  • Support for iframe

Donate

You are currently using code that is totally for free and that is fine. But if you want to put a soup on a developer's table anyway, feel free to do so :).

paypal

19.0.0

8 months ago

18.0.1

1 year ago

18.0.0

1 year ago

17.0.0

2 years ago

16.0.0

2 years ago

15.0.1

3 years ago

15.0.0

3 years ago

14.0.0

3 years ago

13.0.0

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.1.0

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago