This lightbox displays images using an AngularUI Bootstrap Modal (v0.14).
When the lightbox is opened, navigating to the previous/next image can be achieved by clicking buttons above the image, clicking the left/right arrow keys, or swiping to the left/right (optional with ngTouch). The escape key for closing the modal is automatically binded by AngularUI Bootstrap.
Large images are scaled to fit inside the window. An optional image caption overlays the top left corner of the image.
- Install in one of the following ways:
- Install with Bower:
bower install angular-bootstrap-lightbox --save
- Install with npm:
npm install angular-bootstrap-lightbox --save
- Manually save the script and stylesheet from
- Include the stylesheet in your app:
- Include the script in your app:
- The Angular module is named
bootstrapLightbox. Add it as a dependency to your module:
- Optional dependencies:
- To enable swipe navigation in the lightbox, include the ngTouch script.
- To show a loading bar while an image is loading, include the angular-loading-bar script.
- For video support, include the ng-videosharing-embed script.
Changing the appearance of the modal lightbox
The default view template for the lightbox is lightbox.html. Its look can be changed by making your own custom template and/or adding CSS rules; for example, use the selector
.lightbox-image-caption to style the caption.
If you make your own template and save it at
lightbox.html, no further code is necessary. If you save it at a different path, set it in the provider:
Disabling the keyboard navigation
The keyboard navigation in the lightbox with the left/right arrow keys can be enabled/disabled at any time by changing the value of the boolean
Array of images
The first argument to
Lightbox.openModal must be an array, and its elements may be of any type. In the basic example above, it is an array of objects with properties
caption, but this is only the default and is not required. To let the
Lightbox service know the correct values, set these methods in the provider:
Image and modal scaling
By default, images are scaled only if they are too large for the modal to contain without scrolling.
If you want all images to be scaled to the maximum possible dimensions, update the
For more custom behaviour, see the documentation of the methods
An element in the array of 'images' is considered a video if it is an object with a
type property having the value
video (see the demo). To change this, write your own
By default, a video is embedded directly if its url ends in
.webm. Every other url is considered a video from an external sharing service (such as YouTube). To change this check, edit the
LightboxProvider.isSharedVideo method. The
ng-videosharing-embed library is used for embedding shared videos if it is included in your app. You can use another video library by changing the template.
For now, the maximum video dimensions are fixed at 1280x720 (16:9).
API documentation of the services and directive in the Angular module
Setup:npm installbower install
Generate docs:grunt jsdoc2md
Serve the GitHub Pages:git checkout gh-pagesgit checkout master -- dist/angular-bootstrap-lightbox.min.js dist/angular-bootstrap-lightbox.min.cssbundle installbundle exec jekyll serve