All Projects → themyth92 → angular2-lightbox

themyth92 / angular2-lightbox

Licence: MIT License
Lightbox2 port to use with angular2

Programming Languages

typescript
32286 projects
CSS
56736 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to angular2-lightbox

Pigallery2
A directory-first photo gallery website, witch rich UI, optimised for running on low resource servers (especially on raspberry pi)
Stars: ✭ 470 (+1324.24%)
Mutual labels:  angular2, photo-gallery
angular-progress-bar
This component allow you to easy incorporate progress-bar to angular/ionic project, providing binding and color options
Stars: ✭ 26 (-21.21%)
Mutual labels:  angular2
d3-ng2-demo
Reusable visual power? A demo of using D3 version 4 with Angular 2+.
Stars: ✭ 53 (+60.61%)
Mutual labels:  angular2
ngx-carousel
Angular Universal carousel is an lightweight , touchable and responsive library
Stars: ✭ 14 (-57.58%)
Mutual labels:  angular2
ncg-crud-ngx-md
Angular 4+ Material Design CRUD/Admin app by NinjaCodeGen http://DNAfor.NET
Stars: ✭ 36 (+9.09%)
Mutual labels:  angular2
spring-boot-angular2-starter
Starter application. Spring Boot, Angular 2, TypeScript, Gulp, Gradle, SCSS.
Stars: ✭ 35 (+6.06%)
Mutual labels:  angular2
angular-material-datatransfer
A HTML5 datatransfer UI for handling upload and download of multiple simultaneous files.
Stars: ✭ 13 (-60.61%)
Mutual labels:  angular2
8ComicDownloaderElectron
8Comic下載器:一個從8Comic網站下載漫畫的簡單程式,並以GitHub's Electron為開發架構,支援Windows/Linux/Mac,最新版本下載位址:https://github.com/wellwind/8ComicDownloaderElectron/releases
Stars: ✭ 48 (+45.45%)
Mutual labels:  angular2
abp-ng2-module
Angular module wraps abp javascript API as angular services.
Stars: ✭ 54 (+63.64%)
Mutual labels:  angular2
skawa components example
Examples for skawa_components
Stars: ✭ 16 (-51.52%)
Mutual labels:  angular2
ng2-timezone-selector
A simple Angular module to create a timezone selector using moment-timezone.
Stars: ✭ 12 (-63.64%)
Mutual labels:  angular2
a2d3
Flexible and extensible D3 directives for Angular 2
Stars: ✭ 22 (-33.33%)
Mutual labels:  angular2
angular-esri-components
A set of Angular components to work with ArcGIS API for JavaScript v4.6
Stars: ✭ 43 (+30.3%)
Mutual labels:  angular2
ng2-multi-step-wizard-ui-router1
Series 3: Tutorials on creating an Angular 2 Multi-Step Wizard using UI-Router 1.0 and TypeScript 2.0.10
Stars: ✭ 33 (+0%)
Mutual labels:  angular2
ngmodule-viz
Visualize the dependencies between the NgModules in your Angular 2+ application
Stars: ✭ 35 (+6.06%)
Mutual labels:  angular2
awesome-angular-learning
🕶️ Awesome Angular Learning Resources, Courses & Examples
Stars: ✭ 26 (-21.21%)
Mutual labels:  angular2
angular2-cookie-law
Angular2+ component that provides a banner to inform users about cookie law
Stars: ✭ 38 (+15.15%)
Mutual labels:  angular2
ng-apimock
Node plugin that provides the ability to use scenario based api mocking: for local development for protractor testing
Stars: ✭ 102 (+209.09%)
Mutual labels:  angular2
Angular-Firebase-Sortable-Table
Angular Firebase Sortable Table is a module that makes tables creation with firebase an easy task.
Stars: ✭ 28 (-15.15%)
Mutual labels:  angular2
ngx-redux-ui-management-recipes
Recipes for managing the UI layout of an application using Redux in Angular
Stars: ✭ 39 (+18.18%)
Mutual labels:  angular2

Build Status

Angular2 Lightbox

A lighbox2 implementation port to use with Angular2 without the need for jQuery

This module works with angular 2.x and 4.x demo

NOTICE:

For angular >= 5 support. Please use ngx-lightbox.

Installation

npm install --save angular2-lightbox

Update your system.config.js

{
  map: {
    'angular2-lightbox': 'node_modules/angular2-lightbox'
  },
  packages: {
    'angular2-lightbox': {
      main: './index.js',
      defaultExtension: 'js'
    }
  }
}

Usage

CSS

Include modified version of lightbox.css in your index.html

<link rel="stylesheet" href="./node_modules/angular2-lightbox/lightbox.css">

Module:

Import LightboxModule from angular2-lightbox

import { LightboxModule } from 'angular2-lightbox';

@NgModule({
  imports: [ LightboxModule ]
})

Component

  1. Markup
<div *ngFor="let image of _albums; let i=index">
  <img [src]="image.thumb" (click)="open(i)"/>
</div>
  1. Component method
import { Lightbox } from 'angular2-lightbox';

export class AppComponent {
  private _album: Array = [];
  constructor(private _lightbox: Lightbox) {
    for (let i = 1; i <= 4; i++) {
      const src = 'demo/img/image' + i + '.jpg';
      const caption = 'Image ' + i + ' caption here';
      const thumb = 'demo/img/image' + i + '-thumb.jpg';
      const album = {
         src: src,
         caption: caption,
         thumb: thumb
      };

      this._albums.push(album);
    }
  }

  open(index: number): void {
    // open lightbox
    this._lightbox.open(this._albums, index);
  }
}

Each object of album array inside your component may contains 3 properties :

Properties Requirement Description
src Required The source image to your thumbnail that you want to with use lightbox when user click on thumbnail image
caption Optional Your caption corresponding with your image
thumb Optional Source of your thumbnail. It is being used inside your component markup so this properties depends on your naming.
  1. Listen to lightbox event

You can listen to 3 events, which are either CHANGE_PAGE, CLOSE or OPEN.

import { LightboxEvent, LIGHTBOX_EVENT } from 'angular2-lightbox';
import { Subscription } from 'rxjs/Subscription';

export class AppComponent {
  private _subscription: Subscription;
  constructor(private _lightboxEvent: LightboxEvent) {}
  open(index: number): void {
    // register your subscription and callback whe open lightbox is fired
    this._subscription = this._lightboxEvent.lightboxEvent$
      .subscribe(event => this._onReceivedEvent(event));
  }

  private _onReceivedEvent(event: any): void {
    // remember to unsubscribe the event when lightbox is closed
    if (event.id === LIGHTBOX_EVENT.CLOSE) {
      // event CLOSED is fired
      this._subscription.unsubscribe();
    }

    if (event.id === LIGHTBOX_EVENT.OPEN) {
      // event OPEN is fired
    }

    if (event.id === LIGHTBOX_EVENT.CHANGE_PAGE) {
      // event change page is fired
      console.log(event.data); // -> image index that lightbox is switched to
    }
  }
}

Lightbox options

Available options based on lightbox2 options

Properties Default Description
fadeDuration 0.7 seconds duration starting when the src image is loaded to fully appear onto screen.
resizeDuration 0.5 seconds duration starting when Lightbox container change its dimension from a default/previous image to the current image when the current image is loaded.
fitImageInViewPort true Determine whether lightbox will use the natural image width/height or change the image width/height to fit the view of current window. Change this option to true to prevent problem when image too big compare to browser windows.
positionFromTop 20 px The position of lightbox from the top of window browser
showImageNumberLabel false Determine whether to show the image number to user. The default text shown is Image IMAGE_NUMBER of ALBUM_LENGTH
alwaysShowNavOnTouchDevices false Determine whether to show left/right arrow to user on Touch devices.
wrapAround false Determine whether to move to the start of the album when user reaches the end of album and vice versa. Set it to true to enable this feature.
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.

NOTE: You can either override default config or during a specific opening window

  1. Override default config
import { LightboxConfig } from 'angular2-lightbox';

export class AppComponent {
  constructor(private _lighboxConfig: LightboxConfig) {
    // override default config
    _lighboxConfig.fadeDuration = 1;
  }
}
  1. Set config in a specific opening window
import { LightboxConfig, Lightbox } from 'angular2-lightbox';

export class AppComponent {
  constructor(private _lighboxConfig: LightboxConfig, private _lightbox: Lightbox) {}
  open(index: number) {
    // override the default config on second parameter
    this._lightbox.open(this._albums, index, { wrapAround: true, showImageNumberLabel: true });
  }
}

License

MIT

Donation

Buy me a beer if you like

BTC: 1MFx5waJ7Sitn961DaXe3mQXrb7pEoSJct

ETH: 0x2211F3d683eB1C2d753aD21D9Bd9110729C80B72

NEO: ARrUrnbq1ogfsoabvCgJ5SHgknhzyUmtuS

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].