
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
angular-bootstrap-lightbox
Advanced tools
This lightbox displays images using an AngularUI Bootstrap Modal.
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 (using ngTouch directives). 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. angular-loading-bar is used to show the progress of the image being loaded.
API documentation of the services and directive in the Angular module
Different ways to install:
bower install angular-bootstrap-lightbox --save
npm install angular-bootstrap-lightbox --save
dist
.Include the stylesheet in your app (default Bower paths given with dependencies):
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="bower_components/angular-loading-bar/build/loading-bar.css">
<link rel="stylesheet" href="bower_components/angular-bootstrap-lightbox/dist/angular-bootstrap-lightbox.css">
Include the script in your app (default Bower paths given with dependencies):
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-touch/angular-touch.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/angular-loading-bar/build/loading-bar.js"></script>
<script src="bower_components/angular-bootstrap-lightbox/dist/angular-bootstrap-lightbox.js"></script>
The Angular module is named bootstrapLightbox
. Add it as a dependency to your module:
angular.module('app', ['bootstrapLightbox']);
Gallery:
<ul ng-controller="GalleryCtrl">
<li ng-repeat="image in images">
<a ng-click="openLightboxModal($index)">
<img ng-src="{{image.thumbUrl}}" class="img-thumbnail" alt="">
</a>
</li>
</ul>
Controller:
angular.module('app').controller('GalleryCtrl', function ($scope, Lightbox) {
$scope.images = [
{
'url': '1.jpg',
'caption': 'Optional caption',
'thumbUrl': 'thumb1.jpg' // used only for this example
},
{
'url': '2.gif',
'thumbUrl': 'thumb2.jpg'
},
{
'url': '3.png',
'thumbUrl': 'thumb3.png'
}
];
$scope.openLightboxModal = function (index) {
Lightbox.openModal($scope.images, index);
};
});
The default view template for the lightbox is lightbox.html and it does not look particularly pretty. 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:
angular.module('app').config(function (LightboxProvider) {
// set a custom template
LightboxProvider.templateUrl = 'path/to/your-template.html';
});
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 Lightbox.keyboardNavEnabled
.
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 url
and 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:
angular.module('app').config(function (LightboxProvider) {
LightboxProvider.getImageUrl = function (image) {
return '/base/dir/' + image.getName();
};
LightboxProvider.getImageCaption = function (image) {
return image.label;
};
});
For a more specific example, if you have no captions, the array can contain strings for the urls:
angular.module('app').config(function (LightboxProvider) {
LightboxProvider.getImageUrl = function (imageUrl) {
return imageUrl;
};
});
angular.module('app').controller('GalleryCtrl', function ($scope, Lightbox) {
$scope.images = ['1.jpg', '2.jpg', '3.jpg'];
$scope.openLightboxModal = function (index) {
Lightbox.openModal($scope.images, index);
};
});
By default, images are scaled only if they are too large for the modal to contain without scrolling. To change this behaviour, see the documentation of the following methods:
LightboxProvider.calculateImageDimensionLimits
LightboxProvider.calculateModalDimensions
FAQs
An AngularJS lightbox built using UI Bootstrap Modal.
The npm package angular-bootstrap-lightbox receives a total of 3,292 weekly downloads. As such, angular-bootstrap-lightbox popularity was classified as popular.
We found that angular-bootstrap-lightbox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.