JezK
Edit File: skrollr-min.js
/*! skrollr 0.5.14 (2013-04-04) | Alexander Prinzhorn - https://github.com/Prinzhorn/skrollr | Free to use under terms of MIT license */(function(e,t,n){"use strict";function r(n){if(i=t.documentElement,s=t.body,H(),V=this,n=n||{},Q=n.constants||{},n.easing)for(var r in n.easing)B[r]=n.easing[r];if(J={beforerender:n.beforerender,render:n.render},K=n.forceHeight!==!1,Y=n.smoothScrolling!==!1,Z={targetTop:V.getScrollTop()},K&&(lt=n.scale||1),it(i,[c],[h]),K){var u=t.getElementById("skrollr-body")||t.createElement("div"),a=u.style;a.minWidth="1px",a.position="absolute",a.top=a.zIndex="0",u.id||(a.width="1px",a.right="0",s.appendChild(u)),function(e){tt=function(){e.apply(this,arguments),a.height=ft+i.clientHeight+"px"}}(tt)}return V.refresh(),o.addEvent(e,"resize",tt),function f(){S(f),I()}(),V}var i,s,o=e.skrollr={get:function(){return V},init:function(e){return V||new r(e)},VERSION:"0.5.14"},u=Object.prototype.hasOwnProperty,a="rendered",f="un"+a,l="skrollable",c="skrollr",h="no-"+c,p="linear",d=1e3,v=50,m="start",g="end",y="center",b="bottom",w="___has_rendered_class",E="___skrollable_id",S=e.requestAnimationFrame;(function(){var t,n=["ms","moz","webkit","o"];for(t=0;n.length>t&&!S;t++)S=e[n[t]+"RequestAnimationFrame"];var r=0;S||(S=function(t){var n=ut(),i=Math.max(0,30-(n-r));e.setTimeout(function(){t(n+i)},i),r=n+i})})();var x,T,N=/^\s+|\s+$/g,C=/^data(?:-(_\w+))?(?:-?(-?\d+))?(?:-?(start|end|top|center|bottom))?(?:-?(top|center|bottom))?$/,k=/\s*([a-z\-\[\]]+)\s*:\s*(.+?)\s*(?:;|$)/gi,L=/^([a-z\-]+)\[(\w+)\]$/,A=/-([a-z])/g,O=function(e,t){return t.toUpperCase()},M=/[\-+]?[\d]*\.?[\d]+/g,_=/\{\?\}/g,D=/rgba?\(\s*-?\d+\s*,\s*-?\d+\s*,\s*-?\d+/g,P=/[a-z\-]+-gradient/g,H=function(){var t=/^(?:O|Moz|webkit|ms)|(?:-(?:o|moz|webkit|ms)-)/;if(e.getComputedStyle){var n=e.getComputedStyle(s,null);for(var r in n)if(x=r.match(t)||+r==r&&n[r].match(t))break;x&&(x=x[0],"-"===x.slice(0,1)?(T=x,x={"-webkit-":"webkit","-moz-":"Moz","-ms-":"ms","-o-":"O"}[x]):T="-"+x.toLowerCase()+"-")}},B={begin:function(){return 0},end:function(){return 1},linear:function(e){return e},quadratic:function(e){return e*e},cubic:function(e){return e*e*e},swing:function(e){return-Math.cos(e*Math.PI)/2+.5},sqrt:function(e){return Math.sqrt(e)},bounce:function(e){var t;if(.5083>=e)t=3;else if(.8489>=e)t=9;else if(.96208>=e)t=27;else{if(!(.99981>=e))return 1;t=91}return 1-Math.abs(3*Math.cos(1.028*e*t)/t)}};r.prototype.refresh=function(e){var r,i=!1;for(e===n?(i=!0,$=[],dt=0,e=t.getElementsByTagName("*")):e=[].concat(e),r=0;e.length>r;r++){var s=e[r],o=s,u=[],c=Y;if(s.attributes){for(var h=0;s.attributes.length>h;h++){var p=s.attributes[h];if("data-anchor-target"!==p.name)if("data-smooth-scrolling"!==p.name){var d=p.name.match(C);if(null!==d){var v=d[1];v=v&&Q[v.substr(1)]||0;var y=(0|d[2])+v,b=d[3],S=d[4]||b,x={offset:y,props:p.value,element:s};u.push(x),b&&b!==m&&b!==g?(x.mode="relative",x.anchors=[b,S]):(x.mode="absolute",b===g?x.isEnd=!0:(x.frame=y*lt,delete x.offset))}}else c="off"!==p.value;else if(o=t.querySelector(p.value),null===o)throw'Unable to find anchor target "'+p.value+'"'}if(u.length){var T,N,k;!i&&E in s?(k=s[E],T=$[k].styleAttr,N=$[k].classAttr):(k=s[E]=dt++,T=s.style.cssText,N=rt(s));var L=$[k]={element:s,styleAttr:T,classAttr:N,anchorTarget:o,keyFrames:u,smoothScrolling:c};it(s,[l,a],[f]),L[w]=!0}}}for(tt(),r=0;e.length>r;r++){var A=$[e[r][E]];A!==n&&(A.keyFrames.sort(at),q(A),U(A))}return V},r.prototype.relativeToAbsolute=function(e,t,n){var r=i.clientHeight,s=e.getBoundingClientRect(),o=s.top,u=s.bottom-s.top;return t===b?o-=r:t===y&&(o-=r/2),n===b?o+=u:n===y&&(o+=u/2),o+=V.getScrollTop(),0|o+.5},r.prototype.animateTo=function(e,t){t=t||{};var r=ut(),i=V.getScrollTop();return G={startTop:i,topDiff:e-i,targetTop:e,duration:t.duration||d,startTime:r,endTime:r+(t.duration||d),easing:B[t.easing||p],done:t.done},G.topDiff||(G.done&&G.done.call(V,!1),G=n),V},r.prototype.stopAnimateTo=function(){G&&G.done&&G.done.call(V,!0),G=n},r.prototype.isAnimatingTo=function(){return!!G},r.prototype.setScrollTop=function(t,n){return n===!0&&(ht=t,et=!0),o.iscroll?o.iscroll.scrollTo(0,-t):e.scrollTo(0,t),V},r.prototype.getScrollTop=function(){return o.iscroll?-o.iscroll.y:e.pageYOffset||i.scrollTop||s.scrollTop||0},r.prototype.on=function(e,t){return J[e]=t,V},r.prototype.off=function(e){return delete J[e],V};var j=function(){var e,t,n,r,i,s,o,u,a;for(s=0;$.length>s;s++)for(e=$[s],t=e.element,n=e.anchorTarget,r=e.keyFrames,o=0;r.length>o;o++)i=r[o],"relative"===i.mode&&(u=t.style.cssText,a=rt(t),t.style.cssText=e.styleAttr,it(t,e.classAttr),i.frame=V.relativeToAbsolute(n,i.anchors[0],i.anchors[1])-i.offset,t.style.cssText=u,it(t,a)),K&&!i.isEnd&&i.frame>ft&&(ft=i.frame);for(ft=Math.max(ft,nt()),s=0;$.length>s;s++)for(e=$[s],r=e.keyFrames,o=0;r.length>o;o++)i=r[o],i.isEnd&&(i.frame=ft-i.offset)},F=function(e,t){for(var n=0;$.length>n;n++){var r,i,s=$[n],l=s.smoothScrolling?e:t,c=s.keyFrames,h=c[0].frame,p=c[c.length-1].frame,d=h>=l,v=l>=p;if(d||v){var m=c[d?0:c.length-1].props;for(r in m)u.call(m,r)&&(i=X(m[r].value),o.setStyle(s.element,r,i));s[w]&&(h>l||l>p)&&(it(s.element,[f],[a]),s[w]=!1)}else{s[w]||(it(s.element,[a],[f]),s[w]=!0);for(var g=0;c.length-1>g;g++)if(l>=c[g].frame&&c[g+1].frame>=l){var y=c[g],b=c[g+1];for(r in y.props)if(u.call(y.props,r)){var E=(l-y.frame)/(b.frame-y.frame);E=y.props[r].easing(E),i=W(y.props[r].value,b.props[r].value,E),i=X(i),o.setStyle(s.element,r,i)}break}}}},I=function(){var e,t,r=V.getScrollTop(),i=ut();if(G)i>=G.endTime?(r=G.targetTop,e=G.done,G=n):(t=G.easing((i-G.startTime)/G.duration),r=0|G.startTop+t*G.topDiff),V.setScrollTop(r);else{var s=Z.targetTop-r;s&&(Z={startTop:ht,topDiff:r-ht,targetTop:r,startTime:pt,endTime:pt+v}),Z.endTime>=i&&(t=B.sqrt((i-Z.startTime)/v),r=0|Z.startTop+t*Z.topDiff)}if(0>r&&(r=0),et||ht!==r){ct=r>=ht?"down":"up",et=!1;var o={curTop:r,lastTop:ht,maxTop:ft,direction:ct},u=J.beforerender&&J.beforerender.call(V,o);u!==!1&&(F(r,V.getScrollTop()),ht=r,J.render&&J.render.call(V,o)),e&&e.call(V,!1)}pt=i},q=function(e){for(var t=0;e.keyFrames.length>t;t++){for(var n,r,i,s,o=e.keyFrames[t],u={};null!==(s=k.exec(o.props));)i=s[1],r=s[2],n=i.match(L),null!==n?(i=n[1],n=n[2]):n=p,r=r.indexOf("!")?R(r):[r.slice(1)],u[i]={value:r,easing:B[n]};o.props=u}},R=function(e){var t=[];return D.lastIndex=0,e=e.replace(D,function(e){return e.replace(M,function(e){return 100*(e/255)+"%"})}),T&&(P.lastIndex=0,e=e.replace(P,function(e){return T+e})),e=e.replace(M,function(e){return t.push(+e),"{?}"}),t.unshift(e),t},U=function(e){var t,n={};for(t=0;e.keyFrames.length>t;t++)z(e.keyFrames[t],n);for(n={},t=e.keyFrames.length-1;t>=0;t--)z(e.keyFrames[t],n)},z=function(e,t){var n;for(n in t)u.call(e.props,n)||(e.props[n]=t[n]);for(n in e.props)t[n]=e.props[n]},W=function(e,t,n){if(e.length!==t.length)throw"Can't interpolate between \""+e[0]+'" and "'+t[0]+'"';for(var r=[e[0]],i=1;e.length>i;i++)r[i]=e[i]+(t[i]-e[i])*n;return r},X=function(e){var t=1;return _.lastIndex=0,e[0].replace(_,function(){return e[t++]})};o.setStyle=function(e,t,n){var r=e.style;if(t=t.replace(A,O).replace("-",""),"zIndex"===t)r[t]=""+(0|n);else if("float"===t)r.styleFloat=r.cssFloat=n;else try{x&&(r[x+t.slice(0,1).toUpperCase()+t.slice(1)]=n),r[t]=n}catch(i){}},o.addEvent=function(t,n,r){var i=function(t){return t=t||e.event,t.target||(t.target=t.srcElement),t.preventDefault||(t.preventDefault=function(){t.returnValue=!1}),r.call(this,t)};e.addEventListener?t.addEventListener(n,i,!1):t.attachEvent("on"+n,i)};var V,$,J,K,Q,G,Y,Z,et,tt=function(){ft=0,j(),et=!0,o.iscroll&&e.setTimeout(function(){o.iscroll.refresh()},0)},nt=function(){var e=Math.max(s.scrollHeight,s.offsetHeight,i.scrollHeight,i.offsetHeight,i.clientHeight);return e-i.clientHeight},rt=function(t){var n="className";return e.SVGElement&&t instanceof e.SVGElement&&(t=t[n],n="baseVal"),t[n]},it=function(t,r,i){var s="className";if(e.SVGElement&&t instanceof e.SVGElement&&(t=t[s],s="baseVal"),i===n)return t[s]=r,n;for(var o=t[s],u=0;r.length>u;u++)-1===ot(o).indexOf(ot(r[u]))&&(o+=" "+r[u]);for(var a=0;i.length>a;a++)o=ot(o).replace(ot(i[a])," ");t[s]=st(o)},st=function(e){return e.replace(N,"")},ot=function(e){return" "+e+" "},ut=Date.now||function(){return+(new Date)},at=function(e,t){return e.frame-t.frame},ft=0,lt=1,ct="down",ht=-1,pt=ut(),dt=0})(window,document);