Skip to content

Commit

Permalink
Implemented feature-request #44
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jun 6, 2016
1 parent 61a6b8b commit 3359ebe
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var lightbox = $('.gallery a').simpleLightbox(options);
| captionDelay | 0 | int | adds a delay before the caption shows (in ms) |
| close | true | bool | show the close button or not |
| closeText | '×' | string | text or html for the close button |
| swipeClose | true | bool | swipe up or down to close gallery |
| showCounter | true | bool | show current image index or not |
| fileExt | 'png|jpg|jpeg|gif' | regexp or false | list of fileextensions the plugin works with or false for disable the check |
| animationSpeed | 250 | int | how long takes the slide animation |
Expand Down Expand Up @@ -101,6 +102,7 @@ var lightbox2 = $('.lighbox-2 a').simpleLightbox();
```

### Changelog
**1.8.5 - Implemented feature-request #44**
**1.8.4 - Bugfix for #41 and added option for additional html inside images #40**
**1.8.3 - Bugfix for #38 and small other fix for loop false option**
**1.8.2 - Better bugfix for #33, finally fixing multiple lightbox on one page slowness issues!**
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simplelightbox",
"version": "1.8.4",
"version": "1.8.5",
"homepage": "http://andreknieriem.de/simple-lightbox",
"authors": [
"André Rinas <info@andreknieriem.de> (http://andreknieriem.de)"
Expand Down
11 changes: 11 additions & 0 deletions dist/simple-lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ $.fn.simpleLightbox = function( options )
captionPosition: 'bottom',
close: true,
closeText: '×',
swipeClose: true,
showCounter: true,
fileExt: 'png|jpg|jpeg|gif',
animationSlide: true,
Expand Down Expand Up @@ -64,6 +65,7 @@ $.fn.simpleLightbox = function( options )
return false;
},
swipeDiff = 0,
swipeYDiff = 0,
curImg = $(),
transPrefix = function(){
var s = document.body || document.documentElement, s = s.style;
Expand Down Expand Up @@ -261,6 +263,8 @@ $.fn.simpleLightbox = function( options )
// touchcontrols
var swipeStart = 0,
swipeEnd = 0,
swipeYStart = 0,
swipeYEnd = 0,
mousedown = false,
imageLeft = 0;

Expand All @@ -271,14 +275,17 @@ $.fn.simpleLightbox = function( options )
if( canTransisions ) imageLeft = parseInt( image.css( 'left' ) );
mousedown = true;
swipeStart = e.originalEvent.pageX || e.originalEvent.touches[ 0 ].pageX;
swipeYStart = e.originalEvent.pageY || e.originalEvent.touches[ 0 ].pageY;
return false;
})
.on( 'touchmove.'+prefix+' mousemove.'+prefix+' pointermove MSPointerMove', function(e)
{
if(!mousedown) return true;
e.preventDefault();
swipeEnd = e.originalEvent.pageX || e.originalEvent.touches[ 0 ].pageX;
swipeYEnd = e.originalEvent.pageY || e.originalEvent.touches[ 0 ].pageY;
swipeDiff = swipeStart - swipeEnd;
swipeYDiff = swipeYStart - swipeYEnd;
if( options.animationSlide ) {
if( canTransisions ) slide( 0, -swipeDiff + 'px' );
else image.css( 'left', imageLeft - swipeDiff + 'px' );
Expand All @@ -301,6 +308,10 @@ $.fn.simpleLightbox = function( options )
if( canTransisions ) slide( options.animationSpeed / 1000, 0 + 'px' );
else image.animate({ 'left': imageLeft + 'px' }, options.animationSpeed / 2 );
}

if( options.swipeClose && Math.abs(swipeYDiff) > 50 && Math.abs( swipeDiff ) < options.swipeTolerance) {
close();
}
}
});
},
Expand Down
2 changes: 1 addition & 1 deletion dist/simple-lightbox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simplelightbox",
"version": "1.8.4",
"version": "1.8.5",
"description": "Touch-friendly image lightbox for mobile and desktop with jQuery",
"main": "dist/simple-lightbox.js",
"repository": {
Expand Down

0 comments on commit 3359ebe

Please sign in to comment.