Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ngx-cdk-lightbox

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-cdk-lightbox

Custom implementation of CDK to display image gallery in lightbox.

  • 1.4.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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(GalleryDisplayObjectType[], GalleryConfigInterface);
type GalleryDisplayObjectType = GalleryImageInterface|GalleryVideoInterface;
interface GalleryImageInterface
{
	type: 'image';
	source: string;
	description?: string;
	copyright?: string;
}
type videoResolutionsType = 240|360|480|720|1080|2160|4320;
export interface GalleryVideoInterface
{
	type: 'video',
	mp4Source: string|Partial<Record<videoResolutionsType, string>>;
	description?: string;
	copyright?: string;
	resolution?: {
		width: number;
		height: number;
	};
}
interface GalleryConfigInterface
{
	enableZoom?: boolean;
	zoomSize?: number|'originalSize';
	enableImageClick?: boolean;
	loopGallery?: boolean;
	enableImageCounter?: boolean;
	imageCounterText?: string;
	enableCloseIcon?: boolean;
	closeIcon?: string;
	enableArrows?: boolean;
	arrowRight?: string;
	arrowLeft?: string;
	enableImagePreloading?: boolean;
	startingIndex?: number;
	enableAnimations?: boolean;
}
GalleryImageInterface
keyvalue
type'image'
sourcepath to image
descriptionoptional - description of image
copyrightoptional - copyright info
GalleryVideoInterface
keyvalue
type'video'
mp4Sourcepath to video source/sources
descriptionoptional - description of video
copyrightoptional - copyright info
resolutionwidth and height of video
GalleryConfigInterface
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
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 lightboxService: NgxCdkLightboxService)
	{
	}

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

		return;
	}
}

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

Keywords

FAQs

Package last updated on 12 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc