-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshifty.min.js
2 lines (2 loc) · 8.35 KB
/
shifty.min.js
1
2
/*! Shifty - v0.8.6 - 2013-03-02 - http://jeremyckahn.github.com/shifty */
(function(t){var t,n=function(){"use strict";function n(t,n){var e;for(e in t)Object.hasOwnProperty.call(t,e)&&n(e)}function e(t,e){return n(e,function(n){t[n]=e[n]}),t}function r(t,e){return n(e,function(n){t[n]===void 0&&(t[n]=e[n])}),t}function i(t,n,e,r,i,o,u){var s,c=(t-o)/i;for(s in n)n.hasOwnProperty(s)&&r.hasOwnProperty(s)&&(n[s]=a(e[s],r[s],l[u[s]],c));return n}function a(t,n,e,r){return t+(n-t)*e(r)}function o(t,e,r){var i=c.prototype.filter;n(i,function(n){i[n][e]&&i[n][e].apply(t,r)})}function u(t,n,e,r,a,s,c,h){var f=n+e,l=Math.min(p(),f),g=l>=f;t._isTweening&&(g||(t._loopId=setTimeout(function(){u(t,n,e,r,a,s,c,h)},1e3/t.fps)),o(t,"beforeTween",[r,a,s,c]),i(l,r,a,s,e,n,c),o(t,"afterTween",[r,a,s,c]),h&&h.call(r,r)),(g||!t._isTweening)&&t.stop(!0)}function s(t,e){var r={};return"string"==typeof e?n(t,function(t){r[t]=e}):n(t,function(t){r[t]||(r[t]=e[t]||h)}),r}function c(t){return t=t||{},this.data={},this._currentState=t.initialState||{},this.fps=t.fps||60,this._easing=t.easing||h,this}var h="linear",f=500,p=function(){return+new Date};c.prototype.tween=function(t,n,i,a,u){if(!this._isTweening){if(this._loopId=0,this._pausedAtTime=null,arguments.length>1)this._targetState=n||{},this._duration=i||f,this._callback=a,this._easing=u||h,this._currentState=t||{};else{var c=t;this._step=c.step,this._callback=c.callback,this._targetState=c.to||c.target||{},this._duration=c.duration||f,this._easing=c.easing||h,this._currentState=c.from||{}}this._timestamp=p();var l=this._currentState,g=this._targetState;r(l,g),r(g,l),this._easing=s(l,this._easing);var _=this._originalState=e({},l);return o(this,"tweenCreated",[l,_,g,this._easing]),this._isTweening=!0,this.resume(),t.start&&t.start(),this}},c.prototype.to=function(t,n,e,r){return 1===arguments.length?"to"in t?(t.from=this.get(),this.tween(t)):this.tween(this.get(),t):this.tween(this.get(),t,n,e,r),this},c.prototype.get=function(){return e({},this._currentState)},c.prototype.set=function(t){this._currentState=t},c.prototype.stop=function(t){return clearTimeout(this._loopId),this._isTweening=!1,t&&(e(this._currentState,this._targetState),o(this,"afterTweenEnd",[this._currentState,this._originalState,this._targetState,this._easing]),this._callback&&this._callback.call(this._currentState,this._currentState)),this},c.prototype.pause=function(){return clearTimeout(this._loopId),this._pausedAtTime=p(),this._isPaused=!0,this},c.prototype.resume=function(){return this._isPaused&&(this._timestamp+=p()-this._pausedAtTime),u(this,this._timestamp,this._duration,this._currentState,this._originalState,this._targetState,this._easing,this._step),this},c.prototype.filter={},e(c,{now:p,each:n,tweenProps:i,tweenProp:a,applyFilter:o,shallowCopy:e,defaults:r,composeEasingObject:s}),c.prototype.formula={linear:function(t){return t}};var l=c.prototype.formula;return"object"==typeof exports?module.exports=c:"function"==typeof define&&define.amd?define(function(){return c}):t.Tweenable===void 0&&(t.Tweenable=c),c}();(function(){n.shallowCopy(n.prototype.formula,{easeInQuad:function(t){return Math.pow(t,2)},easeOutQuad:function(t){return-(Math.pow(t-1,2)-1)},easeInOutQuad:function(t){return 1>(t/=.5)?.5*Math.pow(t,2):-.5*((t-=2)*t-2)},easeInCubic:function(t){return Math.pow(t,3)},easeOutCubic:function(t){return Math.pow(t-1,3)+1},easeInOutCubic:function(t){return 1>(t/=.5)?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)},easeInQuart:function(t){return Math.pow(t,4)},easeOutQuart:function(t){return-(Math.pow(t-1,4)-1)},easeInOutQuart:function(t){return 1>(t/=.5)?.5*Math.pow(t,4):-.5*((t-=2)*Math.pow(t,3)-2)},easeInQuint:function(t){return Math.pow(t,5)},easeOutQuint:function(t){return Math.pow(t-1,5)+1},easeInOutQuint:function(t){return 1>(t/=.5)?.5*Math.pow(t,5):.5*(Math.pow(t-2,5)+2)},easeInSine:function(t){return-Math.cos(t*(Math.PI/2))+1},easeOutSine:function(t){return Math.sin(t*(Math.PI/2))},easeInOutSine:function(t){return-.5*(Math.cos(Math.PI*t)-1)},easeInExpo:function(t){return 0===t?0:Math.pow(2,10*(t-1))},easeOutExpo:function(t){return 1===t?1:-Math.pow(2,-10*t)+1},easeInOutExpo:function(t){return 0===t?0:1===t?1:1>(t/=.5)?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return-(Math.sqrt(1-t*t)-1)},easeOutCirc:function(t){return Math.sqrt(1-Math.pow(t-1,2))},easeInOutCirc:function(t){return 1>(t/=.5)?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeOutBounce:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},easeInBack:function(t){var n=1.70158;return t*t*((n+1)*t-n)},easeOutBack:function(t){var n=1.70158;return(t-=1)*t*((n+1)*t+n)+1},easeInOutBack:function(t){var n=1.70158;return 1>(t/=.5)?.5*t*t*(((n*=1.525)+1)*t-n):.5*((t-=2)*t*(((n*=1.525)+1)*t+n)+2)},elastic:function(t){return-1*Math.pow(4,-8*t)*Math.sin((6*t-1)*2*Math.PI/2)+1},swingFromTo:function(t){var n=1.70158;return 1>(t/=.5)?.5*t*t*(((n*=1.525)+1)*t-n):.5*((t-=2)*t*(((n*=1.525)+1)*t+n)+2)},swingFrom:function(t){var n=1.70158;return t*t*((n+1)*t-n)},swingTo:function(t){var n=1.70158;return(t-=1)*t*((n+1)*t+n)+1},bounce:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},bouncePast:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?2-(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?2-(7.5625*(t-=2.25/2.75)*t+.9375):2-(7.5625*(t-=2.625/2.75)*t+.984375)},easeFromTo:function(t){return 1>(t/=.5)?.5*Math.pow(t,4):-.5*((t-=2)*Math.pow(t,3)-2)},easeFrom:function(t){return Math.pow(t,4)},easeTo:function(t){return Math.pow(t,.25)}})})(),function(){function t(t,e,r,i,a){return n.tweenProps(i,e,t,r,1,0,a)}n.interpolate=function(e,r,i,a){var o,u,s;e&&e.from&&(r=e.to,i=e.position,a=e.easing,e=e.from),s=new n,s.easing=a||"linear",o=n.shallowCopy({},e);var c=n.composeEasingObject(e,s.easing);return n.applyFilter(s,"tweenCreated",[o,e,r,c]),n.applyFilter(s,"beforeTween",[o,e,r,c]),u=t(e,o,r,i,c),n.applyFilter(s,"afterTween",[u,e,r,c]),u},n.prototype.interpolate=function(t,e,r){var i;return i=n.interpolate(this.get(),t,e,r),this.set(i),i}}(),function(t){function n(t,n){var e,r=t.length,i=[];for(e=0;r>e;e++)i.push("_"+n+"_"+e);return i}function e(t){var n=t.match(d);return 1===n.length&&n.unshift(""),n.join(k)}function r(n){t.each(n,function(t){var e=n[t];"string"==typeof e&&e.match(b)&&(n[t]=i(e))})}function i(t){return s(b,t,a)}function a(t){var n=o(t);return"rgb("+n[0]+","+n[1]+","+n[2]+")"}function o(t){return t=t.replace(/#/,""),3===t.length&&(t=t.split(""),t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),[u(t.substr(0,2)),u(t.substr(2,2)),u(t.substr(4,2))]}function u(t){return parseInt(t,16)}function s(t,n,e){var r=n.match(t),i=n.replace(t,k);if(r)for(var a,o=r.length,u=0;o>u;u++)a=r.shift(),i=i.replace(k,e(a));return i}function c(t){return s(I,t,h)}function h(t){for(var n=t.match(y),e=n.length,r=t.match(S)[0],i=0;e>i;i++)r+=parseInt(n[i],10)+",";return r=r.slice(0,-1)+")"}function f(r){var i={};return t.each(r,function(t){var a=r[t];if("string"==typeof a){var o=m(a);i[t]={formatString:e(a),chunkNames:n(o,t)}}}),i}function p(n,e){t.each(e,function(t){for(var r=n[t],i=m(r),a=i.length,o=0;a>o;o++)n[e[t].chunkNames[o]]=+i[o];delete n[t]})}function l(n,e){t.each(e,function(t){var r=n[t],i=g(n,e[t].chunkNames),a=_(i,e[t].chunkNames);r=w(e[t].formatString,a),n[t]=c(r)})}function g(t,n){for(var e,r={},i=n.length,a=0;i>a;a++)e=n[a],r[e]=t[e],delete t[e];return r}function _(t,n){for(var e=[],r=n.length,i=0;r>i;i++)e.push(t[n[i]]);return e}function w(t,n){for(var e=t,r=n.length,i=0;r>i;i++)e=e.replace(k,+n[i].toFixed(4));return e}function m(t){return t.match(y)}function v(n,e){t.each(e,function(t){for(var r=e[t],i=r.chunkNames,a=i.length,o=n[t].split(" "),u=o[o.length-1],s=0;a>s;s++)n[i[s]]=o[s]||u;delete n[t]})}function M(n,e){t.each(e,function(t){for(var r=e[t],i=r.chunkNames,a=i.length,o="",u=0;a>u;u++)o+=" "+n[i[u]],delete n[i[u]];o=o.substr(1),n[t]=o})}var d=/([^\-0-9\.]+)/g,y=/[0-9.\-]+/g,I=RegExp("rgb\\("+y.source+/,\s*/.source+y.source+/,\s*/.source+y.source+"\\)","g"),S=/^.*\(/,b=/#([0-9]|[a-f]){3,6}/g,k="VAL";t.prototype.filter.token={tweenCreated:function(t,n,e){r(t),r(n),r(e),this._tokenData=f(t)},beforeTween:function(t,n,e,r){v(r,this._tokenData),p(t,this._tokenData),p(n,this._tokenData),p(e,this._tokenData)},afterTween:function(t,n,e,r){l(t,this._tokenData),l(n,this._tokenData),l(e,this._tokenData),M(r,this._tokenData)}}}(n)})(this);