diff --git a/README.md b/README.md index cbdc525..e3f5096 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,7 @@ $add-vendor-prefixes: true !default; ### Changelog +**1.16.3 - Merged pull request #126,#127 - Thanks to jieter** **1.16.2 - Added featured #124 - Add a class to html element if lightbox is open** **1.16.1 - Fixed pinch to zoom offset error on scrolling #123** **1.16.0 - Pinch to Zoom feature for touch devices with new options doubleTapZoom and maxZoom #79** @@ -216,7 +217,7 @@ $add-vendor-prefixes: true !default; **1.0.0 - Initial Release** ### Author -[Andre Rinas](http://andrerinas.de/) - [Github](https://github.com/andreknieriem/) +[Andre Rinas](https://www.andrerinas.de/) - [Github](https://github.com/andreknieriem/) ### Contributors [nicekiwi](https://github.com/nicekiwi) diff --git a/bower.json b/bower.json index 8c54708..584705f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "simplelightbox", - "version": "1.16.2", + "version": "1.16.3", "homepage": "http://simplelightbox.com/", "authors": [ "André Rinas (https://www.andrerinas.de)" diff --git a/dist/simple-lightbox.js b/dist/simple-lightbox.js index 26a1daa..d3f9dac 100644 --- a/dist/simple-lightbox.js +++ b/dist/simple-lightbox.js @@ -1,8 +1,8 @@ -/* +/*! By André Rinas, www.andrerinas.de Documentation, www.simplelightbox.de Available for use under the MIT License - 1.16.2 + 1.16.3 */ ;( function( $, window, document, undefined ) { @@ -413,6 +413,9 @@ $.fn.simpleLightbox = function( options ) image .on( 'touchstart.'+prefix+' mousedown.'+prefix, function(e) { + if (e.target.tagName === 'A' && e.type == 'touchstart') { + return true; + } e = e.originalEvent; if(e.type == 'mousedown') { diff --git a/dist/simple-lightbox.min.js b/dist/simple-lightbox.min.js index 619da36..0e5f0c7 100644 --- a/dist/simple-lightbox.min.js +++ b/dist/simple-lightbox.min.js @@ -2,6 +2,6 @@ By André Rinas, www.andrerinas.de Documentation, www.simplelightbox.de Available for use under the MIT License - 1.16.2 + 1.16.3 */ -!function(ot,lt,rt,t){"use strict";ot.fn.simpleLightbox=function(z){z=ot.extend({sourceAttr:"href",overlay:!0,spinner:!0,nav:!0,navText:["‹","›"],captions:!0,captionDelay:0,captionSelector:"img",captionType:"attr",captionsData:"title",captionPosition:"bottom",captionClass:"",close:!0,closeText:"×",swipeClose:!0,showCounter:!0,fileExt:"png|jpg|jpeg|gif",animationSlide:!0,animationSpeed:250,preloading:!0,enableKeyboard:!0,loop:!0,rel:!1,docClose:!0,swipeTolerance:50,className:"simple-lightbox",widthRatio:.8,heightRatio:.9,scaleImageToRatio:!1,disableRightClick:!1,disableScroll:!0,alertError:!0,alertErrorMessage:"Image not found, next image will be loaded",additionalHtml:!1,history:!0,throttleInterval:0,doubleTapZoom:2,maxZoom:10,htmlClass:"has-lightbox"},z);var h,t,H="ontouchstart"in lt,L=(lt.navigator.pointerEnabled||lt.navigator.msPointerEnabled,0),Z=0,F=ot(),i=function(){var t=rt.body||rt.documentElement;return""===(t=t.style).WebkitTransition?"-webkit-":""===t.MozTransition?"-moz-":""===t.OTransition?"-o-":""===t.transition&&""},N=!1,d=[],j=z.rel&&!1!==z.rel?(t=z.rel,ot(this).filter(function(){return ot(this).attr("rel")===t})):this,p=(i=i(),0),K=!1!==i,a="pushState"in history,u=!1,n=lt.location,$=function(){return n.hash.substring(1)},B=$(),g=function(){$();var t="pid="+(J+1),e=n.href.split("#")[0]+"#"+t;a?history[u?"replaceState":"pushState"]("",rt.title,e):u?n.replace(e):n.hash=t,u=!0},Q=function(e,a){var n;return function(){var t=arguments;n||(e.apply(this,t),n=!0,setTimeout(function(){return n=!1},a))}},U="simplelb",e=ot("
").addClass("sl-overlay"),s=ot(""),o=ot("
").addClass("sl-counter").html('/'),m=!1,J=0,v=0,l=ot("
").addClass("sl-caption "+z.captionClass+" pos-"+z.captionPosition),V=ot("
").addClass("sl-image"),r=ot("
").addClass("sl-wrapper").addClass(z.className),c=function(t){t.trigger(ot.Event("show.simplelightbox")),z.disableScroll&&(p=C("hide")),z.htmlClass&&""!=z.htmlClass&&ot("html").addClass(z.htmlClass),r.appendTo("body"),V.appendTo(r),z.overlay&&e.appendTo(ot("body")),m=!0,J=j.index(t),F=ot("").hide().attr("src",t.attr(z.sourceAttr)).attr("data-scale",1).attr("data-translate-x",0).attr("data-translate-y",0),-1==d.indexOf(t.attr(z.sourceAttr))&&d.push(t.attr(z.sourceAttr)),V.html("").attr("style",""),F.appendTo(V),b(),e.fadeIn("fast"),ot(".sl-close").fadeIn("fast"),f.show(),G.fadeIn("fast"),ot(".sl-wrapper .sl-counter .sl-current").text(J+1),o.fadeIn("fast"),_(),z.preloading&&y(),setTimeout(function(){t.trigger(ot.Event("shown.simplelightbox"))},z.animationSpeed)},_=function(o){if(F.length){var l=new Image,r=lt.innerWidth*z.widthRatio,c=lt.innerHeight*z.heightRatio;l.src=F.attr("src"),F.data("scale",1),F.data("translate-x",0),F.data("translate-y",0),et(0,0,1),ot(l).on("error",function(t){j.eq(J).trigger(ot.Event("error.simplelightbox")),N=!(m=!1),f.hide();var e=1==o||-1==o;v===J&&e?st():(z.alertError&&alert(z.alertErrorMessage),it(e?o:1))}),l.onload=function(){void 0!==o&&j.eq(J).trigger(ot.Event("changed.simplelightbox")).trigger(ot.Event((1===o?"nextDone":"prevDone")+".simplelightbox")),z.history&&(u?h=setTimeout(g,800):g()),-1==d.indexOf(F.attr("src"))&&d.push(F.attr("src"));var t=l.width,e=l.height;if(z.scaleImageToRatio||r=j.length-1&&ot(".sl-next").hide(),0").html(z.additionalHtml).addClass("sl-additional-html").appendTo(ot(".sl-image"))}}},x=function(t,e){""!==t&&void 0!==t&&z.captions&&l.html(t).css({width:e+"px"}).hide().appendTo(ot(".sl-image")).delay(z.captionDelay).fadeIn("fast")},tt=function(t,e){var a={};a[i+"transform"]="translateX("+e+")",a[i+"transition"]=i+"transform "+t+"s linear",ot(".sl-image").css(a)},et=function(t,e,a){var n={};n[i+"transform"]="translate("+t+","+e+") scale("+a+")",F.css(n)},at=function(t,e,a){return t=j.length-1&&0z.swipeTolerance&&e?it(0=j.length-1?0:J+1,e=J-1<0?j.length-1:J-1>=j.length-1?0:J-1;ot("").attr("src",j.eq(t).attr(z.sourceAttr)).on("load",function(){-1==d.indexOf(ot(this).attr("src"))&&d.push(ot(this).attr("src")),j.eq(J).trigger(ot.Event("nextImageLoaded.simplelightbox"))}),ot("").attr("src",j.eq(e).attr(z.sourceAttr)).on("load",function(){-1==d.indexOf(ot(this).attr("src"))&&d.push(ot(this).attr("src")),j.eq(J).trigger(ot.Event("prevImageLoaded.simplelightbox"))})},it=function(e){j.eq(J).trigger(ot.Event("change.simplelightbox")).trigger(ot.Event((1===e?"next":"prev")+".simplelightbox"));var t=J+e;if(!(m||(t<0||t>=j.length)&&!1===z.loop)){J=t<0?j.length-1:t>j.length-1?0:t,ot(".sl-wrapper .sl-counter .sl-current").text(J+1);var a={opacity:0};z.animationSlide&&(K?tt(z.animationSpeed/1e3,-100*e-L+"px"):a.left=parseInt(ot(".sl-image").css("left"))+-100*e+"px"),ot(".sl-image").animate(a,z.animationSpeed,function(){setTimeout(function(){var t=j.eq(J);F.attr("src",t.attr(z.sourceAttr)),-1==d.indexOf(t.attr(z.sourceAttr))&&f.show(),ot(".sl-caption").remove(),_(e),z.preloading&&y()},100)})}},st=function(){if(!m){var t=j.eq(J),e=!1;t.trigger(ot.Event("close.simplelightbox")),z.history&&(a?history.pushState("",rt.title,n.pathname+n.search):n.hash="",clearTimeout(h)),ot(".sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter").fadeOut("fast",function(){z.disableScroll&&C("show"),z.htmlClass&&""!=z.htmlClass&&ot("html").removeClass(z.htmlClass),ot(".sl-wrapper, .sl-overlay").remove(),G.off("click","button"),ot(rt).off("click."+U,".sl-close"),ot(lt).off("resize."+U),ot(lt).off("hashchange."+U),e||t.trigger(ot.Event("closed.simplelightbox")),e=!0}),F=ot(),m=N=!1}},C=function(t){var e=0;if("hide"==t){var a=lt.innerWidth;if(!a){var n=rt.documentElement.getBoundingClientRect();a=n.right-Math.abs(n.left)}if(rt.body.clientWidth").addClass("sl-overlay"),s=ot(""),o=ot("
").addClass("sl-counter").html('/'),m=!1,J=0,v=0,l=ot("
").addClass("sl-caption "+z.captionClass+" pos-"+z.captionPosition),V=ot("
").addClass("sl-image"),r=ot("
").addClass("sl-wrapper").addClass(z.className),c=function(t){t.trigger(ot.Event("show.simplelightbox")),z.disableScroll&&(p=C("hide")),z.htmlClass&&""!=z.htmlClass&&ot("html").addClass(z.htmlClass),r.appendTo("body"),V.appendTo(r),z.overlay&&e.appendTo(ot("body")),m=!0,J=j.index(t),Z=ot("").hide().attr("src",t.attr(z.sourceAttr)).attr("data-scale",1).attr("data-translate-x",0).attr("data-translate-y",0),-1==d.indexOf(t.attr(z.sourceAttr))&&d.push(t.attr(z.sourceAttr)),V.html("").attr("style",""),Z.appendTo(V),b(),e.fadeIn("fast"),ot(".sl-close").fadeIn("fast"),f.show(),G.fadeIn("fast"),ot(".sl-wrapper .sl-counter .sl-current").text(J+1),o.fadeIn("fast"),_(),z.preloading&&y(),setTimeout(function(){t.trigger(ot.Event("shown.simplelightbox"))},z.animationSpeed)},_=function(o){if(Z.length){var l=new Image,r=lt.innerWidth*z.widthRatio,c=lt.innerHeight*z.heightRatio;l.src=Z.attr("src"),Z.data("scale",1),Z.data("translate-x",0),Z.data("translate-y",0),et(0,0,1),ot(l).on("error",function(t){j.eq(J).trigger(ot.Event("error.simplelightbox")),F=!(m=!1),f.hide();var e=1==o||-1==o;v===J&&e?st():(z.alertError&&alert(z.alertErrorMessage),it(e?o:1))}),l.onload=function(){void 0!==o&&j.eq(J).trigger(ot.Event("changed.simplelightbox")).trigger(ot.Event((1===o?"nextDone":"prevDone")+".simplelightbox")),z.history&&(u?h=setTimeout(g,800):g()),-1==d.indexOf(Z.attr("src"))&&d.push(Z.attr("src"));var t=l.width,e=l.height;if(z.scaleImageToRatio||r=j.length-1&&ot(".sl-next").hide(),0").html(z.additionalHtml).addClass("sl-additional-html").appendTo(ot(".sl-image"))}}},x=function(t,e){""!==t&&void 0!==t&&z.captions&&l.html(t).css({width:e+"px"}).hide().appendTo(ot(".sl-image")).delay(z.captionDelay).fadeIn("fast")},tt=function(t,e){var a={};a[i+"transform"]="translateX("+e+")",a[i+"transition"]=i+"transform "+t+"s linear",ot(".sl-image").css(a)},et=function(t,e,a){var n={};n[i+"transform"]="translate("+t+","+e+") scale("+a+")",Z.css(n)},at=function(t,e,a){return t=j.length-1&&0z.swipeTolerance&&e?it(0=j.length-1?0:J+1,e=J-1<0?j.length-1:J-1>=j.length-1?0:J-1;ot("").attr("src",j.eq(t).attr(z.sourceAttr)).on("load",function(){-1==d.indexOf(ot(this).attr("src"))&&d.push(ot(this).attr("src")),j.eq(J).trigger(ot.Event("nextImageLoaded.simplelightbox"))}),ot("").attr("src",j.eq(e).attr(z.sourceAttr)).on("load",function(){-1==d.indexOf(ot(this).attr("src"))&&d.push(ot(this).attr("src")),j.eq(J).trigger(ot.Event("prevImageLoaded.simplelightbox"))})},it=function(e){j.eq(J).trigger(ot.Event("change.simplelightbox")).trigger(ot.Event((1===e?"next":"prev")+".simplelightbox"));var t=J+e;if(!(m||(t<0||t>=j.length)&&!1===z.loop)){J=t<0?j.length-1:t>j.length-1?0:t,ot(".sl-wrapper .sl-counter .sl-current").text(J+1);var a={opacity:0};z.animationSlide&&(K?tt(z.animationSpeed/1e3,-100*e-L+"px"):a.left=parseInt(ot(".sl-image").css("left"))+-100*e+"px"),ot(".sl-image").animate(a,z.animationSpeed,function(){setTimeout(function(){var t=j.eq(J);Z.attr("src",t.attr(z.sourceAttr)),-1==d.indexOf(t.attr(z.sourceAttr))&&f.show(),ot(".sl-caption").remove(),_(e),z.preloading&&y()},100)})}},st=function(){if(!m){var t=j.eq(J),e=!1;t.trigger(ot.Event("close.simplelightbox")),z.history&&(a?history.pushState("",rt.title,n.pathname+n.search):n.hash="",clearTimeout(h)),ot(".sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter").fadeOut("fast",function(){z.disableScroll&&C("show"),z.htmlClass&&""!=z.htmlClass&&ot("html").removeClass(z.htmlClass),ot(".sl-wrapper, .sl-overlay").remove(),G.off("click","button"),ot(rt).off("click."+U,".sl-close"),ot(lt).off("resize."+U),ot(lt).off("hashchange."+U),e||t.trigger(ot.Event("closed.simplelightbox")),e=!0}),Z=ot(),m=F=!1}},C=function(t){var e=0;if("hide"==t){var a=lt.innerWidth;if(!a){var n=rt.documentElement.getBoundingClientRect();a=n.right-Math.abs(n.left)}if(rt.body.clientWidth=1.7.0" + "jquery": ">=1.7.0" }, "keywords": [ "lightbox", @@ -31,5 +31,11 @@ "bugs": { "url": "https://github.com/andreknieriem/simplelightbox/issues" }, - "homepage": "http://simplelightbox.com/" + "homepage": "http://simplelightbox.com/", + "scripts": { + "minify": "uglifyjs dist/simple-lightbox.js --compress --comments '/^\/*!/' --mangle --output dist/simple-lightbox.min.js" + }, + "devDependencies": { + "uglify-js": "^3.4.9" + } }