Skip to content

Commit

Permalink
Support custom label
Browse files Browse the repository at this point in the history
Fix #13
  • Loading branch information
themyth92 committed Nov 21, 2018
1 parent b28f883 commit d94247d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ wrapAround | **false** | Determine whether to move to the start of the album whe
disableKeyboardNav | **false** | Determine whether to disable navigation using keyboard event.
disableScrolling | **false** | If **true**, prevent the page from scrolling while Lightbox is open. This works by settings overflow hidden on the body.
centerVertically | **false** | If **true**, images will be centered vertically to the screen.
albumLabel | "Image %1 of %2" | The text displayed below the caption when viewing an image set. The default text shows the current image number and the total number of images in the set.
enableTransition | **true** | Transition animation between images will be disabled if this flag set to **false**

**NOTE**: You can either override default config or during a specific opening window
1. Override default config
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-lightbox",
"version": "1.1.1",
"version": "1.2.0",
"description": "A port >= angular5 for lightbox2",
"main": "index.js",
"dependencies": {},
Expand Down
2 changes: 2 additions & 0 deletions src/lightbox-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class LightboxConfig {
public disableScrolling: boolean;
public centerVertically: boolean;
public enableTransition: boolean;
public albumLabel: string;
constructor() {
this.fadeDuration = 0.7;
this.resizeDuration = 0.5;
Expand All @@ -25,5 +26,6 @@ export class LightboxConfig {
this.disableScrolling = false;
this.centerVertically = false;
this.enableTransition = true;
this.albumLabel = 'Image %1 of %2';
}
}
2 changes: 1 addition & 1 deletion src/lightbox.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export class LightboxComponent implements AfterViewInit, OnDestroy, OnInit {

private _albumLabel(): string {
// due to {this.currentImageIndex} is set from 0 to {this.album.length} - 1
return `Image ${Number(this.currentImageIndex + 1)} of ${this.album.length}`;
return this.options.albumLabel.replace(/%1/g, Number(this.currentImageIndex + 1)).replace(/%2/g, this.album.length);
}

private _changeImage(newIndex: number): void {
Expand Down

0 comments on commit d94247d

Please sign in to comment.