diff --git a/README.md b/README.md index c89be8c..288ddb3 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,7 @@ $add-vendor-prefixes: true !default; ### Changelog +**1.17.3 - Fixed new chrome passive error #155** **1.17.2 - Fixed caption keeps disappeared on double click #139 and added better close symbol #133** **1.17.1 - Added webp in fileExt list #135, removed hardcoded a-tag in isValidLink function #134** **1.17.0 - Merged pull request #132. Added double click to zoom for desktop browsers - Thanks to coderkan** diff --git a/bower.json b/bower.json index 04e45a1..ecc408d 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "simplelightbox", - "version": "1.17.2", - "homepage": "http://simplelightbox.com/", + "version": "1.17.3", + "homepage": "https://simplelightbox.com/", "authors": [ "André Rinas (https://www.andrerinas.de)" ], diff --git a/dist/simple-lightbox.js b/dist/simple-lightbox.js index 36aec74..ad21e7f 100644 --- a/dist/simple-lightbox.js +++ b/dist/simple-lightbox.js @@ -2,7 +2,7 @@ By André Rinas, www.andrerinas.de Documentation, www.simplelightbox.de Available for use under the MIT License - 1.17.2 + 1.17.3 */ ;( function( $, window, document, undefined ) { @@ -346,7 +346,7 @@ $.fn.simpleLightbox = function( options ) $( window ).on( 'resize.'+prefix, adjustImage ); // close lightbox on close btn - $( document ).on('click.'+prefix+ ' touchstart.'+prefix, '.sl-close', function(e){ + $( '.sl-wrapper' ).on('click.'+prefix+ ' touchstart.'+prefix, '.sl-close', function(e){ e.preventDefault(); if(opened){ close();} }); @@ -672,7 +672,7 @@ $.fn.simpleLightbox = function( options ) }, removeEvents = function(){ nav.off('click', 'button'); - $( document ).off('click.'+prefix, '.sl-close'); + $( '.sl-wrapper' ).off('click.'+prefix, '.sl-close'); $( window ).off( 'resize.'+prefix); $( window ).off( 'hashchange.'+prefix); }, diff --git a/dist/simple-lightbox.min.js b/dist/simple-lightbox.min.js index 6302b42..090cb8e 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.17.2 + 1.17.3 */ -!function(ot,st,lt){"use strict";ot.fn.simpleLightbox=function(N){N=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|webp",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"},N);function P(){return s.hash.substring(1)}function h(){P();var t="pid="+(V+1),e=s.href.split("#")[0]+"#"+t;o?history[f?"replaceState":"pushState"]("",lt.title,e):f?s.replace(e):s.hash=t,f=!0}function t(e,a){var n;return function(){var t=arguments;n||(e.apply(this,t),n=!0,setTimeout(function(){return n=!1},a))}}function a(t){t.trigger(ot.Event("show.simplelightbox")),N.disableScroll&&(u=T("hide")),N.htmlClass&&""!=N.htmlClass&&ot("html").addClass(N.htmlClass),b.appendTo("body"),_.appendTo(b),N.overlay&&l.appendTo(ot("body")),m=!0,V=$.index(t),K=ot("").hide().attr("src",t.attr(N.sourceAttr)).attr("data-scale",1).attr("data-translate-x",0).attr("data-translate-y",0),-1==d.indexOf(t.attr(N.sourceAttr))&&d.push(t.attr(N.sourceAttr)),_.html("").attr("style",""),K.appendTo(_),C(),l.fadeIn("fast"),ot(".sl-close").fadeIn("fast"),g.show(),J.fadeIn("fast"),ot(".sl-wrapper .sl-counter .sl-current").text(V+1),c.fadeIn("fast"),tt(),N.preloading&&w(),setTimeout(function(){t.trigger(ot.Event("shown.simplelightbox"))},N.animationSpeed)}function Z(t,e,a){return t").addClass("sl-overlay"),r=ot(""),c=ot("
").addClass("sl-counter").html('/'),m=!1,V=0,v=0,x=ot("
").addClass("sl-caption "+N.captionClass+" pos-"+N.captionPosition),_=ot("
").addClass("sl-image"),b=ot("
").addClass("sl-wrapper").addClass(N.className),tt=function(s){if(K.length){var l=new Image,r=st.innerWidth*N.widthRatio,c=st.innerHeight*N.heightRatio;l.src=K.attr("src"),K.data("scale",1),K.data("translate-x",0),K.data("translate-y",0),at(0,0,1),ot(l).on("error",function(t){$.eq(V).trigger(ot.Event("error.simplelightbox")),U=!(m=!1),g.hide();var e=1==s||-1==s;v===V&&e?it():(N.alertError&&alert(N.alertErrorMessage),nt(e?s:1))}),l.onload=function(){void 0!==s&&$.eq(V).trigger(ot.Event("changed.simplelightbox")).trigger(ot.Event((1===s?"nextDone":"prevDone")+".simplelightbox")),N.history&&(f?p=setTimeout(h,800):h()),-1==d.indexOf(K.attr("src"))&&d.push(K.attr("src"));var t=l.width,e=l.height;if(N.scaleImageToRatio||r=$.length-1&&ot(".sl-next").hide(),0").html(N.additionalHtml).addClass("sl-additional-html").appendTo(ot(".sl-image"))}}},y=function(t,e){""!==t&&void 0!==t&&N.captions&&x.html(t).css({width:e+"px"}).hide().appendTo(ot(".sl-image")).delay(N.captionDelay).fadeIn("fast")},et=function(t,e){var a={};a[i+"transform"]="translateX("+e+")",a[i+"transition"]=i+"transform "+t+"s linear",ot(".sl-image").css(a)},at=function(t,e,a){var n={};n[i+"transform"]="translate("+t+","+e+") scale("+a+")",K.css(n)},C=function(){ot(st).on("resize."+G,tt),ot(lt).on("click."+G+" touchstart."+G,".sl-close",function(t){t.preventDefault(),U&&it()}),N.history&&setTimeout(function(){ot(st).on("hashchange."+G,function(){U&&P()===Q&&it()})},40),J.on("click."+G,"button",t(function(t){t.preventDefault(),L=0,nt(ot(this).hasClass("sl-next")?1:-1)},N.throttleInterval));var e,a,n,i,o,s,l,r,c,h,p,d,u,f,g,m,v,x,b,y,C,w,T,E,S,M,I,k=0,q=0,X=0,D=0,Y=!1,A=!1,O=0,R=!1,W=Z(1,1,N.maxZoom),F=!1;_.on("touchstart."+G+" mousedown."+G,function(t){if("A"===t.target.tagName&&"touchstart"==t.type)return!0;if("mousedown"==(t=t.originalEvent).type)c=t.clientX,h=t.clientY,e=_.height(),a=_.width(),o=K.height(),s=K.width(),n=_.position().left,i=_.position().top,l=parseFloat(K.data("translate-x")),r=parseFloat(K.data("translate-y")),R=!0;else{if(I=t.touches.length,c=t.touches[0].clientX,h=t.touches[0].clientY,e=_.height(),a=_.width(),o=K.height(),s=K.width(),n=_.position().left,i=_.position().top,1===I){if(F)return K.addClass("sl-transition"),Y=Y?(z(0,0,W=1),at("0px","0px",W),!1):(W=N.doubleTapZoom,z(0,0,W),at("0px","0px",W),ot(".sl-caption").fadeOut(200),!0),setTimeout(function(){K.removeClass("sl-transition")},200),!1;F=!0,setTimeout(function(){F=!1},300),l=parseFloat(K.data("translate-x")),r=parseFloat(K.data("translate-y"))}else 2===I&&(p=t.touches[1].clientX,d=t.touches[1].clientY,l=parseFloat(K.data("translate-x")),r=parseFloat(K.data("translate-y")),C=(c+p)/2,w=(h+d)/2,u=Math.sqrt((c-p)*(c-p)+(h-d)*(h-d)));R=!0}return!!A||(B&&(O=parseInt(_.css("left"))),A=!0,j=L=0,k=t.pageX||t.touches[0].pageX,X=t.pageY||t.touches[0].pageY,!1)}).on("touchmove."+G+" mousemove."+G+" MSPointerMove",function(t){if(!A)return!0;if(t.preventDefault(),"touchmove"==(t=t.originalEvent).type){if(!1===R)return!1;f=t.touches[0].clientX,g=t.touches[0].clientY,I=t.touches.length,0,1=$.length-1&&0N.swipeTolerance&&e?nt(0=$.length-1?0:V+1,e=V-1<0?$.length-1:V-1>=$.length-1?0:V-1;ot("").attr("src",$.eq(t).attr(N.sourceAttr)).on("load",function(){-1==d.indexOf(ot(this).attr("src"))&&d.push(ot(this).attr("src")),$.eq(V).trigger(ot.Event("nextImageLoaded.simplelightbox"))}),ot("").attr("src",$.eq(e).attr(N.sourceAttr)).on("load",function(){-1==d.indexOf(ot(this).attr("src"))&&d.push(ot(this).attr("src")),$.eq(V).trigger(ot.Event("prevImageLoaded.simplelightbox"))})},nt=function(e){$.eq(V).trigger(ot.Event("change.simplelightbox")).trigger(ot.Event((1===e?"next":"prev")+".simplelightbox"));var t=V+e;if(!(m||(t<0||t>=$.length)&&!1===N.loop)){V=t<0?$.length-1:t>$.length-1?0:t,ot(".sl-wrapper .sl-counter .sl-current").text(V+1);var a={opacity:0};N.animationSlide&&(B?et(N.animationSpeed/1e3,-100*e-L+"px"):a.left=parseInt(ot(".sl-image").css("left"))+-100*e+"px"),ot(".sl-image").animate(a,N.animationSpeed,function(){setTimeout(function(){var t=$.eq(V);K.attr("src",t.attr(N.sourceAttr)),-1==d.indexOf(t.attr(N.sourceAttr))&&g.show(),ot(".sl-caption").remove(),tt(e),N.preloading&&w()},100)})}},it=function(){if(!m){var t=$.eq(V),e=!1;t.trigger(ot.Event("close.simplelightbox")),N.history&&(o?history.pushState("",lt.title,s.pathname+s.search):s.hash="",clearTimeout(p)),ot(".sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter").fadeOut("fast",function(){N.disableScroll&&T("show"),N.htmlClass&&""!=N.htmlClass&&ot("html").removeClass(N.htmlClass),ot(".sl-wrapper, .sl-overlay").remove(),J.off("click","button"),ot(lt).off("click."+G,".sl-close"),ot(st).off("resize."+G),ot(st).off("hashchange."+G),e||t.trigger(ot.Event("closed.simplelightbox")),e=!0}),K=ot(),m=U=!1}},T=function(t){var e=0;if("hide"==t){var a=st.innerWidth;if(!a){var n=lt.documentElement.getBoundingClientRect();a=n.right-Math.abs(n.left)}if(lt.body.clientWidth").hide().attr("src",t.attr(N.sourceAttr)).attr("data-scale",1).attr("data-translate-x",0).attr("data-translate-y",0),-1==d.indexOf(t.attr(N.sourceAttr))&&d.push(t.attr(N.sourceAttr)),_.html("").attr("style",""),K.appendTo(_),C(),l.fadeIn("fast"),st(".sl-close").fadeIn("fast"),g.show(),J.fadeIn("fast"),st(".sl-wrapper .sl-counter .sl-current").text(V+1),c.fadeIn("fast"),tt(),N.preloading&&w(),setTimeout(function(){t.trigger(st.Event("shown.simplelightbox"))},N.animationSpeed)}function Z(t,e,a){return t").addClass("sl-overlay"),r=st(""),c=st("
").addClass("sl-counter").html('/'),m=!1,V=0,v=0,x=st("
").addClass("sl-caption "+N.captionClass+" pos-"+N.captionPosition),_=st("
").addClass("sl-image"),b=st("
").addClass("sl-wrapper").addClass(N.className),tt=function(o){if(K.length){var l=new Image,r=ot.innerWidth*N.widthRatio,c=ot.innerHeight*N.heightRatio;l.src=K.attr("src"),K.data("scale",1),K.data("translate-x",0),K.data("translate-y",0),at(0,0,1),st(l).on("error",function(t){$.eq(V).trigger(st.Event("error.simplelightbox")),U=!(m=!1),g.hide();var e=1==o||-1==o;v===V&&e?it():(N.alertError&&alert(N.alertErrorMessage),nt(e?o:1))}),l.onload=function(){void 0!==o&&$.eq(V).trigger(st.Event("changed.simplelightbox")).trigger(st.Event((1===o?"nextDone":"prevDone")+".simplelightbox")),N.history&&(f?h=setTimeout(p,800):p()),-1==d.indexOf(K.attr("src"))&&d.push(K.attr("src"));var t=l.width,e=l.height;if(N.scaleImageToRatio||r=$.length-1&&st(".sl-next").hide(),0").html(N.additionalHtml).addClass("sl-additional-html").appendTo(st(".sl-image"))}}},y=function(t,e){""!==t&&void 0!==t&&N.captions&&x.html(t).css({width:e+"px"}).hide().appendTo(st(".sl-image")).delay(N.captionDelay).fadeIn("fast")},et=function(t,e){var a={};a[i+"transform"]="translateX("+e+")",a[i+"transition"]=i+"transform "+t+"s linear",st(".sl-image").css(a)},at=function(t,e,a){var n={};n[i+"transform"]="translate("+t+","+e+") scale("+a+")",K.css(n)},C=function(){st(ot).on("resize."+G,tt),st(".sl-wrapper").on("click."+G+" touchstart."+G,".sl-close",function(t){t.preventDefault(),U&&it()}),N.history&&setTimeout(function(){st(ot).on("hashchange."+G,function(){U&&P()===Q&&it()})},40),J.on("click."+G,"button",t(function(t){t.preventDefault(),L=0,nt(st(this).hasClass("sl-next")?1:-1)},N.throttleInterval));var e,a,n,i,s,o,l,r,c,p,h,d,u,f,g,m,v,x,b,y,C,w,T,E,S,M,I,k=0,q=0,X=0,D=0,Y=!1,A=!1,O=0,R=!1,W=Z(1,1,N.maxZoom),F=!1;_.on("touchstart."+G+" mousedown."+G,function(t){if("A"===t.target.tagName&&"touchstart"==t.type)return!0;if("mousedown"==(t=t.originalEvent).type)c=t.clientX,p=t.clientY,e=_.height(),a=_.width(),s=K.height(),o=K.width(),n=_.position().left,i=_.position().top,l=parseFloat(K.data("translate-x")),r=parseFloat(K.data("translate-y")),R=!0;else{if(I=t.touches.length,c=t.touches[0].clientX,p=t.touches[0].clientY,e=_.height(),a=_.width(),s=K.height(),o=K.width(),n=_.position().left,i=_.position().top,1===I){if(F)return K.addClass("sl-transition"),Y=Y?(z(0,0,W=1),at("0px","0px",W),!1):(W=N.doubleTapZoom,z(0,0,W),at("0px","0px",W),st(".sl-caption").fadeOut(200),!0),setTimeout(function(){K.removeClass("sl-transition")},200),!1;F=!0,setTimeout(function(){F=!1},300),l=parseFloat(K.data("translate-x")),r=parseFloat(K.data("translate-y"))}else 2===I&&(h=t.touches[1].clientX,d=t.touches[1].clientY,l=parseFloat(K.data("translate-x")),r=parseFloat(K.data("translate-y")),C=(c+h)/2,w=(p+d)/2,u=Math.sqrt((c-h)*(c-h)+(p-d)*(p-d)));R=!0}return!!A||(B&&(O=parseInt(_.css("left"))),A=!0,j=L=0,k=t.pageX||t.touches[0].pageX,X=t.pageY||t.touches[0].pageY,!1)}).on("touchmove."+G+" mousemove."+G+" MSPointerMove",function(t){if(!A)return!0;if(t.preventDefault(),"touchmove"==(t=t.originalEvent).type){if(!1===R)return!1;f=t.touches[0].clientX,g=t.touches[0].clientY,I=t.touches.length,0,1=$.length-1&&0N.swipeTolerance&&e?nt(0=$.length-1?0:V+1,e=V-1<0?$.length-1:V-1>=$.length-1?0:V-1;st("").attr("src",$.eq(t).attr(N.sourceAttr)).on("load",function(){-1==d.indexOf(st(this).attr("src"))&&d.push(st(this).attr("src")),$.eq(V).trigger(st.Event("nextImageLoaded.simplelightbox"))}),st("").attr("src",$.eq(e).attr(N.sourceAttr)).on("load",function(){-1==d.indexOf(st(this).attr("src"))&&d.push(st(this).attr("src")),$.eq(V).trigger(st.Event("prevImageLoaded.simplelightbox"))})},nt=function(e){$.eq(V).trigger(st.Event("change.simplelightbox")).trigger(st.Event((1===e?"next":"prev")+".simplelightbox"));var t=V+e;if(!(m||(t<0||t>=$.length)&&!1===N.loop)){V=t<0?$.length-1:t>$.length-1?0:t,st(".sl-wrapper .sl-counter .sl-current").text(V+1);var a={opacity:0};N.animationSlide&&(B?et(N.animationSpeed/1e3,-100*e-L+"px"):a.left=parseInt(st(".sl-image").css("left"))+-100*e+"px"),st(".sl-image").animate(a,N.animationSpeed,function(){setTimeout(function(){var t=$.eq(V);K.attr("src",t.attr(N.sourceAttr)),-1==d.indexOf(t.attr(N.sourceAttr))&&g.show(),st(".sl-caption").remove(),tt(e),N.preloading&&w()},100)})}},it=function(){if(!m){var t=$.eq(V),e=!1;t.trigger(st.Event("close.simplelightbox")),N.history&&(s?history.pushState("",E.title,o.pathname+o.search):o.hash="",clearTimeout(h)),st(".sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter").fadeOut("fast",function(){N.disableScroll&&T("show"),N.htmlClass&&""!=N.htmlClass&&st("html").removeClass(N.htmlClass),st(".sl-wrapper, .sl-overlay").remove(),J.off("click","button"),st(".sl-wrapper").off("click."+G,".sl-close"),st(ot).off("resize."+G),st(ot).off("hashchange."+G),e||t.trigger(st.Event("closed.simplelightbox")),e=!0}),K=st(),m=U=!1}},T=function(t){var e=0;if("hide"==t){var a=ot.innerWidth;if(!a){var n=E.documentElement.getBoundingClientRect();a=n.right-Math.abs(n.left)}if(E.body.clientWidth