Skip to content

Commit

Permalink
Bugfix for #31, #32 and #33
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Feb 28, 2016
1 parent d53a973 commit 4a24e18
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ var lightbox2 = $('.lighbox-2 a').simpleLightbox();
```

### Changelog
**1.8.1 - Bugfix for #31, #32 and #33**
**1.8.0 - New API Events (changed open to show) and little fix in function open() brought by Geoffrey Crofte and some other small bugfixes**
**1.7.2 - Bugfix von #25 and #27**
**1.7.1 - Bugfix von #22 with new option alertError and merged pull request #23**
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.0",
"version": "1.8.1",
"homepage": "http://andreknieriem.de/simple-lightbox",
"authors": [
"André Rinas <[email protected]> (http://andreknieriem.de)"
Expand Down
24 changes: 19 additions & 5 deletions dist/simple-lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ $.fn.simpleLightbox = function( options )
return false;
},
opened = false,

objects = $( this.selector, this.context ),
loaded = [],
objects = this,
transPrefix = transPrefix(),
canTransisions = (transPrefix !== false) ? true : false,
prefix = 'simplelb',
Expand Down Expand Up @@ -115,6 +115,9 @@ $.fn.simpleLightbox = function( options )
curImg = $( '<img/>' )
.hide()
.attr('src', elem.attr('href'));
if(loaded.indexOf(elem.attr('href')) == -1){
loaded.push(elem.attr('href'));
}
$('.sl-image').html('').attr('style','');
curImg.appendTo($('.sl-image'));
overlay.fadeIn('fast');
Expand Down Expand Up @@ -152,14 +155,16 @@ $.fn.simpleLightbox = function( options )
return;
}
})

tmpImage.onload = function() {
if (typeof dir !== 'undefined') {
objects.eq(index)
.trigger($.Event('changed.simplelightbox'))
.trigger($.Event( (dir===1?'nextDone':'prevDone')+'.simplelightbox'));
}

if(loaded.indexOf(curImg.attr( 'src' )) == -1){
loaded.push(curImg.attr( 'src' ));
}
var imageWidth = tmpImage.width,
imageHeight = tmpImage.height;

Expand Down Expand Up @@ -236,9 +241,15 @@ $.fn.simpleLightbox = function( options )
var next = (index+1 < 0) ? objects.length -1: (index+1 >= objects.length -1) ? 0 : index+1,
prev = (index-1 < 0) ? objects.length -1: (index-1 >= objects.length -1) ? 0 : index-1;
$( '<img />' ).attr( 'src', objects.eq(next).attr( 'href' ) ).load(function(){
if(loaded.indexOf($(this).attr('src')) == -1){
loaded.push($(this).attr('src'));
}
objects.eq(index).trigger($.Event('nextImageLoaded.simplelightbox'));
});
$( '<img />' ).attr( 'src', objects.eq(prev).attr( 'href' ) ).load(function(){
if(loaded.indexOf($(this).attr('src')) == -1){
loaded.push($(this).attr('src'));
}
objects.eq(index).trigger($.Event('prevImageLoaded.simplelightbox'));
});

Expand All @@ -248,7 +259,6 @@ $.fn.simpleLightbox = function( options )
.trigger($.Event('change.simplelightbox'))
.trigger($.Event( (dir===1?'next':'prev')+'.simplelightbox'));

spinner.show();
var newIndex = index + dir;
if(animating || (newIndex < 0 || newIndex >= objects.length) && options.loop == false ) return;
index = (newIndex < 0) ? objects.length -1: (newIndex > objects.length -1) ? 0 : newIndex;
Expand All @@ -258,12 +268,16 @@ $.fn.simpleLightbox = function( options )
if( canTransisions ) slide(options.animationSpeed / 1000, ( -100 * dir ) - swipeDiff + 'px');
else css.left = parseInt( $('.sl-image').css( 'left' ) ) + -100 * dir + 'px';
}

$('.sl-image').animate( css, options.animationSpeed, function(){
setTimeout( function(){
// fadeout old image
var elem = objects.eq(index);
curImg
.attr('src', elem.attr('href'));
if(loaded.indexOf(elem.attr('href')) == -1){
spinner.show();
}
$('.sl-caption').remove();
adjustImage(dir);
if(options.preloading) preload();
Expand Down Expand Up @@ -305,7 +319,7 @@ $.fn.simpleLightbox = function( options )
}
}
} else {
$('body').css({'padding-right':$('body').data('padding'), 'overflow':'auto'});
$('body').css({'padding-right':$('body').data('padding'), 'overflow':'visible'});
}
}

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.0",
"version": "1.8.1",
"description": "Touch-friendly image lightbox for mobile and desktop with jQuery",
"main": "dist/simple-lightbox.js",
"repository": {
Expand Down

0 comments on commit 4a24e18

Please sign in to comment.