diff --git a/abigimage.jquery.js b/abigimage.jquery.js index 0b53b65..612ea96 100644 --- a/abigimage.jquery.js +++ b/abigimage.jquery.js @@ -1,6 +1,6 @@ /** * http://aeqdev.com/tools/js/abigimage/ - * v 1.2.6 + * v 1.2.7 * * Copyright © 2014 Maksim Krylosov * @@ -200,6 +200,7 @@ } img[0].addEventListener('touchstart', function(e) { + if (!opened) return; if (e.touches.length > 1) { k = dis(e); img.css({zIndex: opts.prevBtnBoxCSS.zIndex}); @@ -222,6 +223,7 @@ }); img[0].addEventListener('touchmove', function(e) { + if (!opened) return; dx = (med(e.touches, 'X') - med(touches, 'X')); dy = (med(e.touches, 'Y') - med(touches, 'Y')); x = sx + dx / s; @@ -255,6 +257,7 @@ img[0].addEventListener('touchcancel', touchend); function touchend(e) { + if (!opened) return; var time = (new Date()).getTime() - start; if (!e.touches.length) { diff --git a/abigimage.jquery.json b/abigimage.jquery.json index c66282c..a8f554f 100644 --- a/abigimage.jquery.json +++ b/abigimage.jquery.json @@ -1,6 +1,6 @@ { "name": "abigimage", - "version": "1.2.6", + "version": "1.2.7", "title": "ABigImage - view big versions of images", "author": { "name": "Maksim Krylosov", diff --git a/abigimage.jquery.min.js b/abigimage.jquery.min.js index 21a56b4..0951f3f 100644 --- a/abigimage.jquery.min.js +++ b/abigimage.jquery.min.js @@ -1 +1 @@ -(function(R){var aj=R("
").css({display:"none"}).appendTo("body"),P=R("
").css({display:"none"}).appendTo("body"),n=R("
").appendTo(P),U=R("
").appendTo(n),F=R("
").appendTo(U),v=R("
").appendTo(F),B=R("
").appendTo(n),M=R("
").appendTo(B),V=R("
").appendTo(M),p=R("").appendTo(n),z=R("").appendTo(n),ab=R("").appendTo(n),b=R("
").appendTo(P);var N={},ac=null,ai=null,al=0,D=false;function ag(){var d=ai+1;if(d>=ac.length){d=0}return d}function o(){var d=ai-1;if(d<0){d=ac.length-1}return d}function f(){if(al===ac.length-1){return ae()}else{++al;return K(ag())}}function O(){if(al===1-ac.length){return ae()}else{--al;return K(o())}}function G(d){if(N.keyNext.indexOf(d.which)!==-1){f();return false}else{if(N.keyPrev.indexOf(d.which)!==-1){O();return false}else{if(N.keyClose.indexOf(d.which)!==-1){ae();return false}}}}function K(k,d){if("number"===typeof k){if(k===ai||k<0||k>ac.length-1){return}ai=k;var t=R(ac[ai]);k=t.data("href")||t.attr("href")}else{if("number"!==typeof d){d=-1}if(ai===d){return}ai=d}D=true;p.removeAttr("src").attr("src",k);var s=R(ac[ag()]);z.removeAttr("src").attr("src",s.data("href")||s.attr("href"));var i=R(ac[o()]);ab.removeAttr("src").attr("src",i.data("href")||i.attr("href"));aj.fadeIn(N.fadeIn);P.fadeIn(N.fadeIn);N.onopen.call(ac,ac[ai],ai);R(document).unbind("keydown",G).bind("keydown",G);return false}function ae(){if(!D){return}D=false;ai=null;al=0;aj.fadeOut(N.fadeOut);P.fadeOut(N.fadeOut,I);N.onclose.call(ac);R(document).unbind("keydown",G);return false}U.click(function(){return O()});B.click(function(){return ae()});var h=function(d){d.preventDefault()};P.on("touchmove",h).on("wheel",h);var r,q,w,aa,Z,ad,ah,l,g,J,T,L,a,e,am,C,ao,A=false,X=[null,null,null],af=n[0].style;an();function an(){aa=0;Z=0;ad=1;C=null;if(N.imgCSS){p.css({zIndex:N.imgCSS.zIndex})}}function E(k,x){var s=0;for(var i=0,d=k.length;i1){ah=ak(d);p.css({zIndex:N.prevBtnBoxCSS.zIndex})}else{C=null;L=(new Date()).getTime();a=n.width()*0.34;e=n.height();am=N.slideWidth*a;J=p.width();T=p.height()}r=aa;q=Z;w=ad;l=0;g=0;ao=d.touches;d.preventDefault()});p[0].addEventListener("touchmove",function(k){l=(E(k.touches,"X")-E(ao,"X"));g=(E(k.touches,"Y")-E(ao,"Y"));aa=r+l/ad;Z=q+g/ad;if(k.touches.length>1){ad=Math.max(1,w*(ak(k)/ah))}if(ad>N.zoomMin){var s=0.5*(J-(J/ad));var i=0.5*(T-(T/ad));aa=Math.max(-s,Math.min(s,aa));Z=Math.max(-i,Math.min(i,Z))}else{if(null===C){var d=Math.abs(g)-Math.abs(l);if(Math.abs(d)>2){C=d>0}}if(C){aa=0}else{Z=0}}S(aa,Z,ad,false);k.preventDefault()});p[0].addEventListener("touchend",W);p[0].addEventListener("touchcancel",W);function W(i){var d=(new Date()).getTime()-L;if(!i.touches.length){if(ad<=N.zoomMin){if(l>=-1&&l<=1&&g>=-1&&g<=1){Q(true)}else{if(C){var k=Math.abs(g);if(k>am){c()}else{if(k/d>N.slideVelocity){c()}else{j()}}}else{if(l<-am){Q()}else{if(l>am){m()}else{if(Math.abs(l)/d>N.slideVelocity){if(l<0){Q()}else{m()}}else{j()}}}}}an()}else{if(ad>N.zoomMax){ad=N.zoomMax;S(aa,Z,ad,true)}}}if(ad<=N.zoomMin){p.css({zIndex:N.imgCSS.zIndex})}ao=i.touches;i.preventDefault()}n.on("transitionend webkitTransitionEnd msTransitionEnd oTransitionEnd",I);function I(){A=false;for(var d=0;d<2;d++){if(X[d]){X[d]();X[d]=null;if(A){break}}}}p.click(function(){return f()});function Q(d){S(d?0:-a,0,1,!d);Y(f)}function m(){S(a,0,1,true);Y(O)}function j(){S(0,0,1,true)}function c(){j();Y();ae()}function H(k,d){if(A){X[d||0]=k}else{k()}}function S(d,aq,t,ap,k){H(function(){u(d,aq,t,ap)},k)}function Y(d){H(function(){u(0,0,1,false);if(d){d()}},1)}function u(d,ap,k,t){A=t;var i="scale("+k+") translate3d("+d+"px, "+ap+"px, 0)";af.transition=t?"all .2s ease-out":"";af.webkitTransform=i;af.mozTransform=i;af.msTransform=i;af.oTransform=i;af.transform=i}R.fn.abigimage=function(s){ac=this;N=R.extend(true,R.fn.abigimage.defaults,s);this.overlay=aj.attr(N.overlayAttrs).css(N.overlayCSS);this.layout=P.attr(N.layoutAttrs).css(N.layoutCSS);this.box=n.attr(N.boxAttrs).css(N.boxCSS);this.prevBtnWrapper=U.attr(N.prevBtnWrapperAttrs).css(N.prevBtnWrapperCSS);this.prevBtnBox=F.attr(N.prevBtnBoxAttrs).css(N.prevBtnBoxCSS);this.prevBtn=v.attr(N.prevBtnAttrs).css(N.prevBtnCSS).html(N.prevBtnHtml);this.closeBtnWrapper=B.attr(N.closeBtnWrapperAttrs).css(N.closeBtnWrapperCSS);this.closeBtnBox=M.attr(N.closeBtnBoxAttrs).css(N.closeBtnBoxCSS);this.closeBtn=V.attr(N.closeBtnAttrs).css(N.closeBtnCSS).html(N.closeBtnHtml);this.img=p.attr(N.imgAttrs).css(N.imgCSS);this.imgNext=z.attr(N.imgNextAttrs).css(N.imgNextCSS);this.imgPrev=ab.attr(N.imgPrevAttrs).css(N.imgPrevCSS);this.bottom=b.attr(N.bottomAttrs).css(N.bottomCSS);var k={};for(var t in N.prevBtnHoverCSS){if(N.prevBtnCSS){k[t]=N.prevBtnCSS[t]}}var d={};for(var t in N.closeBtnHoverCSS){if(N.closeBtnCSS){d[t]=N.closeBtnCSS[t]}}var i={};for(var t in N.bottomHoverCSS){if(N.bottomCSS){i[t]=N.bottomCSS[t]}}this.prevBtnWrapper.hover(function(){v.stop().animate(N.prevBtnHoverCSS,N.fadeIn)},function(){v.stop().animate(k,N.fadeOut)});this.closeBtnWrapper.hover(function(){V.stop().animate(N.closeBtnHoverCSS,N.fadeIn)},function(){V.stop().animate(d,N.fadeOut)});this.bottom.hover(function(){b.stop().animate(N.bottomHoverCSS,N.fadeIn)},function(){b.stop().animate(i,N.fadeOut)});return this.each(function(x){R(this).unbind("click.abigimage").bind("click.abigimage",function(){return K(x)})})};R.abigimage={open:K,next:f,prev:O,close:ae};R.fn.abigimage.defaults={fadeIn:"fast",fadeOut:"fast",slideWidth:0.4,slideVelocity:0.4,zoomMin:1.5,zoomMax:5,prevBtnHtml:"←",closeBtnHtml:"x",keyNext:[13,32,39,40],keyPrev:[8,37,38],keyClose:[27,35,36],onopen:function(){},onclose:function(){},overlayCSS:{position:"fixed",zIndex:101,top:0,right:0,bottom:0,left:0,backgroundColor:"#000",opacity:0.9},layoutCSS:{position:"fixed",zIndex:101,top:0,right:0,bottom:0,left:0,"-webkit-user-select":"none","-moz-user-select":"none","user-select":"none","-webkit-tap-highlight-color":"rgba(0, 0, 0, 0)",lineHeight:2.5},boxCSS:{position:"absolute",width:"312.5%",height:"100%",left:"-106.25%",top:0},prevBtnWrapperCSS:{cursor:"pointer",position:"absolute",top:0,right:"50%",bottom:0,left:0},closeBtnWrapperCSS:{cursor:"pointer",position:"absolute",top:0,right:0,bottom:0,left:"50%"},prevBtnBoxCSS:{position:"absolute",zIndex:103,top:0,bottom:0,left:"68%"},closeBtnBoxCSS:{position:"absolute",zIndex:103,top:0,bottom:0,right:"68%"},prevBtnCSS:{color:"#fff",backgroundColor:"#000",opacity:0.5,padding:"0 1em",borderRadius:"0 0 1ex 0"},closeBtnCSS:{color:"#fff",backgroundColor:"#000",opacity:0.5,padding:"0 1em",borderRadius:"0 0 0 1ex"},prevBtnHoverCSS:{opacity:1},closeBtnHoverCSS:{opacity:1},imgCSS:{position:"absolute",zIndex:102,margin:"auto",width:"auto",top:0,right:0,bottom:0,left:0,display:"block",cursor:"pointer",maxWidth:"32%",maxHeight:"100%"},imgNextCSS:{position:"absolute",margin:"auto",width:"auto",top:0,right:0,bottom:0,left:"68%",display:"block",maxWidth:"32%",maxHeight:"100%"},imgPrevCSS:{position:"absolute",margin:"auto",width:"auto",top:0,right:"68%",bottom:0,left:0,display:"block",maxWidth:"32%",maxHeight:"100%"},bottomCSS:{position:"fixed",zIndex:104,right:0,bottom:0,left:0,"-webkit-user-select":"text","-moz-user-select":"text","user-select":"text",backgroundColor:"#000",color:"#fff",opacity:0.5,padding:"0 1em",textAlign:"center"},bottomHoverCSS:{opacity:1},overlayAttrs:{},layoutAttrs:{},boxAttrs:{},prevBtnWrapperAttrs:{},prevBtnBoxAttrs:{},prevBtnAttrs:{},closeBtnWrapperAttrs:{},closeBtnBoxAttrs:{},closeBtnAttrs:{},imgAttrs:{},imgNextAttrs:{},imgPrevAttrs:{},bottomAttrs:{}}}(jQuery)); \ No newline at end of file +(function(R){var aj=R("
").css({display:"none"}).appendTo("body"),P=R("
").css({display:"none"}).appendTo("body"),n=R("
").appendTo(P),U=R("
").appendTo(n),F=R("
").appendTo(U),v=R("
").appendTo(F),B=R("
").appendTo(n),M=R("
").appendTo(B),V=R("
").appendTo(M),p=R("").appendTo(n),z=R("").appendTo(n),ab=R("").appendTo(n),b=R("
").appendTo(P);var N={},ac=null,ai=null,al=0,D=false;function ag(){var d=ai+1;if(d>=ac.length){d=0}return d}function o(){var d=ai-1;if(d<0){d=ac.length-1}return d}function f(){if(al===ac.length-1){return ae()}else{++al;return K(ag())}}function O(){if(al===1-ac.length){return ae()}else{--al;return K(o())}}function G(d){if(N.keyNext.indexOf(d.which)!==-1){f();return false}else{if(N.keyPrev.indexOf(d.which)!==-1){O();return false}else{if(N.keyClose.indexOf(d.which)!==-1){ae();return false}}}}function K(k,d){if("number"===typeof k){if(k===ai||k<0||k>ac.length-1){return}ai=k;var t=R(ac[ai]);k=t.data("href")||t.attr("href")}else{if("number"!==typeof d){d=-1}if(ai===d){return}ai=d}D=true;p.removeAttr("src").attr("src",k);var s=R(ac[ag()]);z.removeAttr("src").attr("src",s.data("href")||s.attr("href"));var i=R(ac[o()]);ab.removeAttr("src").attr("src",i.data("href")||i.attr("href"));aj.fadeIn(N.fadeIn);P.fadeIn(N.fadeIn);N.onopen.call(ac,ac[ai],ai);R(document).unbind("keydown",G).bind("keydown",G);return false}function ae(){if(!D){return}D=false;ai=null;al=0;aj.fadeOut(N.fadeOut);P.fadeOut(N.fadeOut,I);N.onclose.call(ac);R(document).unbind("keydown",G);return false}U.click(function(){return O()});B.click(function(){return ae()});var h=function(d){d.preventDefault()};P.on("touchmove",h).on("wheel",h);var r,q,w,aa,Z,ad,ah,l,g,J,T,L,a,e,am,C,ao,A=false,X=[null,null,null],af=n[0].style;an();function an(){aa=0;Z=0;ad=1;C=null;if(N.imgCSS){p.css({zIndex:N.imgCSS.zIndex})}}function E(k,x){var s=0;for(var i=0,d=k.length;i1){ah=ak(d);p.css({zIndex:N.prevBtnBoxCSS.zIndex})}else{C=null;L=(new Date()).getTime();a=n.width()*0.34;e=n.height();am=N.slideWidth*a;J=p.width();T=p.height()}r=aa;q=Z;w=ad;l=0;g=0;ao=d.touches;d.preventDefault()});p[0].addEventListener("touchmove",function(k){if(!D){return}l=(E(k.touches,"X")-E(ao,"X"));g=(E(k.touches,"Y")-E(ao,"Y"));aa=r+l/ad;Z=q+g/ad;if(k.touches.length>1){ad=Math.max(1,w*(ak(k)/ah))}if(ad>N.zoomMin){var s=0.5*(J-(J/ad));var i=0.5*(T-(T/ad));aa=Math.max(-s,Math.min(s,aa));Z=Math.max(-i,Math.min(i,Z))}else{if(null===C){var d=Math.abs(g)-Math.abs(l);if(Math.abs(d)>2){C=d>0}}if(C){aa=0}else{Z=0}}S(aa,Z,ad,false);k.preventDefault()});p[0].addEventListener("touchend",W);p[0].addEventListener("touchcancel",W);function W(i){if(!D){return}var d=(new Date()).getTime()-L;if(!i.touches.length){if(ad<=N.zoomMin){if(l>=-1&&l<=1&&g>=-1&&g<=1){Q(true)}else{if(C){var k=Math.abs(g);if(k>am){c()}else{if(k/d>N.slideVelocity){c()}else{j()}}}else{if(l<-am){Q()}else{if(l>am){m()}else{if(Math.abs(l)/d>N.slideVelocity){if(l<0){Q()}else{m()}}else{j()}}}}}an()}else{if(ad>N.zoomMax){ad=N.zoomMax;S(aa,Z,ad,true)}}}if(ad<=N.zoomMin){p.css({zIndex:N.imgCSS.zIndex})}ao=i.touches;i.preventDefault()}n.on("transitionend webkitTransitionEnd msTransitionEnd oTransitionEnd",I);function I(){A=false;for(var d=0;d<2;d++){if(X[d]){X[d]();X[d]=null;if(A){break}}}}p.click(function(){return f()});function Q(d){S(d?0:-a,0,1,!d);Y(f)}function m(){S(a,0,1,true);Y(O)}function j(){S(0,0,1,true)}function c(){j();Y();ae()}function H(k,d){if(A){X[d||0]=k}else{k()}}function S(d,aq,t,ap,k){H(function(){u(d,aq,t,ap)},k)}function Y(d){H(function(){u(0,0,1,false);if(d){d()}},1)}function u(d,ap,k,t){A=t;var i="scale("+k+") translate3d("+d+"px, "+ap+"px, 0)";af.transition=t?"all .2s ease-out":"";af.webkitTransform=i;af.mozTransform=i;af.msTransform=i;af.oTransform=i;af.transform=i}R.fn.abigimage=function(s){ac=this;N=R.extend(true,R.fn.abigimage.defaults,s);this.overlay=aj.attr(N.overlayAttrs).css(N.overlayCSS);this.layout=P.attr(N.layoutAttrs).css(N.layoutCSS);this.box=n.attr(N.boxAttrs).css(N.boxCSS);this.prevBtnWrapper=U.attr(N.prevBtnWrapperAttrs).css(N.prevBtnWrapperCSS);this.prevBtnBox=F.attr(N.prevBtnBoxAttrs).css(N.prevBtnBoxCSS);this.prevBtn=v.attr(N.prevBtnAttrs).css(N.prevBtnCSS).html(N.prevBtnHtml);this.closeBtnWrapper=B.attr(N.closeBtnWrapperAttrs).css(N.closeBtnWrapperCSS);this.closeBtnBox=M.attr(N.closeBtnBoxAttrs).css(N.closeBtnBoxCSS);this.closeBtn=V.attr(N.closeBtnAttrs).css(N.closeBtnCSS).html(N.closeBtnHtml);this.img=p.attr(N.imgAttrs).css(N.imgCSS);this.imgNext=z.attr(N.imgNextAttrs).css(N.imgNextCSS);this.imgPrev=ab.attr(N.imgPrevAttrs).css(N.imgPrevCSS);this.bottom=b.attr(N.bottomAttrs).css(N.bottomCSS);var k={};for(var t in N.prevBtnHoverCSS){if(N.prevBtnCSS){k[t]=N.prevBtnCSS[t]}}var d={};for(var t in N.closeBtnHoverCSS){if(N.closeBtnCSS){d[t]=N.closeBtnCSS[t]}}var i={};for(var t in N.bottomHoverCSS){if(N.bottomCSS){i[t]=N.bottomCSS[t]}}this.prevBtnWrapper.hover(function(){v.stop().animate(N.prevBtnHoverCSS,N.fadeIn)},function(){v.stop().animate(k,N.fadeOut)});this.closeBtnWrapper.hover(function(){V.stop().animate(N.closeBtnHoverCSS,N.fadeIn)},function(){V.stop().animate(d,N.fadeOut)});this.bottom.hover(function(){b.stop().animate(N.bottomHoverCSS,N.fadeIn)},function(){b.stop().animate(i,N.fadeOut)});return this.each(function(x){R(this).unbind("click.abigimage").bind("click.abigimage",function(){return K(x)})})};R.abigimage={open:K,next:f,prev:O,close:ae};R.fn.abigimage.defaults={fadeIn:"fast",fadeOut:"fast",slideWidth:0.4,slideVelocity:0.4,zoomMin:1.5,zoomMax:5,prevBtnHtml:"←",closeBtnHtml:"x",keyNext:[13,32,39,40],keyPrev:[8,37,38],keyClose:[27,35,36],onopen:function(){},onclose:function(){},overlayCSS:{position:"fixed",zIndex:101,top:0,right:0,bottom:0,left:0,backgroundColor:"#000",opacity:0.9},layoutCSS:{position:"fixed",zIndex:101,top:0,right:0,bottom:0,left:0,"-webkit-user-select":"none","-moz-user-select":"none","user-select":"none","-webkit-tap-highlight-color":"rgba(0, 0, 0, 0)",lineHeight:2.5},boxCSS:{position:"absolute",width:"312.5%",height:"100%",left:"-106.25%",top:0},prevBtnWrapperCSS:{cursor:"pointer",position:"absolute",top:0,right:"50%",bottom:0,left:0},closeBtnWrapperCSS:{cursor:"pointer",position:"absolute",top:0,right:0,bottom:0,left:"50%"},prevBtnBoxCSS:{position:"absolute",zIndex:103,top:0,bottom:0,left:"68%"},closeBtnBoxCSS:{position:"absolute",zIndex:103,top:0,bottom:0,right:"68%"},prevBtnCSS:{color:"#fff",backgroundColor:"#000",opacity:0.5,padding:"0 1em",borderRadius:"0 0 1ex 0"},closeBtnCSS:{color:"#fff",backgroundColor:"#000",opacity:0.5,padding:"0 1em",borderRadius:"0 0 0 1ex"},prevBtnHoverCSS:{opacity:1},closeBtnHoverCSS:{opacity:1},imgCSS:{position:"absolute",zIndex:102,margin:"auto",width:"auto",top:0,right:0,bottom:0,left:0,display:"block",cursor:"pointer",maxWidth:"32%",maxHeight:"100%"},imgNextCSS:{position:"absolute",margin:"auto",width:"auto",top:0,right:0,bottom:0,left:"68%",display:"block",maxWidth:"32%",maxHeight:"100%"},imgPrevCSS:{position:"absolute",margin:"auto",width:"auto",top:0,right:"68%",bottom:0,left:0,display:"block",maxWidth:"32%",maxHeight:"100%"},bottomCSS:{position:"fixed",zIndex:104,right:0,bottom:0,left:0,"-webkit-user-select":"text","-moz-user-select":"text","user-select":"text",backgroundColor:"#000",color:"#fff",opacity:0.5,padding:"0 1em",textAlign:"center"},bottomHoverCSS:{opacity:1},overlayAttrs:{},layoutAttrs:{},boxAttrs:{},prevBtnWrapperAttrs:{},prevBtnBoxAttrs:{},prevBtnAttrs:{},closeBtnWrapperAttrs:{},closeBtnBoxAttrs:{},closeBtnAttrs:{},imgAttrs:{},imgNextAttrs:{},imgPrevAttrs:{},bottomAttrs:{}}}(jQuery)); \ No newline at end of file diff --git a/index.html b/index.html index 76b0b30..7aae002 100644 --- a/index.html +++ b/index.html @@ -74,14 +74,14 @@

ABigImage

ABigImage is jQuery plugin for viewing big versions of images.

-

Current version: 1.2.6 (2014-07-23).

+

Current version: 1.2.7 (2014-07-24).