Download
Demo
- Overview
- Documents
User Rating: 4.5/5 ( 4 votes)
Your Rating:
Simple Lightbox - Touch-friendly image lightbox for mobile and desktop with jQuery
Features
- responsive
-
touchfriendly
swipe gestures for next/previous image - easy to install, easy to use
-
minimalistic
Only some css is included. You can change the style like you want! - lots of options
- preloading next and previous image
- Android, iOs and Windows phone support
- CSS3 Transitions with fallback for older browsers
- Can use jQuery 1.x or 2.x
- Keyboard support
Source: andreknieriem.de
1. INCLUDE CSS AND JS FILES
<link href='../dist/simplelightbox.min.css' rel='stylesheet' type='text/css'> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript" src="../dist/simple-lightbox.js"></script>
2. HTML
<div class="gallery"> <a href="images/image1.jpg" class="big"><img src="images/thumbs/thumb1.jpg" alt="" title="Beautiful Image" /></a> <a href="images/image2.jpg"><img src="images/thumbs/thumb2.jpg" alt="" title=""/></a> <a href="images/image3.jpg"><img src="images/thumbs/thumb3.jpg" alt="" title="Beautiful Image"/></a> <a href="images/image4.jpg"><img src="images/thumbs/thumb4.jpg" alt="" title=""/></a> <div class="clear"></div> <a href="images/image5.jpg"><img src="images/thumbs/thumb5.jpg" alt="" title=""/></a> <a href="images/image6.jpg"><img src="images/thumbs/thumb6.jpg" alt="" title=""/></a> <a href="images/image7.jpg" class="big"><img src="images/thumbs/thumb7.jpg" alt="" title=""/></a> <a href="images/image8.jpg"><img src="images/thumbs/thumb8.jpg" alt="" title=""/></a> <div class="clear"></div> <a href="images/image9.jpg" class="big"><img src="images/thumbs/thumb9.jpg" alt="" title=""/></a> <a href="images/image10.jpg"><img src="images/thumbs/thumb10.jpg" alt="" title=""/></a> <a href="images/image11.jpg"><img src="images/thumbs/thumb11.jpg" alt="" title=""/></a> <a href="images/image12.jpg"><img src="images/thumbs/thumb12.jpg" alt="" title=""/></a> <div class="clear"></div> </div>
3. JAVASCRIPT
$(function(){ var gallery = $('.gallery a').simpleLightbox(); });
4. OPTIONS
Property | Default | Type | Description |
---|---|---|---|
overlay | true | bool | show an overlay or not |
spinner | true | bool | show spinner or not |
nav | true | bool | show arrow-navigation or not |
navText | [‚←‘,’→‘] | array | text or html for the navigation arrows |
captions | true | bool | show captions if availabled or not |
captionsData | title | string | get the caption from title or data-title attribute |
close | true | bool | show the close button or not |
closeText | ‚X‘ | string | text or html for the close button |
fileExt | ‚png|jpg|jpeg|gif‘ | regexp | list of fileextensions the plugin works with |
animationSpeed | 250 | int | how long takes the slide animation |
preloading | true | bool | allows preloading next und previous images |
enableKeyboard | true | bool | allow keyboard arrow navigation and close with ESC key |
loop | true | bool | enables looping through images |
docClose | true | bool | closes the lightbox when clicking outside |
swipeTolerance | 50 | int | how much pixel you have to swipe, until next or previous image |
className: | ‚simple-lightbox‘ | string | adds a class to the wrapper of the lightbox |
widthRatio: | 0.8 | float | Ratio of image width to screen width |
heightRatio: | 0.9 | float | Ratio of image height to screen height |
5. EVENTS
Name | Description |
---|---|
open.simplelightbox | this event fires before the lightbox opens |
opened.simplelightbox | this event fires after the lightbox was opened |
close.simplelightbox | this event fires before the lightbox closes |
closed.simplelightbox | this event fires after the lightbox was closed |
Example
$('.gallery a').on('open.simplelightbox', function () { // do something… });
6. METHODS
Name | Description |
---|---|
open | Opens the lightbox with an given jQuery Element |
close | Closes current openend Lightbox |
next | Go to next image |
prev | Go to previous image |
destroy | Destroys the instance of the lightbox |
Example
var gallery = $('.gallery a').simpleLightbox(); gallery.next(); // Next Image