Socket
Socket
Sign inDemoInstall

ng-bootstrap-lightbox

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ng-bootstrap-lightbox

The image slider directive based on lightbox2 created by Lokesh Dhakar (http://lokeshdhakar.com/projects/lightbox2/) for angularjs app. This directive does not use jQuery but use css3 animation in replacement.


Version published
Weekly downloads
115
increased by29.21%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

ng-bootstrap-lightbox

Introduction

This angular module follows Lightbox2 implementation but make use of AngularUI Bootstrap Modal and CSS3 animation to work with AngularJS without the need of jQuery.

Demo

Demo

Setup

  1. Dependancy :
  1. Installation :
  • Download and extract
  • bower install ng-bootstrap-lightbox
  1. Include stylesheet in your app
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" type="text/css"/>
<link rel="stylesheet" href="dist/css/lightbox.min.css" type="text/css">
  1. Include scripts in your app :
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.js"> </script>
<script src="dist/js/bootstrap-modal.min.js"></script>
<script src="dist/js/lightbox.min.js"></script>
  1. Inject ngBootstrapLightbox as module dependancy to your current app
angular.module('app', ['ngBootstrapLightbox']);

Basic example :

Markup :

<div ng-controller="Ctrl as Ctrl">
  <div ng-repeat="image in Ctrl.album">
   <img ng-src="{{image.thumb}}" ng-click = "Ctrl.open($index)"/>
  </div>
</div>

Controller :

angular
   .module('app')
   
   //inject lightbox service to your controller
   .controller('Ctrl', function(lightbox){
    
    //list available lightbox default options
    this.options = {
      fadeDuration: 0.7,
      resizeDuration: 0.5,
      fitImageInViewPort: true,
      positionFromTop: 20,  
      showImageNumberLabel: false,
      alwaysShowNavOnTouchDevices: false,
      wrapAround: false
    };
    
    this.album = [{
      src: '1.png',
      thumb: '1-thumb.png',
      caption: 'Optional caption 1'
    }, {
      src: '2.png',
      thumb: '2-thumb.png',
      caption: 'Optional caption 2'
    }, {
      src: '3.png', 
      thumb: '3-thumb.png',
      caption: 'Optional caption 3'
    }]; 
    
    this.open = function($index){
      lightbox.open(this.album, $index, this.options);
    }
   }); 

Configuration

Album array

Each object of album array inside controller may contains 3 properties :

PropertiesRequirementDescription
srcRequiredThe source image to your thumbnail that you want to with use lightbox when user click on thumbnail image
captionOptionalYour caption corresponding with your image
thumbOptionalSource of your thumbnail. You can use whatever properties your like, just to make sure that your controller understand that properties.

Lightbox options

PropertiesDefaultDescription
fadeDuration0.7 secondsduration starting when the src image is loaded to fully appear onto screen.
resizeDuration0.5 secondsduration starting when Lightbox container change its dimension from a default/previous image to the current image when the current image is loaded.
fitImageInViewPorttrueDetermine 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.
positionFromTop20 pxThe position of lightbox from the top of window browser
showImageNumberLabelfalseDetermine whether to show the image number to user. The default text shown is Image IMAGE_NUMBER of ALBUM_LENGTH
alwaysShowNavOnTouchDevicesfalseDetermine whether to show left/right arrow to user on Touch devices.
wrapAroundfalseDetermine 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.

Touch support

Added ngTouch support.

  1. Include ngTouch scripts :
<script src = 'https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-touch.js'></script>
  1. Inject ngTouch as your module dependancy
angular.module('app', ['ngBootstrapLightbox', 'ngTouch']);

You can now swipe left or right of your image on your mobile devices.

License

MIT

Keywords

FAQs

Last updated on 13 Mar 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc