多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] # 插件-ease 缓动函数 从jquery-ease中抄的,很不错的缓动库,可以在`v.ani`中使用 ## 动画类型 * easeInSine * easeOutSine * easeInOutSine * easeInCirc * easeOutCirc * easeInOutCirc * easeInElastic * easeOutElastic * easeInOutElastic * easeInBack * easeOutBack * easeInOutBack * easeInBounce * easeOutBounce * easeInOutBounce * easeInQuad * easeOutQuad * easeInOutQuad * easeInCubic * easeOutCubic * easeInOutCubic * easeInQuart * easeOutQuart * easeInOutQuart * easeInQuint * easeOutQuint * easeInOutQuint * easeInExpo * easeOutExpo * easeInOutExpo * linear ## 源码 ```javascript var easings = (function() { var eases = {}; var names = ['Quad', 'Cubic', 'Quart', 'Quint', 'Expo']; var functions = { Sine: function(t) { return 1 - Math.cos(t * Math.PI / 2); }, Circ: function(t) { return 1 - Math.sqrt(1 - t * t); }, Elastic: function(t, m) { if (t === 0 || t === 1) return t; var p = (1 - Math.min(m, 998) / 1000), st = t / 1, st1 = st - 1, s = p / (2 * Math.PI) * Math.asin(1); return -(Math.pow(2, 10 * st1) * Math.sin((st1 - s) * (2 * Math.PI) / p)); }, Back: function(t) { return t * t * (3 * t - 2); }, Bounce: function(t) { var pow2, bounce = 4; while (t < ((pow2 = Math.pow(2, --bounce)) - 1) / 11) {} return 1 / Math.pow(4, 3 - bounce) - 7.5625 * Math.pow((pow2 * 3 - 2) / 22 - t, 2); } } names.forEach(function(name, i) { functions[name] = function(t) { return Math.pow(t, i + 2); } }); Object.keys(functions).forEach(function(name) { var easeIn = functions[name]; eases['easeIn' + name] = easeIn; eases['easeOut' + name] = function(t, m) { return 1 - easeIn(1 - t, m); }; eases['easeInOut' + name] = function(t, m) { return t < 0.5 ? easeIn(t * 2, m) / 2 : 1 - easeIn(t * -2 + 2, m) / 2; }; }); eases.linear = function(t) { return t; }; return eases; })(); ```