diff --git a/dist/xzoom.min.js b/dist/xzoom.min.js index f78190b..c1f2f78 100644 --- a/dist/xzoom.min.js +++ b/dist/xzoom.min.js @@ -1,8 +1,8 @@ /*!----------------------------------------------------- - * xZoom v1.0.7 + * xZoom v1.0.8 * (c) 2013 by Azat Ahmedov & Elman Guseynov * https://github.com/payalord * https://dribbble.com/elmanvebs * Apache License 2.0 *------------------------------------------------------*/ -;window.requestAnimFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,20)}})();function detect_old_ie(){if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){var a=new Number(RegExp.$1);if(a>=9){return false}else{if(a>=8){return true}else{if(a>=7){return true}else{if(a>=6){return true}else{if(a>=5){return true}}}}}}else{return false}}(function(b){b.fn.xon=b.fn.on||b.fn.bind;b.fn.xoff=b.fn.off||b.fn.bind;function a(ay,aH){this.xzoom=true;var F=this;var N;var aE={};var ae,al,ab,ak,ad,aj,an,S,aG,y,ap,aa,Y;var az,o,Q,U,T,ac,p=new Array();var G=new Array(),aD=0,z=0;var J,R,l,k;var ar,aC,ax,av,P,n,aM,aK,aB,aA,X,V,aq,am=0;var h,ai;var aL,C=0,A=0,ah=0,af=0,s=0,r=0,au=0,at=0,I=0,H=0;var E=detect_old_ie(),B=/MSIE (\d+\.\d+);/.test(navigator.userAgent),Z,W;var L,j="",K,w;var aJ,f,m,q,g,i,ao,d,t;this.adaptive=function(){if(m==0||q==0){ay.css("width","");ay.css("height","");m=ay.width();q=ay.height()}aI();aJ=b(window).width();f=b(window).height();g=ay.width();i=ay.height();var u=false;if(m>aJ||q>f){u=true}if(g>m){g=m}if(i>q){i=q}if(u){ay.width("100%")}else{if(m!=0){ay.width(m)}}if(ao!="fullscreen"){if(aF()){F.options.position=ao}else{F.options.position=F.options.mposition}}if(!F.options.lensReverse){d=F.options.adaptiveReverse&&F.options.position==F.options.mposition}};function aw(){var aN=document.documentElement;var v=(window.pageXOffset||aN.scrollLeft)-(aN.clientLeft||0);var u=(window.pageYOffset||aN.scrollTop)-(aN.clientTop||0);return{left:v,top:u}}function aF(){var u=ay.offset();if(F.options.zoomWidth=="auto"){ab=g}else{ab=F.options.zoomWidth}if(F.options.zoomHeight=="auto"){ak=i}else{ak=F.options.zoomHeight}if(F.options.position.substr(0,1)=="#"){aE=b(F.options.position)}else{aE.length=0}if(aE.length!=0){return true}switch(ao){case"lens":case"inside":return true;break;case"top":aj=u.top;an=u.left;S=aj-i;aG=an;break;case"left":aj=u.top;an=u.left;S=aj;aG=an-g;break;case"bottom":aj=u.top;an=u.left;S=aj+i;aG=an;break;case"right":default:aj=u.top;an=u.left;S=aj;aG=an+g}if(aG+ab>aJ||aG<0){return false}return true}this.xscroll=function(v){aa=v.pageX||v.originalEvent.pageX;Y=v.pageY||v.originalEvent.pageY;v.preventDefault();if(v.xscale){am=v.xscale;M(aa,Y)}else{var aO=-v.originalEvent.detail||v.originalEvent.wheelDelta||v.xdelta;var u=aa;var aN=Y;if(E){u=Z;aN=W}if(aO>0){aO=-0.05}else{aO=0.05}am+=aO;M(u,aN)}};function x(){if(F.options.lensShape=="circle"&&F.options.position=="lens"){ar=aC=Math.max(ar,aC);var u=(ar+Math.max(n,P)*2)/2;l.css({"-moz-border-radius":u,"-webkit-border-radius":u,"border-radius":u})}}function D(u,aO,aN,v){if(F.options.position=="lens"){R.css({top:-(aO-aj)*aA+(aC/2),left:-(u-an)*aB+(ar/2)});if(F.options.bg){l.css({"background-image":"url("+R.attr("src")+")","background-repeat":"no-repeat","background-position":(-(u-an)*aB+(ar/2))+"px "+(-(aO-aj)*aA+(aC/2))+"px"});if(aN&&v){l.css({"background-size":aN+"px "+v+"px"})}}}else{R.css({top:-av*aA,left:-ax*aB})}}function M(u,aP){if(am<-1){am=-1}if(am>1){am=1}if(Xae-ar){ax=ae-ar}if(av<0){av=0}if(av>al-aC){av=al-aC}}}function aI(){if(typeof az!="undefined"){az.remove()}if(typeof Q!="undefined"){Q.remove()}if(typeof w!="undefined"){w.remove()}}function O(u,aN){if(F.options.position=="fullscreen"){ae=b(window).width();al=b(window).height()}else{ae=ay.width();al=ay.height()}U.css({top:al/2-U.height()/2,left:ae/2-U.width()/2});if(F.options.rootOutput||F.options.position=="fullscreen"){ad=ay.offset()}else{ad=ay.position()}ad.top=Math.round(ad.top);ad.left=Math.round(ad.left);switch(F.options.position){case"fullscreen":aj=aw().top;an=aw().left;S=0;aG=0;break;case"inside":aj=ad.top;an=ad.left;S=0;aG=0;break;case"top":aj=ad.top;an=ad.left;S=aj-al;aG=an;break;case"left":aj=ad.top;an=ad.left;S=aj;aG=an-ae;break;case"bottom":aj=ad.top;an=ad.left;S=aj+al;aG=an;break;case"right":default:aj=ad.top;an=ad.left;S=aj;aG=an+ae}aj-=az.outerHeight()/2;an-=az.outerWidth()/2;if(F.options.position.substr(0,1)=="#"){aE=b(F.options.position)}else{aE.length=0}if(aE.length==0&&F.options.position!="inside"&&F.options.position!="fullscreen"){if(!F.options.adaptive||!m||!q){m=ae;q=al}if(F.options.zoomWidth=="auto"){ab=ae}else{ab=F.options.zoomWidth}if(F.options.zoomHeight=="auto"){ak=al}else{ak=F.options.zoomHeight}S+=F.options.Yoffset;aG+=F.options.Xoffset;Q.css({width:ab+"px",height:ak+"px",top:S,left:aG});if(F.options.position!="lens"){N.append(Q)}}else{if(F.options.position=="inside"||F.options.position=="fullscreen"){ab=ae;ak=al;Q.css({width:ab+"px",height:ak+"px"});az.append(Q)}else{ab=aE.width();ak=aE.height();if(F.options.rootOutput){S=aE.offset().top;aG=aE.offset().left;N.append(Q)}else{S=aE.position().top;aG=aE.position().left;aE.parent().append(Q)}S+=(aE.outerHeight()-ak-Q.outerHeight())/2;aG+=(aE.outerWidth()-ab-Q.outerWidth())/2;Q.css({width:ab+"px",height:ak+"px",top:S,left:aG})}}if(F.options.title&&j!=""){if(F.options.position=="inside"||F.options.position=="lens"||F.options.position=="fullscreen"){y=S;ap=aG;az.append(w)}else{y=S+(Q.outerHeight()-ak)/2;ap=aG+(Q.outerWidth()-ab)/2;N.append(w)}w.css({width:ab+"px",height:ak+"px",top:y,left:ap})}az.css({width:ae+"px",height:al+"px",top:aj,left:an});o.css({width:ae+"px",height:al+"px"});if(F.options.tint&&(F.options.position!="inside"&&F.options.position!="fullscreen")){o.css("background-color",F.options.tint)}else{if(E){o.css({"background-image":"url("+ay.attr("src")+")","background-color":"#fff"})}}J=new Image();var v="";if(B){v="?r="+(new Date()).getTime()}J.src=ay.attr("xoriginal")+v;R=b(J);R.css("position","absolute");J=new Image();J.src=ay.attr("src");k=b(J);k.css("position","absolute");k.width(ae);switch(F.options.position){case"fullscreen":case"inside":Q.append(R);break;case"lens":l.append(R);if(F.options.bg){R.css({display:"none"})}break;default:Q.append(R);l.append(k)}}this.openzoom=function(u){aa=u.pageX;Y=u.pageY;if(F.options.adaptive){F.adaptive()}am=F.options.defaultScale;aL=false;az=b("
");if(F.options.sourceClass!=""){az.addClass(F.options.sourceClass)}az.css("position","absolute");U=b("
");if(F.options.loadingClass!=""){U.addClass(F.options.loadingClass)}U.css("position","absolute");o=b('
');az.append(U);Q=b("
");if(F.options.zoomClass!=""&&F.options.position!="fullscreen"){Q.addClass(F.options.zoomClass)}Q.css({position:"absolute",overflow:"hidden",opacity:1});if(F.options.title&&j!=""){w=b("
");K=b("
");w.css({position:"absolute",opacity:1});if(F.options.titleClass){K.addClass(F.options.titleClass)}K.html(""+j+"");w.append(K);if(F.options.fadeIn){w.css({opacity:0})}}l=b("
");if(F.options.lensClass!=""){l.addClass(F.options.lensClass)}l.css({position:"absolute",overflow:"hidden"});if(F.options.lens){lenstint=b("
");lenstint.css({position:"absolute",background:F.options.lens,opacity:F.options.lensOpacity,width:"100%",height:"100%",top:0,left:0,"z-index":9999});l.append(lenstint)}if(F.options.position!="inside"&&F.options.position!="fullscreen"){if(F.options.tint||E){az.append(o)}if(F.options.fadeIn){o.css({opacity:0});l.css({opacity:0});Q.css({opacity:0})}N.append(az)}else{if(F.options.fadeIn){Q.css({opacity:0})}N.append(az)}F.eventmove(az);F.eventleave(az);O(aa,Y);switch(F.options.position){case"inside":S-=(Q.outerHeight()-Q.height())/2;aG-=(Q.outerWidth()-Q.width())/2;break;case"top":S-=Q.outerHeight()-Q.height();aG-=(Q.outerWidth()-Q.width())/2;break;case"left":S-=(Q.outerHeight()-Q.height())/2;aG-=Q.outerWidth()-Q.width();break;case"bottom":aG-=(Q.outerWidth()-Q.width())/2;break;case"right":S-=(Q.outerHeight()-Q.height())/2}Q.css({top:S,left:aG});R.xon("load",function(){U.remove();if(F.options.scroll){F.eventscroll(az)}if(F.options.position!="inside"&&F.options.position!="fullscreen"){az.append(l);if(F.options.fadeIn){o.fadeTo(300,F.options.tintOpacity);l.fadeTo(300,1);Q.fadeTo(300,1)}else{o.css({opacity:F.options.tintOpacity});l.css({opacity:1});Q.css({opacity:1})}}else{if(F.options.fadeIn){Q.fadeTo(300,1)}else{Q.css({opacity:1})}}if(F.options.title&&j!=""){if(F.options.fadeIn){w.fadeTo(300,1)}else{w.css({opacity:1})}}h=R.width();ai=R.height();if(F.options.adaptive){if(aeae||aN<0||aN>al){az.trigger("mouseleave")}if(t&&!F.options.bg){C=v.pageX;A=v.pageY}else{x();e(v.pageX,v.pageY);l.css({top:av-n,left:ax-P});k.css({top:-av,left:-ax});D(v.pageX,v.pageY,0,0)}};this.eventdefault=function(){F.eventopen=function(u){u.xon("mouseenter",F.openzoom)};F.eventleave=function(u){u.xon("mouseleave",F.closezoom)};F.eventmove=function(u){u.xon("mousemove",F.movezoom)};F.eventscroll=function(u){u.xon("mousewheel DOMMouseScroll",F.xscroll)};F.eventclick=function(u){u.xon("click",function(v){ay.trigger("click")})}};this.eventunbind=function(){ay.xoff("mouseenter");F.eventopen=function(u){};F.eventleave=function(u){};F.eventmove=function(u){};F.eventscroll=function(u){};F.eventclick=function(u){}};this.init=function(u){F.options=b.extend({},b.fn.xzoom.defaults,u);if(F.options.rootOutput){N=b("body")}else{N=ay.parent()}ao=F.options.position;d=F.options.lensReverse&&F.options.position=="inside";if(F.options.smoothZoomMove<0){F.options.smoothZoomMove=0}if(F.options.smoothLensMove<0){F.options.smoothLensMove=0}if(F.options.smoothScale<0){F.options.smoothScale=0}t=F.options.smoothZoomMove&&F.options.smoothLensMove&&F.options.smoothScale;if(F.options.adaptive){b(window).xon("load",function(){m=ay.width();q=ay.height();F.adaptive();b(window).resize(F.adaptive)})}F.eventdefault();F.eventopen(ay)};this.destroy=function(){F.eventunbind();delete F};this.closezoom=function(){aL=false;if(F.options.fadeOut){if(F.options.title&&j!=""){w.fadeOut(299)}if(F.options.position!="inside"||F.options.position!="fullscreen"){Q.fadeOut(299);az.fadeOut(300,function(){aI()})}else{az.fadeOut(300,function(){aI()})}}else{aI()}};this.gallery=function(){var aN=new Array();var v,u=0;for(v=z;v=9){return false}else{if(a>=8){return true}else{if(a>=7){return true}else{if(a>=6){return true}else{if(a>=5){return true}}}}}}else{return false}}(function(b){b.fn.xon=b.fn.on||b.fn.bind;b.fn.xoff=b.fn.off||b.fn.bind;function a(ax,aG){this.xzoom=true;var E=this;var M;var aD={};var ad,ak,aa,aj,ac,ai,am,R,aF,x,ao,Z,X;var ay,o,P,T,S,ab,p=new Array();var F=new Array(),aC=0,y=0;var I,Q,l,k;var aq,aB,aw,au,O,n,aL,aJ,aA,az,W,U,ap,al=0;var h,ah;var aK,B=0,z=0,ag=0,ae=0,s=0,r=0,at=0,ar=0,H=0,G=0;var D=detect_old_ie(),A=/MSIE (\d+\.\d+);/.test(navigator.userAgent),Y,V;var K,j="",J,t;var aI,f,m,q,g,i,an,d;this.adaptive=function(){if(m==0||q==0){ax.css("width","");ax.css("height","");m=ax.width();q=ax.height()}aH();aI=b(window).width();f=b(window).height();g=ax.width();i=ax.height();var u=false;if(m>aI||q>f){u=true}if(g>m){g=m}if(i>q){i=q}if(u){ax.width("100%")}else{if(m!=0){ax.width(m)}}if(an!="fullscreen"){if(aE()){E.options.position=an}else{E.options.position=E.options.mposition}}if(!E.options.lensReverse){d=E.options.adaptiveReverse&&E.options.position==E.options.mposition}};function av(){var aM=document.documentElement;var v=(window.pageXOffset||aM.scrollLeft)-(aM.clientLeft||0);var u=(window.pageYOffset||aM.scrollTop)-(aM.clientTop||0);return{left:v,top:u}}function aE(){var u=ax.offset();if(E.options.zoomWidth=="auto"){aa=g}else{aa=E.options.zoomWidth}if(E.options.zoomHeight=="auto"){aj=i}else{aj=E.options.zoomHeight}if(E.options.position.substr(0,1)=="#"){aD=b(E.options.position)}else{aD.length=0}if(aD.length!=0){return true}switch(an){case"lens":case"inside":return true;break;case"top":ai=u.top;am=u.left;R=ai-aj;aF=am;break;case"left":ai=u.top;am=u.left;R=ai;aF=am-aa;break;case"bottom":ai=u.top;am=u.left;R=ai+i;aF=am;break;case"right":default:ai=u.top;am=u.left;R=ai;aF=am+g}if(aF+aa>aI||aF<0){return false}return true}this.xscroll=function(v){Z=v.pageX||v.originalEvent.pageX;X=v.pageY||v.originalEvent.pageY;v.preventDefault();if(v.xscale){al=v.xscale;L(Z,X)}else{var aN=-v.originalEvent.detail||v.originalEvent.wheelDelta||v.xdelta;var u=Z;var aM=X;if(D){u=Y;aM=V}if(aN>0){aN=-0.05}else{aN=0.05}al+=aN;L(u,aM)}};function w(){if(E.options.lensShape=="circle"&&E.options.position=="lens"){aq=aB=Math.max(aq,aB);var u=(aq+Math.max(n,O)*2)/2;l.css({"-moz-border-radius":u,"-webkit-border-radius":u,"border-radius":u})}}function C(u,aN,aM,v){if(E.options.position=="lens"){Q.css({top:-(aN-ai)*az+(aB/2),left:-(u-am)*aA+(aq/2)});if(E.options.bg){l.css({"background-image":"url("+Q.attr("src")+")","background-repeat":"no-repeat","background-position":(-(u-am)*aA+(aq/2))+"px "+(-(aN-ai)*az+(aB/2))+"px"});if(aM&&v){l.css({"background-size":aM+"px "+v+"px"})}}}else{Q.css({top:-au*az,left:-aw*aA})}}function L(u,aO){if(al<-1){al=-1}if(al>1){al=1}if(Wad-aq){aw=ad-aq}if(au<0){au=0}if(au>ak-aB){au=ak-aB}}}function aH(){if(typeof ay!="undefined"){ay.remove()}if(typeof P!="undefined"){P.remove()}if(typeof t!="undefined"){t.remove()}}function N(u,aM){if(E.options.position=="fullscreen"){ad=b(window).width();ak=b(window).height()}else{ad=ax.width();ak=ax.height()}T.css({top:ak/2-T.height()/2,left:ad/2-T.width()/2});if(E.options.rootOutput||E.options.position=="fullscreen"){ac=ax.offset()}else{ac=ax.position()}ac.top=Math.round(ac.top);ac.left=Math.round(ac.left);switch(E.options.position){case"fullscreen":ai=av().top;am=av().left;R=0;aF=0;break;case"inside":ai=ac.top;am=ac.left;R=0;aF=0;break;case"top":ai=ac.top;am=ac.left;R=ai-aj;aF=am;break;case"left":ai=ac.top;am=ac.left;R=ai;aF=am-aa;break;case"bottom":ai=ac.top;am=ac.left;R=ai+ak;aF=am;break;case"right":default:ai=ac.top;am=ac.left;R=ai;aF=am+ad}ai-=ay.outerHeight()/2;am-=ay.outerWidth()/2;if(E.options.position.substr(0,1)=="#"){aD=b(E.options.position)}else{aD.length=0}if(aD.length==0&&E.options.position!="inside"&&E.options.position!="fullscreen"){if(!E.options.adaptive||!m||!q){m=ad;q=ak}if(E.options.zoomWidth=="auto"){aa=ad}else{aa=E.options.zoomWidth}if(E.options.zoomHeight=="auto"){aj=ak}else{aj=E.options.zoomHeight}R+=E.options.Yoffset;aF+=E.options.Xoffset;P.css({width:aa+"px",height:aj+"px",top:R,left:aF});if(E.options.position!="lens"){M.append(P)}}else{if(E.options.position=="inside"||E.options.position=="fullscreen"){aa=ad;aj=ak;P.css({width:aa+"px",height:aj+"px"});ay.append(P)}else{aa=aD.width();aj=aD.height();if(E.options.rootOutput){R=aD.offset().top;aF=aD.offset().left;M.append(P)}else{R=aD.position().top;aF=aD.position().left;aD.parent().append(P)}R+=(aD.outerHeight()-aj-P.outerHeight())/2;aF+=(aD.outerWidth()-aa-P.outerWidth())/2;P.css({width:aa+"px",height:aj+"px",top:R,left:aF})}}if(E.options.title&&j!=""){if(E.options.position=="inside"||E.options.position=="lens"||E.options.position=="fullscreen"){x=R;ao=aF;ay.append(t)}else{x=R+(P.outerHeight()-aj)/2;ao=aF+(P.outerWidth()-aa)/2;M.append(t)}t.css({width:aa+"px",height:aj+"px",top:x,left:ao})}ay.css({width:ad+"px",height:ak+"px",top:ai,left:am});o.css({width:ad+"px",height:ak+"px"});if(E.options.tint&&(E.options.position!="inside"&&E.options.position!="fullscreen")){o.css("background-color",E.options.tint)}else{if(D){o.css({"background-image":"url("+ax.attr("src")+")","background-color":"#fff"})}}I=new Image();var v="";if(A){v="?r="+(new Date()).getTime()}I.src=ax.attr("xoriginal")+v;Q=b(I);Q.css("position","absolute");I=new Image();I.src=ax.attr("src");k=b(I);k.css("position","absolute");k.width(ad);switch(E.options.position){case"fullscreen":case"inside":P.append(Q);break;case"lens":l.append(Q);if(E.options.bg){Q.css({display:"none"})}break;default:P.append(Q);l.append(k)}}this.openzoom=function(u){Z=u.pageX;X=u.pageY;if(E.options.adaptive){E.adaptive()}al=E.options.defaultScale;aK=false;ay=b("
");if(E.options.sourceClass!=""){ay.addClass(E.options.sourceClass)}ay.css("position","absolute");T=b("
");if(E.options.loadingClass!=""){T.addClass(E.options.loadingClass)}T.css("position","absolute");o=b('
');ay.append(T);P=b("
");if(E.options.zoomClass!=""&&E.options.position!="fullscreen"){P.addClass(E.options.zoomClass)}P.css({position:"absolute",overflow:"hidden",opacity:1});if(E.options.title&&j!=""){t=b("
");J=b("
");t.css({position:"absolute",opacity:1});if(E.options.titleClass){J.addClass(E.options.titleClass)}J.html(""+j+"");t.append(J);if(E.options.fadeIn){t.css({opacity:0})}}l=b("
");if(E.options.lensClass!=""){l.addClass(E.options.lensClass)}l.css({position:"absolute",overflow:"hidden"});if(E.options.lens){lenstint=b("
");lenstint.css({position:"absolute",background:E.options.lens,opacity:E.options.lensOpacity,width:"100%",height:"100%",top:0,left:0,"z-index":9999});l.append(lenstint)}if(E.options.position!="inside"&&E.options.position!="fullscreen"){if(E.options.tint||D){ay.append(o)}if(E.options.fadeIn){o.css({opacity:0});l.css({opacity:0});P.css({opacity:0})}M.append(ay)}else{if(E.options.fadeIn){P.css({opacity:0})}M.append(ay)}E.eventmove(ay);E.eventleave(ay);N(Z,X);switch(E.options.position){case"inside":R-=(P.outerHeight()-P.height())/2;aF-=(P.outerWidth()-P.width())/2;break;case"top":R-=P.outerHeight()-P.height();aF-=(P.outerWidth()-P.width())/2;break;case"left":R-=(P.outerHeight()-P.height())/2;aF-=P.outerWidth()-P.width();break;case"bottom":aF-=(P.outerWidth()-P.width())/2;break;case"right":R-=(P.outerHeight()-P.height())/2}P.css({top:R,left:aF});Q.xon("load",function(){T.remove();if(E.options.scroll){E.eventscroll(ay)}if(E.options.position!="inside"&&E.options.position!="fullscreen"){ay.append(l);if(E.options.fadeIn){o.fadeTo(300,E.options.tintOpacity);l.fadeTo(300,1);P.fadeTo(300,1)}else{o.css({opacity:E.options.tintOpacity});l.css({opacity:1});P.css({opacity:1})}}else{if(E.options.fadeIn){P.fadeTo(300,1)}else{P.css({opacity:1})}}if(E.options.title&&j!=""){if(E.options.fadeIn){t.fadeTo(300,1)}else{t.css({opacity:1})}}h=Q.width();ah=Q.height();if(E.options.adaptive){if(adad||aM<0||aM>ak){ay.trigger("mouseleave")}if(E.options.smooth){B=v.pageX;z=v.pageY}else{w();e(v.pageX,v.pageY);l.css({top:au-n,left:aw-O});k.css({top:-au,left:-aw});C(v.pageX,v.pageY,0,0)}};this.eventdefault=function(){E.eventopen=function(u){u.xon("mouseenter",E.openzoom)};E.eventleave=function(u){u.xon("mouseleave",E.closezoom)};E.eventmove=function(u){u.xon("mousemove",E.movezoom)};E.eventscroll=function(u){u.xon("mousewheel DOMMouseScroll",E.xscroll)};E.eventclick=function(u){u.xon("click",function(v){ax.trigger("click")})}};this.eventunbind=function(){ax.xoff("mouseenter");E.eventopen=function(u){};E.eventleave=function(u){};E.eventmove=function(u){};E.eventscroll=function(u){};E.eventclick=function(u){}};this.init=function(u){E.options=b.extend({},b.fn.xzoom.defaults,u);if(E.options.rootOutput){M=b("body")}else{M=ax.parent()}an=E.options.position;d=E.options.lensReverse&&E.options.position=="inside";if(E.options.smoothZoomMove<1){E.options.smoothZoomMove=1}if(E.options.smoothLensMove<1){E.options.smoothLensMove=1}if(E.options.smoothScale<1){E.options.smoothScale=1}if(E.options.adaptive){b(window).xon("load",function(){m=ax.width();q=ax.height();E.adaptive();b(window).resize(E.adaptive)})}E.eventdefault();E.eventopen(ax)};this.destroy=function(){E.eventunbind();delete E};this.closezoom=function(){aK=false;if(E.options.fadeOut){if(E.options.title&&j!=""){t.fadeOut(299)}if(E.options.position!="inside"||E.options.position!="fullscreen"){P.fadeOut(299);ay.fadeOut(300,function(){aH()})}else{ay.fadeOut(300,function(){aH()})}}else{aH()}};this.gallery=function(){var aM=new Array();var v,u=0;for(v=y;vOptions bg false - Zoom image output as background. + Zoom image output as background, works only when position is set to "lens". diff --git a/doc/manual.md b/doc/manual.md index 6d4571d..b11267b 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -88,7 +88,7 @@ Here is list of all possible options and their description: | adaptiveReverse | false | Same as lensReverse, but only available when adaptive is true. | | title | false | Output title/caption of the image, in the zoom output window. | | titleClass | xzoom-caption | Class name for caption "div" container. | -| bg | false | Zoom image output as background. | +| bg | false | Zoom image output as background, works only when position is set to "lens". | Options are case sensetive. And must be passed to xZoom as javascript object: ```javascript diff --git a/package.json b/package.json index 5d4483d..e3b1b4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xzoom", - "version": "1.0.7", + "version": "1.0.8", "contributors": [ "Azat Ahmedov (https://payalord.github.io)", "Elman Guseynov (http://elman.pro)" diff --git a/src/xzoom.js b/src/xzoom.js index 0bd2145..2ea7322 100644 --- a/src/xzoom.js +++ b/src/xzoom.js @@ -1,5 +1,5 @@ /*!----------------------------------------------------- - * xZoom v1.0.7 + * xZoom v1.0.8 * (c) 2013 by Azat Ahmedov & Elman Guseynov * https://github.com/payalord * https://dribbble.com/elmanvebs @@ -55,7 +55,7 @@ if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ var active, title = '', caption, caption_container; //Adaptive properties - var wsw, wsh, osw, osh, tsw, tsh, oposition, reverse, smoothNormal; + var wsw, wsh, osw, osh, tsw, tsh, oposition, reverse;//, smoothNormal; this.adaptive = function() { if (osw == 0 || osh == 0) { @@ -111,14 +111,14 @@ if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ case 'top': stop = moffset.top; sleft = moffset.left; - mtop = stop - tsh; + mtop = stop - mh; //tsh; mleft = sleft; break; case 'left': stop = moffset.top; sleft = moffset.left; mtop = stop; - mleft = sleft - tsw; + mleft = sleft - mw; //tsw; break; case 'bottom': stop = moffset.top; @@ -197,7 +197,7 @@ if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ var ih = mh * cc; var iw = ih * iwh; } - if (smoothNormal && flag) { + if (flag) { //If smoothMove u = x; v = y; @@ -329,14 +329,14 @@ if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ case 'top': stop = moffset.top; sleft = moffset.left; - mtop = stop - sh; + mtop = stop - mh; mleft = sleft; break; case 'left': stop = moffset.top; sleft = moffset.left; mtop = stop; - mleft = sleft - sw; + mleft = sleft - mw; break; case 'bottom': stop = moffset.top; @@ -625,7 +625,7 @@ if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ llv = lv = v = my; xscale(mx, my); - if (smoothNormal && !current.options.bg) {flag = true; requestAnimFrame(loopZoom);} + if (current.options.smooth) {flag = true; requestAnimFrame(loopZoom);} current.eventclick(source); }); @@ -656,7 +656,7 @@ if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ } if (x < 0 || x > sw || y < 0 || y > sh) source.trigger('mouseleave'); - if (smoothNormal && !current.options.bg) { + if (current.options.smooth) { u = event.pageX; v = event.pageY; } else { @@ -717,11 +717,11 @@ if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ reverse = current.options.lensReverse && current.options.position == 'inside'; //Limits - if (current.options.smoothZoomMove < 0) current.options.smoothZoomMove = 0; - if (current.options.smoothLensMove < 0) current.options.smoothLensMove = 0; - if (current.options.smoothScale < 0) current.options.smoothScale = 0; + if (current.options.smoothZoomMove < 1) current.options.smoothZoomMove = 1; + if (current.options.smoothLensMove < 1) current.options.smoothLensMove = 1; + if (current.options.smoothScale < 1) current.options.smoothScale = 1; - smoothNormal = current.options.smoothZoomMove && current.options.smoothLensMove && current.options.smoothScale; + //smoothNormal = current.options.smoothZoomMove && current.options.smoothLensMove && current.options.smoothScale; //Adaptive if (current.options.adaptive) { @@ -896,6 +896,7 @@ if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ fadeIn: true, fadeTrans: true, fadeOut: false, + smooth: true, smoothZoomMove: 3, smoothLensMove: 1, smoothScale: 6,