-
Notifications
You must be signed in to change notification settings - Fork 0
/
move.min.js
1 lines (1 loc) · 6.83 KB
/
move.min.js
1
!function(e,t){function n(e,t){return"transform"===t?e.style[t]:t?document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(e,null)[t]:e.currentStyle?e.currentStyle[t]:e.style[t]:document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(e,null):e.currentStyle?e.currentStyle:e.style}function a(e,t){var n="";for(var a in t)if(o.indexOf(a)+1)if("backgroundSize"===a)e.style[a]=t[a]+"%";else if(a.indexOf("scale")+1){n=a+"("+t[a]+")";var u=new RegExp("\\s?"+a+"\\([\\w\\W]+?\\)","g");e.style.transform=(e.style.transform||"").replace(u,"")+n}else e.style[a]=t[a];else if(r.deg.indexOf(a)+1){n=a+"("+t[a]+"deg)";var u=new RegExp("\\s?"+a+"\\([\\w\\W]+?\\)","g");e.style.transform=(e.style.transform||"").replace(u,"")+n}else if(r.px.indexOf(a)+1){n=a+"("+t[a]+"px)";var u=new RegExp("\\s?"+a+"\\([\\w\\W]+?\\)","g");e.style.transform=(e.style.transform||"").replace(u,"")+n}else e.style[a]=t[a]+"px"}var r={all:["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective"],px:["translateX","translateY","translateZ","perspective"],deg:["rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],none:["scale","scaleX","scaleY","scaleZ"]},o=["opacity","backgroundSize"].concat(r.none),u=Math.TWEEN={linear:function(e,t,n,a){return n*e/a+t},easeInQuad:function(e,t,n,a){return n*(e/=a)*e+t},easeOutQuad:function(e,t,n,a){return-n*(e/=a)*(e-2)+t},easeInOutQuad:function(e,t,n,a){return(e/=a/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t},easeInCubic:function(e,t,n,a){return n*(e/=a)*e*e+t},easeOutCubic:function(e,t,n,a){return n*((e=e/a-1)*e*e+1)+t},easeInOutCubic:function(e,t,n,a){return(e/=a/2)<1?n/2*e*e*e+t:n/2*((e-=2)*e*e+2)+t},easeInQuart:function(e,t,n,a){return n*(e/=a)*e*e*e+t},easeOutQuart:function(e,t,n,a){return-n*((e=e/a-1)*e*e*e-1)+t},easeInOutQuart:function(e,t,n,a){return(e/=a/2)<1?n/2*e*e*e*e+t:-n/2*((e-=2)*e*e*e-2)+t},easeInQuint:function(e,t,n,a){return n*(e/=a)*e*e*e*e+t},easeOutQuint:function(e,t,n,a){return n*((e=e/a-1)*e*e*e*e+1)+t},easeInOutQuint:function(e,t,n,a){return(e/=a/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t},easeInSine:function(e,t,n,a){return-n*Math.cos(e/a*(Math.PI/2))+n+t},easeOutSine:function(e,t,n,a){return n*Math.sin(e/a*(Math.PI/2))+t},easeInOutSine:function(e,t,n,a){return-n/2*(Math.cos(Math.PI*e/a)-1)+t},easeInExpo:function(e,t,n,a){return 0==e?t:n*Math.pow(2,10*(e/a-1))+t},easeOutExpo:function(e,t,n,a){return e==a?t+n:n*(-Math.pow(2,-10*e/a)+1)+t},easeInOutExpo:function(e,t,n,a){return 0==e?t:e==a?t+n:(e/=a/2)<1?n/2*Math.pow(2,10*(e-1))+t:n/2*(-Math.pow(2,-10*--e)+2)+t},easeInCirc:function(e,t,n,a){return-n*(Math.sqrt(1-(e/=a)*e)-1)+t},easeOutCirc:function(e,t,n,a){return n*Math.sqrt(1-(e=e/a-1)*e)+t},easeInOutCirc:function(e,t,n,a){return(e/=a/2)<1?-n/2*(Math.sqrt(1-e*e)-1)+t:n/2*(Math.sqrt(1-(e-=2)*e)+1)+t},easeInElastic:function(e,t,n,a,r,o){var u=void 0;return 0==e?t:1==(e/=a)?t+n:("undefined"==typeof o&&(o=.3*a),!r||r<Math.abs(n)?(u=o/4,r=n):u=o/(2*Math.PI)*Math.asin(n/r),-(r*Math.pow(2,10*(e-=1))*Math.sin((e*a-u)*(2*Math.PI)/o))+t)},easeOutElastic:function(e,t,n,a,r,o){var u=void 0;return 0==e?t:1==(e/=a)?t+n:("undefined"==typeof o&&(o=.3*a),!r||r<Math.abs(n)?(r=n,u=o/4):u=o/(2*Math.PI)*Math.asin(n/r),r*Math.pow(2,-10*e)*Math.sin((e*a-u)*(2*Math.PI)/o)+n+t)},easeInOutElastic:function(e,t,n,a,r,o){var u=void 0;return 0==e?t:2==(e/=a/2)?t+n:("undefined"==typeof o&&(o=a*(.3*1.5)),!r||r<Math.abs(n)?(r=n,u=o/4):u=o/(2*Math.PI)*Math.asin(n/r),e<1?-.5*(r*Math.pow(2,10*(e-=1))*Math.sin((e*a-u)*(2*Math.PI)/o))+t:r*Math.pow(2,-10*(e-=1))*Math.sin((e*a-u)*(2*Math.PI)/o)*.5+n+t)},easeInBack:function(e,t,n,a,r){return"undefined"==typeof r&&(r=1.70158),n*(e/=a)*e*((r+1)*e-r)+t},easeOutBack:function(e,t,n,a,r){return"undefined"==typeof r&&(r=1.70158),n*((e=e/a-1)*e*((r+1)*e+r)+1)+t},easeInOutBack:function(e,t,n,a,r){return"undefined"==typeof r&&(r=1.70158),(e/=a/2)<1?n/2*(e*e*(((r*=1.525)+1)*e-r))+t:n/2*((e-=2)*e*(((r*=1.525)+1)*e+r)+2)+t},easeInBounce:function(e,t,n,a){return n-u.easeOutBounce(a-e,0,n,a)+t},easeOutBounce:function(e,t,n,a){return(e/=a)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t},easeInOutBounce:function(e,t,n,a){return e<a/2?.5*u.easeInBounce(2*e,0,n,a)+t:.5*u.easeOutBounce(2*e-a,0,n,a)+.5*n+t}};!function(){for(var t=0,n=["webkit","moz"],a=0;a<n.length&&!e.requestAnimationFrame;++a)e.requestAnimationFrame=e[n[a]+"RequestAnimationFrame"],e.cancelAnimationFrame=e[n[a]+"CancelAnimationFrame"]||e[n[a]+"CancelRequestAnimationFrame"];e.requestAnimationFrame||(e.requestAnimationFrame=function(n,a){var r=(new Date).getTime(),o=Math.max(0,16.7-(r-t)),u=e.setTimeout(function(){n(r+o)},o);return t=r+o,u}),e.cancelAnimationFrame||(e.cancelAnimationFrame=function(e){clearTimeout(e)})}();var i=function(){var t=function(e,t){function o(){u++;var t={};for(var n in h)t[n]=s(u,c[n],h[n]-c[n],i);a(e,t),u<i&&requestAnimationFrame(o),u===i&&"function"==typeof l&&l()}if(!(e instanceof HTMLElement))return"move(): 第一个参数必须为 DOM 元素";for(var u=0,i=Math.ceil(400/16.67),c={},s=Math.TWEEN.linear,l=null,f=arguments.length,p=Array(f>2?f-2:0),d=2;d<f;d++)p[d-2]=arguments[d];for(var m in p)"number"==typeof p[m]&&p[m]>0&&(i=Math.ceil(p[m]/16.67)),"string"==typeof p[m]&&p[m]in Math.TWEEN&&(s=Math.TWEEN[p[m]]),"function"==typeof p[m]&&(l=p[m]);var h=function(){var a={};for(var o in t){if(("number"==typeof t[o]||/[-]?(\d+|\d*\.\d*)/.test(t[o]))&&(a[o]=parseFloat(t[o]),r.all.indexOf(o)+1||(c[o]=parseFloat(n(e,o)))),"backgroundSize"===o){var u=n(e,o);"auto"===u?c[o]=100:c[o]=parseFloat(u.replace("%","")),a[o]=t[o].toString().indexOf("%")+1?parseFloat(t[o].replace("%","")):100*parseFloat(t[o])}if(r.all.indexOf(o)+1){var i=(n(e,"transform")||"").replace(/\)/g,"").split(/\(|\s+/),s=i.indexOf(o);c[o]=parseFloat(i[s+1])||(o.indexOf("scale")+1?1:0)}}return a}();o()};return t.scroll=function(t){function n(){a++;var c=u(a,o,t-o,r);document.body.scrollTop+1?document.body.scrollTop=c:e.scrollY=c,a<r&&requestAnimationFrame(n),a===r&&"function"==typeof i&&i()}for(var a=0,r=Math.ceil(400/16.67),o=document.body.scrollTop||e.scrollY,u=Math.TWEEN.linear,i=null,c=arguments.length,s=Array(c>1?c-1:0),l=1;l<c;l++)s[l-1]=arguments[l];for(var f in s)"number"==typeof s[f]&&(r=Math.ceil(s[f]/16.67)),"string"==typeof s[f]&&s[f]in Math.TWEEN&&(u=Math.TWEEN[s[f]]),"function"==typeof s[f]&&(i=s[f]);n()},t.each=function(e,n){for(var a=arguments.length,r=Array(a>2?a-2:0),o=2;o<a;o++)r[o-2]=arguments[o];var u=null,i=0;for(var c in r)"function"==typeof r[c]&&(u=r.splice(c,1)[0]);if(e.length>=1){var s=Array.prototype.slice.call(e);for(var l in s)t.apply(null,[s[l],n].concat(r).concat(function(){i++,i===e.length&&"function"==typeof u&&u()}))}else{if(!e)return!1;t.apply(null,[e,n].concat(r).concat(u))}},t}();e.move=i}(window);