-
Notifications
You must be signed in to change notification settings - Fork 1
/
jquery.simple3D.min.js
executable file
·9 lines (9 loc) · 1.68 KB
/
jquery.simple3D.min.js
1
2
3
4
5
6
7
8
9
/*! jQuery.Simples3D (http://memocarilog.info/jquery/6014)
* lastupdate: 2014-04-09
* author: Saori Miyazaki http://memocarilog.info
* License: MIT
*/
(function(c,s){c.fn.simple3D=function(r){var h=this,a=c.extend({},c.fn.simple3D.defaults,r);c(function(){if(0==h.length)return!1;var e=h[0],l=c(e).children().width(),e=c(e).children().height(),m=h.width(),n=h.height(),p=l-m,q=e-n,d=h.children();!1==a.bgImage?(l=(m-l)/2,e=(n-e)/2,h.css({position:"relative",overflow:"hidden"}),d.css({position:"absolute",left:l,top:e})):(h.css({overflow:"hidden"}),d.css({position:"absolute",left:d.position().left,top:d.position().top,"background-position":"0px 0px"}));
if(5<a.moveX||5<a.moveY)return!1;l=[5,4,3,2,1];a.moveX=l[parseFloat(a.moveX)-1];a.moveY=l[parseFloat(a.moveY)-1];a.moveX=6*Math.floor(a.moveX)/10+1;a.moveY=6*Math.floor(a.moveY)/10+1;(!0==a.targetAll?c(document):h).mousemove(function(k){var e=k.clientX-h.offset().left,e=e>m?m:e,e=e/m*p-p/2;k=k.clientY-h.offset().top+c("html").scrollTop();k=k>n?n:k;k=k/n*q-q/2;for(var g=1,l=d.length;g<=l;g++)if(!1==a.bgImage){var b=parseFloat(c(d[g-1]).css("left")),f=g/d.length*e-p/2,f=Math.floor((f+b)/a.moveX),f=
!1==a.reverseX?f:-f;c(d[g-1]).css("left",f);f=parseFloat(c(d[g-1]).css("top"));b=g/d.length*k-q/2;b=Math.floor((b+f)/a.moveY);b=!1==a.reverseY?b:-b;c(d[g-1]).css("top",b)}else{var b=parseFloat(c(d[g-1]).css("left")),f=g/d.length*e-p/2,f=Math.floor((f+b)/a.moveX),f=!1==a.reverseX?f:-f,r=parseFloat(c(d[g-1]).css("top")),b=g/d.length*k-q/2,b=Math.floor((r+b)/a.moveY),b=!1==a.reverseY?b:-b;c(d[g-1]).css("background-position",f+"px "+b+"px")}})});return this};c.fn.simple3D.defaults={moveX:3,moveY:3,bgImage:!1,
targetAll:!1,reverseX:!1,reverseY:!1}})(jQuery);