/
thomas.min.js
9 lines (9 loc) · 3.73 KB
/
thomas.min.js
1
2
3
4
5
6
7
8
9
function thomas2(){function e(a,b,c){return a.substr(b,c||1)}function m(a){var b=i.props.length,c={};for(a=a.currentStyle?a.currentStyle:document.defaultView.getComputedStyle(a,null);b--;)c[i.props[b]]=a[i.props[b]];return c}function h(a,b,c){return(a+(b-a)*c).toFixed(3)}function k(a,b,c){for(var g=2,f,d,j=[],n=[];f=3,d=arguments[g-1],g--;)if(e(d,0)=="r")for(d=d.match(/\d+/g);f--;)j.push(~~d[f]);else{if(d.length==4)d="#"+e(d,1)+e(d,1)+e(d,2)+e(d,2)+e(d,3)+e(d,3);for(;f--;)j.push(parseInt(e(d,1+f*
2,2),16))}for(;f--;){g=~~(j[f+3]+(j[f]-j[f+3])*c);n.push(g<0?0:g>255?255:g)}return"rgb("+n.join(",")+")"}function p(a,b){var c=m(a),g=i.props.length,f={source:{},target:{}};if(b.indexOf(":")==-1){b=b.replace(/\./g," ");var d=a.className;a.className+=" "+b;b=m(a);a.className=d}else{l.innerHTML='<div style="'+b+'"></div>';b=l.firstChild.style}for(;g--;){a=i.props[g];if(c[a]!=b[a]){d=o(a,c[a]);var j=o(a,b[a]);if(d&&j){f.source[a]=d;f.target[a]=j}}}return f}function o(a,b){try{var c=parseFloat(b),g=b.replace(/^[\-\d\.]+/,
"")}catch(f){return null}return a.match(/color/i)?{v:g,interpolate:k,u:""}:isNaN(c)?null:{v:c,interpolate:h,u:g}}var i=this,l=document.createElement("div");this.props="backgroundColor borderBottomColor borderBottomWidth borderLeftColor borderLeftWidth borderRightColor borderRightWidth borderSpacing borderTopColor borderTopWidth bottom color fontSize fontWeight height left letterSpacing lineHeight marginBottom marginLeft marginRight marginTop maxHeight maxWidth minHeight minWidth opacity outlineColor outlineOffset outlineWidth paddingBottom paddingLeft paddingRight paddingTop right textIndent top width wordSpacing zIndex".split(" ");
this.after=function(a){a.animated=null;if(a.after){try{a.after()}catch(b){throw b;}a.after=null}a.queue&&a.queue.length&&thomas.apply(i,a.queue.pop())};this.animate=function(a,b,c,g){var f=+new Date,d=f+c;a.interval=setInterval(function(){var j=+new Date,n=j>d?1:(j-f)/c;for(prop in b.source)a.style[prop]=b.source[prop].interpolate(b.source[prop].v,b.target[prop].v,g(n))+b.source[prop].u;if(j>d){clearInterval(a.interval);i.after(a)}},10)};this.timing=function(a){return thomas2.prototype.transitions[a]||
a};return function(a,b,c){c=typeof c=="function"?{after:c}:c||{};var g=c.link||"cancel",f=c.duration||200,d=i.timing(c.easing||"ease-in-out");if(a.animated){if(g=="ignore")return;if(g=="chain"){if(!a.queue)a.queue=[];return a.queue.push([a,b,c])}}a.animated=true;a.after=c.after;b=p(a,b);i.animate(a,b,f,d)}}
thomas2.prototype.transitions={linear:function(e){return e},"ease-in":function(e){return-Math.cos(e*(Math.PI/2))+1},"ease-out":function(e){return Math.sin(e*(Math.PI/2))},"ease-in-out":function(e){return-0.5*(Math.cos(Math.PI*e)-1)}};
function thomas3(){var e=this,m=thomas2.call(this);"BackgroundSize BorderTopLeftRadius BorderTopRightRadius BorderBottomLeftRadius BorderBottomRightRadius BoxShadow TextFillColor TextStrokeColor TransformOriginX TransformOriginY TransformOriginZ".split(" ").forEach(function(h){e.props.push("webkit"+h)});document.addEventListener("webkitTransitionEnd",function(h){if(el=h.target||h.srcElement)e.after(el)});this.animate=function(h,k,p,o){var i=[],l=targetText="",a;for(prop in k.target){a=prop.replace(/[A-Z]/g,
function(b){return"-"+b.charAt(0).toLowerCase()});if(a.match(/^webkit/))a="-"+a;i.push(a+" "+p+"ms "+o);l+=";"+a+":"+k.source[prop].v+k.source[prop].u;targetText+=";"+a+":"+k.target[prop].v+k.target[prop].u}h.style.webkitTransitionDuration="";h.style.cssText+=l;setTimeout(function(){h.style.webkitTransition=i.join(",");h.style.cssText+=targetText},0.01)};this.timing=function(h){var k=thomas3.prototype.transitions[h];return typeof h=="function"?"ease":k?"cubic-bezier("+k+")":h};return m}
thomas3.prototype.transitions={};window.thomas=!window.WebKitCSSMatrix?new thomas2:new thomas3;