Skip to content

Commit

Permalink
Merged pull request #111, fixed #101 and added possibility to close l…
Browse files Browse the repository at this point in the history
…ightbox on load #74
  • Loading branch information
root committed Oct 17, 2018
1 parent 5baaef4 commit d845155
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ $sl-iframe-border-large: 0 none;


### Changelog
**1.15.0 - Merged pull request #111, fixed #101 and added possibility to close lightbox on load #74**
**1.14.0 - Merged pull request #107 and #108. Thanks to RaphaelHaettich**
**1.13.0 - Added featured #92 and merged pull request #98 and #99. Thanks to RaphaelHaettich**
**1.12.2 - Bugfix for #89**
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.14.0",
"version": "1.15.0",
"homepage": "http://andreknieriem.de/simple-lightbox",
"authors": [
"André Rinas <[email protected]> (http://andrerinas.de)"
Expand Down
4 changes: 2 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<title>Simple Lightbox - Responsive touch friendly Image lightbox</title>
<link href='http://fonts.googleapis.com/css?family=Slabo+27px' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Slabo+27px' rel='stylesheet' type='text/css'>
<link href='../dist/simplelightbox.min.css' rel='stylesheet' type='text/css'>
<link href='demo.css' rel='stylesheet' type='text/css'>
</head>
Expand Down Expand Up @@ -36,7 +36,7 @@ <h1 class="align-center">Simple Lightbox Demo Page</h1>
<p>All images are free availabled on <a href="https://unsplash.com/" target="_blank">Unsplash</a></p>
<p>Documentation and download <a target="_blank" href="http://andreknieriem.de/simple-lightbox/">here</a></p>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript" src="../dist/simple-lightbox.js"></script>
<script>
$(function(){
Expand Down
34 changes: 20 additions & 14 deletions dist/simple-lightbox.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
By André Rinas, www.andrerinas.de
Available for use under the MIT License
1.14.0
1.15.0
*/
;( function( $, window, document, undefined )
{
Expand Down Expand Up @@ -98,7 +98,7 @@ $.fn.simpleLightbox = function( options )
updateHash = function(){
var hash = getHash(),
newHash = 'pid='+(index+1);
var newURL = winLoc.href.split('#')[0] + '#' + newHash;
var newURL = winLoc.href.split('#')[0] + '#' + newHash;

if(supportsPushState){
history[historyhasChanged ? 'replaceState' : 'pushState']('', document.title, newURL);
Expand All @@ -113,7 +113,7 @@ $.fn.simpleLightbox = function( options )
},
resetHash = function() {
if (supportsPushState) {
history.pushState('', document.title, winLoc.pathname + winLoc.search );
history.pushState('', document.title, winLoc.pathname + winLoc.search );
} else {
winLoc.hash = '';
}
Expand Down Expand Up @@ -247,7 +247,7 @@ $.fn.simpleLightbox = function( options )

$('.sl-image').css({
'top': ( window.innerHeight - imageHeight ) / 2 + 'px',
'left': ( window.innerWidt - imageWidth - globalScrollbarwidth)/ 2 + 'px'
'left': ( window.innerWidth - imageWidth - globalScrollbarwidth)/ 2 + 'px'
});
spinner.hide();
curImg
Expand Down Expand Up @@ -303,7 +303,7 @@ $.fn.simpleLightbox = function( options )
},
setCaption = function(captiontext, imageWidth){
if(captiontext !== '' && typeof captiontext !== "undefined" && options.captions){
caption.html(captiontext).css({'width': imageWidth + 'px'}).hide().appendTo($('.sl-image')).delay(options.captionDelay).fadeIn('fast');
caption.html(captiontext).css({'width': imageWidth + 'px'}).hide().appendTo($('.sl-image')).delay(options.captionDelay).fadeIn('fast');
}
},
slide = function(speed, pos){
Expand Down Expand Up @@ -371,8 +371,8 @@ $.fn.simpleLightbox = function( options )
swipeDiff = swipeStart - swipeEnd;
swipeYDiff = swipeYStart - swipeYEnd;
if( options.animationSlide ) {
if( canTransisions ) slide( 0, -swipeDiff + 'px' );
else image.css( 'left', imageLeft - swipeDiff + 'px' );
if( canTransisions ) slide( 0, -swipeDiff + 'px' );
else image.css( 'left', imageLeft - swipeDiff + 'px' );
}
})
.on( 'touchend.'+prefix+' mouseup.'+prefix+' touchcancel.'+prefix+' mouseleave.'+prefix+' pointerup pointercancel MSPointerUp MSPointerCancel',function(e)
Expand Down Expand Up @@ -431,10 +431,10 @@ $.fn.simpleLightbox = function( options )
if(animating || (newIndex < 0 || newIndex >= objects.length) && options.loop === false ) return;
index = (newIndex < 0) ? objects.length -1: (newIndex > objects.length -1) ? 0 : newIndex;
$('.sl-wrapper .sl-counter .sl-current').text(index +1);
var css = { 'opacity': 0 };
var css = { 'opacity': 0 };
if( options.animationSlide ) {
if( canTransisions ) slide(options.animationSpeed / 1000, ( -100 * dir ) - swipeDiff + 'px');
else css.left = parseInt( $('.sl-image').css( 'left' ) ) + -100 * dir + 'px';
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(){
Expand Down Expand Up @@ -468,9 +468,9 @@ $.fn.simpleLightbox = function( options )
if(!triggered) elem.trigger($.Event('closed.simplelightbox'));
triggered = true;
});
curImg = $();
opened = false;
animating = false;
curImg = $();
opened = false;
animating = false;
},
handleScrollbar = function(type){
var scrollbarWidth = 0;
Expand Down Expand Up @@ -532,9 +532,15 @@ $.fn.simpleLightbox = function( options )
$( document ).on( 'keyup.'+prefix, throttle(function( e ){
swipeDiff = 0;
// keyboard control only if lightbox is open
var key = e.keyCode;
if(animating && key == 27) {
curImg.attr('src', '');
animating = false;
close();
}

if(opened){
e.preventDefault();
var key = e.keyCode;
if( key == 27 ) {
close();
}
Expand Down
Loading

0 comments on commit d845155

Please sign in to comment.