-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebkit.tweener.min.js
1 lines (1 loc) · 4.28 KB
/
webkit.tweener.min.js
1
jQuery.fn.doTween=function(a){a=jQuery.extend({time:1,transition:"linear",callback:function(b){},keyframes:{}},a);$(this).attr("is_tweening",true);this.each(function(){var l=new Date().getTime();var m="<style id='style_"+l+"' class='webkit_style'>";m+="@-webkit-keyframes 'tweener_"+l+"' {";for(var n in a.keyframes){m+=n+" { ";for(var c in a.keyframes[n]){if(c=="transform"){m+="-webkit-transform: ";var k="";var e=[];var f=[];current_transform=$(this).css("-webkit-transform");if(current_transform!="none"){f=current_transform.split(" ").sort()}for(var d in a.keyframes[n][c]){e.push(d+"("+a.keyframes[n][c][d]+")")}for(var h in f){var b=false;for(var g in e){if(f[h].split("(")[0]==e[g].split("(")[0]){b=true}}if(b==false){e.push(f[h])}}e.sort();for(var h in e){m+=e[h]+" ";k+=e[h]+" "}m+=";";$(this).css("-webkit-transform",k)}else{$(this).css(c,a.keyframes[n][c]);m+=c+": "+a.keyframes[n][c]+"; "}}m+="}"}m+="}";m+="</style>";jQuery(this).bind("webkitAnimationEnd",function(i){$("#style_"+l).remove();$(this).attr("is_tweening",false);a.callback(this);this.style.removeProperty("-webkit-animation-name");this.style.removeProperty("-webkit-animation-duration");this.style.removeProperty("-webkit-transition-timing-function");i.stopPropagation();$(this).unbind("webkitAnimationEnd")});$("head").append(m);$(this).css({"-webkit-animation-name":"tweener_"+l,"-webkit-animation-duration":a.time+"s","-webkit-transition-timing-function":"'"+a.transition+"'"})});return jQuery(this)};jQuery.fn.isTweening=function(){return(jQuery(this).attr("is_tweening")=="true")};jQuery.fn.removeAllTweens=function(){$(".webkit_style").remove()};jQuery.fn.alphaTo=function(c,b,d,e){var a=function(f){if(e!==undefined){e()}$(f).css("display",(c==0)?"none":"block")};if(c>0){$(this).css("display","block")}$(this).doTween({time:b,transition:d,callback:a,keyframes:{from:{"-webkit-transform-style":"preserve-3d",opacity:$(this).css("opacity")},to:{"-webkit-transform-style":"preserve-3d",opacity:c}}});return jQuery(this)};jQuery.fn.slideTo=function(b,a,c,d,e){$(this).doTransform({translateX:b+"px",translateY:a+"px"},{translateX:"0px",translateY:"0px"},c,d,e);return jQuery(this)};jQuery.fn.glowTo=function(b,a,c,d,e){$(this).doTween({time:c,transition:d,callback:e,keyframes:{from:{"-webkit-box-shadow":$(this).css("-webkit-box-shadow")},to:{"-webkit-box-shadow":"0px 0px "+b+"px "+a}}});return jQuery(this)};jQuery.fn.doTransform=function(b,a,c,d,e){$(this).doTween({time:c,transition:d,callback:e,keyframes:{from:{"-webkit-transform":$(this).lastTransformOr(a)},to:{transform:b}}});return jQuery(this)};jQuery.fn.rotate=function(a,b,c,d){$(this).doTransform({rotate:a+"deg"},{rotate:"0deg"},b,c,d);return jQuery(this)};jQuery.fn.rotateX=function(a,b,c,d){$(this).doTransform({rotateX:a+"deg"},{rotateX:"0deg"},b,c,d);return jQuery(this)};jQuery.fn.rotateY=function(a,b,c,d){$(this).doTransform({rotateY:a+"deg"},{rotateY:"0deg"},b,c,d);return jQuery(this)};jQuery.fn.scale=function(c,a,b,d){$(this).doTransform({scale:c},{scale:1},a,b,d);return jQuery(this)};jQuery.fn.scaleX=function(c,a,b,d){$(this).doTransform({scaleX:c},{scaleX:1},a,b,d);return jQuery(this)};jQuery.fn.scaleY=function(c,a,b,d){$(this).doTransform({scaleY:c},{scaleY:1},a,b,d);return jQuery(this)};jQuery.fn.skew=function(a,b,c,d){$(this).doTransform({skew:a+"deg"},{skew:"0deg"},b,c,d);return jQuery(this)};jQuery.fn.skewX=function(a,b,c,d){$(this).doTransform({skewX:a+"deg"},{skewY:"0deg"},b,c,d);return jQuery(this)};jQuery.fn.skewY=function(a,b,c,d){$(this).doTransform({skewX:a+"deg"},{skewY:"0deg"},b,c,d);return jQuery(this)};jQuery.fn.lastTransformOr=function(e){var d="";var g=$(this).css("-webkit-transform");if(g!="none"){var f=g.split(" ").sort();var b=false;for(var a in e){for(var c in f){if(f[c].split("(")[0]==a){b=true}}if(!b){f.push(a+"("+e[a]+")")}}f.sort();for(var c in f){d+=f[c]+" "}}else{d="none"}return d};jQuery.fn.growX=function(a,b,c,d){$(this).doTween({time:b,transition:c,callback:d,keyframes:{from:{"-webkit-transform-style":"preserve-3d",width:$(this).css("width")},to:{"-webkit-transform-style":"preserve-3d",width:a}}});return jQuery(this)};jQuery.fn.growY=function(a,b,c,d){$(this).doTween({time:b,transition:c,callback:d,keyframes:{from:{"-webkit-transform-style":"preserve-3d",height:$(this).css("height")},to:{"-webkit-transform-style":"preserve-3d",height:a}}});return jQuery(this)};