forked from tholman/intense-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
intense.min.js
1 lines (1 loc) · 7.59 KB
/
intense.min.js
1
window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}}(),window.cancelRequestAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||clearTimeout}();var Intense=function(){"use strict";function e(e,n){for(var t in n)t in e||(e[t]=n[t]);return e}function n(e,n){for(var t in n)e.style[t]=n[t]}function t(e){var n=window.innerHeight/e.h;if(e.w*n>window.innerWidth)return{w:e.w*n,h:e.h*n,fit:!0};var t=window.innerWidth/e.w;return{w:e.w*t,h:e.h*t,fit:!1}}function i(e){var n;if(e.length)for(n=0;n<e.length;n++)o(e[n]);else o(e)}function o(e){(e.getAttribute("data-image")||e.src)&&e.addEventListener("click",function(){p(this)},!1)}function r(){d()}function a(){cancelRequestAnimFrame(y)}function d(){y=requestAnimFrame(d),b()}function c(){I=document.body.style.overflow,document.body.style.overflow="hidden"}function u(){document.body.style.overflow=I}function w(e,t){var i={backgroundColor:"rgba(0,0,0,0.8)",width:"100%",height:"100%",position:"fixed",top:"0px",left:"0px",overflow:"hidden",zIndex:"999999",margin:"0px",webkitTransition:"opacity 150ms cubic-bezier( 0, 0, .26, 1 )",MozTransition:"opacity 150ms cubic-bezier( 0, 0, .26, 1 )",transition:"opacity 150ms cubic-bezier( 0, 0, .26, 1 )",opacity:"0"};Z=document.createElement("figure"),Z.appendChild(E),n(Z,i);var o={cursor:'url( "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpb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4bw6ya06/OnHNqXnGrjnZIyWNXzyjC0GPYIk0fvHM+h+XXzxjnOCcNH7x7KqT/VrSfwQYAOAcX9HTDttYAAAAAElFTkSuQmCC" ) 25 25, no-drop'};n(E,o);var r={fontFamily:'Georgia, Times, "Times New Roman", serif',position:"fixed",bottom:"0px",left:"0px",padding:"20px",color:"#fff",wordSpacing:"0.2px",webkitFontSmoothing:"antialiased",textShadow:"-1px 0px 1px rgba(0,0,0,0.4)"},a=document.createElement("figcaption");if(n(a,r),e){var d={margin:"0px",padding:"0px",fontWeight:"normal",fontSize:"40px",letterSpacing:"0.5px",lineHeight:"35px",textAlign:"left"},c=document.createElement("h1");n(c,d),c.innerHTML=e,a.appendChild(c)}if(t){var u={margin:"0px",padding:"0px",fontWeight:"normal",fontSize:"20px",letterSpacing:"0.1px",maxWidth:"500px",textAlign:"left",background:"none",marginTop:"5px"},w=document.createElement("h2");n(w,u),w.innerHTML=t,a.appendChild(w)}Z.appendChild(a),s(),M.xCurr=M.xDest=window.innerWidth/2,M.yCurr=M.yDest=window.innerHeight/2,document.body.appendChild(Z),setTimeout(function(){Z.style.opacity="1"},10)}function m(){u(),f(),a(),document.body.removeChild(Z)}function s(){var e=t(C);E.width=e.w,E.height=e.h,j=e.fit,F={w:E.width,h:E.height},S={w:window.innerWidth,h:window.innerHeight},k={x:S.w-F.w,y:S.h-F.h}}function p(e){var n=e.getAttribute("data-image")||e.src,t=e.getAttribute("data-title"),i=e.getAttribute("data-caption"),o=new Image;o.onload=function(){C={w:o.width,h:o.height},E=this,w(t,i),c(),l(),d()},o.src=n}function l(){Z.addEventListener("mousemove",x,!1),Z.addEventListener("touchmove",h,!1),window.addEventListener("resize",s,!1),window.addEventListener("keyup",v,!1),E.addEventListener("click",m,!1)}function f(){Z.removeEventListener("mousemove",x,!1),Z.removeEventListener("touchmove",h,!1),window.removeEventListener("resize",s,!1),window.removeEventListener("keyup",v,!1),E.removeEventListener("click",m,!1)}function x(e){M.xDest=e.clientX,M.yDest=e.clientY}function h(e){e.preventDefault(),M.xDest=e.touches[0].clientX,M.yDest=e.touches[0].clientY}function v(e){e.preventDefault(),e.keyCode===D&&m()}function b(){if(M.xCurr+=.05*(M.xDest-M.xCurr),M.yCurr+=.05*(M.yDest-M.yCurr),j===!0){if(R+=M.xCurr-R,M.xCurr!==A){var e=parseFloat(R/S.w);e=k.x*e,E.style.webkitTransform="translate3d("+e+"px, 0px, 0px)",E.style.MozTransform="translate3d("+e+"px, 0px, 0px)",E.style.msTransform="translate3d("+e+"px, 0px, 0px)",A=M.xCurr}}else if(j===!1&&(R+=M.yCurr-R,M.yCurr!==A)){var e=parseFloat(R/S.h);e=k.y*e,E.style.webkitTransform="translate3d( 0px, "+e+"px, 0px)",E.style.MozTransform="translate3d( 0px, "+e+"px, 0px)",E.style.msTransform="translate3d( 0px, "+e+"px, 0px)",A=M.yCurr}}function g(e){if(!e)throw"You need to pass an element!";i(e)}var y,A,C,E,Z,I,D=27,M={xCurr:0,yCurr:0,xDest:0,yDest:0},j=!0,R=0,F={w:0,h:0},S={w:0,h:0},k={x:0,y:0};return e(g,{resize:s,start:r,stop:a})}();