-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.min.js
1 lines (1 loc) · 2.2 KB
/
core.min.js
1
function getDirection(e,t){var n=e.width(),r=e.height(),i=(t.x-e.offset().left-n/2)*(n>r?r/n:1),s=(t.y-e.offset().top-r/2)*(r>n?n/r:1),o=Math.round((Math.atan2(s,i)*(180/Math.PI)+180)/90+3)%4;switch(o){case 0:return"top";case 1:return"right";case 2:return"bottom";default:return"left"}}function reverse(e){switch(e){case"top":return["top",1];case"bottom":return["top",-1];case"left":return["left",1];default:return["left",-1]}}function sneak(e,t,n,r){var i=~~e.css(n[0]).replace("px",""),s=n[1]*distance*(n[0]==="top"?1:2),o=s>0?n[0]==="top"?90:240:n[0]==="top"?-90:-240;i+~~(s*(n[0]==="top"?1:xFactor))+o>(n[0]==="top"?wHeight():wWidth())?e.css(n[0],n[0]==="top"?"40px":"100px"):i+~~(s*(n[0]==="top"?1:xFactor))-(n[0]==="top"?20:100)<0?e.css(n[0],(n[0]==="top"?wHeight():wWidth())+o-40+"px"):e.css(n[0],i+~~(s*(n[0]==="top"?1:xFactor))+"px");e.addClass("hovered skew"+t+(n[0]==="top"?r:""));$body.addClass("laugh");count++;(count===6||count===3&&wWidth>480)&&$body.addClass("final");$.wait(300).then(function(){e.removeClass("hovered skew"+t+(n[0]==="top"?r:""))});$.wait(500).then(function(){$body.removeClass("laugh")})}function getDodgeSide(e,t){var n=e.width();return t.x-e.offset().left>n/2?"right":"left"}$.wait=function(e){return $.Deferred(function(t){setTimeout(t.resolve,e)})};var xFactor=1.4,win=$(window),$body=$("body"),wHeight=function(){return win.height()},wWidth=function(){return win.width()},distance=wWidth()<481?80:40,button=$("button"),count=0;$("button").on("mouseenter",function(e){var t=$(this),n=getDirection(t,{x:e.pageX,y:e.pageY}),r=getDodgeSide(t,{x:e.pageX,y:e.pageY}),i=reverse(n);sneak($(this),n,i,r)}).on("click",function(e){var t=$(this),n=getDirection(t,{x:e.pageX,y:e.pageY}),r=getDodgeSide(t,{x:e.pageX,y:e.pageY}),i=reverse(n);sneak($(this),n,i,r)}).addClass("on").one("mouseenter",function(){$.wait(6e3).then(function(){$body.addClass("final")})});$(".copyright").on("click","a",function(e){wWidth()<480&&!$body.hasClass("final")&&e.preventDefault()});win.on("resize",function(){var e=~~((button.offset().left+100)/wWidth()*100);button.css({left:e+"%"});wWidth()<480?distance=40:distance=80});yepnope({load:["//platform.twitter.com/widgets.js","//connect.facebook.net/en_US/all.js#xfbml=1&appId=123142237735444"]});