Updates from Tue 17 Mar

- [ReactNative] Remove pushNotification prop from renderApplication | Eric Vicenti
- [react_native] Stub VibrationIOS on Android | Andy Street
- [ReactNative] Simplify and test interpolators | Christopher Chedeau
- [ReactNative] Increase timeout for obj-c tests | Christopher Chedeau
- [ReactNative] Updated RKText to new UIManager system | Nick Lockwood
- [ReactNative] Unforked RCTShadowView, moved RKTextView into FBReactKitTextModule | Nick Lockwood
- [ReactKit] Remove NativeModulesDeprecated | Spencer Ahrens
- [ReactNative] Allow single callbacks in NativeModules | Spencer Ahrens
- [ReactNative] s/RK/RCT in OSS | Spencer Ahrens
- [ReactNative] Cleanup StyleSheet API | Christopher Chedeau
- [RCTVibration] Basic Vibration API | Christopher Chedeau
- [React Native] Prevent crash in redbox code with two thrown errors | Ben Alpert
- [ReactNative] unbreak Android | Andrew Rasmussen
This commit is contained in:
Christopher Chedeau
2015-03-17 13:42:44 -07:00
parent 299dea8594
commit f7cf017d29
77 changed files with 937 additions and 530 deletions

View File

@@ -8,197 +8,191 @@
type EasingFunction = (t: number) => number;
var b = 0,
c = 1,
d = 1;
var defaults = {
easeInQuad: function(t) {
return c * (t /= 1) * t + b;
return t * t;
},
easeOutQuad: function(t) {
return -c * (t /= d) * (t - 2) + b;
return -t * (t - 2);
},
easeInOutQuad: function(t) {
if ((t /= d / 2) < 1) {
return c / 2 * t * t + b;
t = t * 2;
if (t < 1) {
return 0.5 * t * t;
}
return -c / 2 * ((--t) * (t - 2) - 1) + b;
return -((t - 1) * (t - 3) - 1) / 2;
},
easeInCubic: function(t) {
return c * (t /= d) * t * t + b;
return t * t * t;
},
easeOutCubic: function(t) {
return c * ((t = t / d - 1) * t * t + 1) + b;
t -= 1;
return t * t * t + 1;
},
easeInOutCubic: function(t) {
if ((t /= d / 2) < 1) {
return c / 2 * t * t * t + b;
t *= 2;
if (t < 1) {
return 0.5 * t * t * t;
}
return c / 2 * ((t -= 2) * t * t + 2) + b;
t -= 2;
return (t * t * t + 2) / 2;
},
easeInQuart: function(t) {
return c * (t /= d) * t * t * t + b;
return t * t * t * t;
},
easeOutQuart: function(t) {
return -c * ((t = t / d - 1) * t * t * t - 1) + b;
t -= 1;
return -(t * t * t * t - 1);
},
easeInOutQuart: function(t) {
if ((t /= d / 2) < 1) {
return c / 2 * t * t * t * t + b;
t *= 2;
if (t < 1) {
return 0.5 * t * t * t * t;
}
return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
t -= 2;
return -(t * t * t * t - 2) / 2;
},
easeInQuint: function(t) {
return c * (t /= d) * t * t * t * t + b;
return t * t * t * t * t;
},
easeOutQuint: function(t) {
return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
t -= 1;
return t * t * t * t * t + 1;
},
easeInOutQuint: function(t) {
if ((t /= d / 2) < 1) {
return c / 2 * t * t * t * t * t + b;
t *= 2;
if (t < 1) {
return (t * t * t * t * t) / 2;
}
return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
t -= 2;
return (t * t * t * t * t + 2) / 2;
},
easeInSine: function(t) {
return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
return -Math.cos(t * (Math.PI / 2)) + 1;
},
easeOutSine: function(t) {
return c * Math.sin(t / d * (Math.PI / 2)) + b;
return Math.sin(t * (Math.PI / 2));
},
easeInOutSine: function(t) {
return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
return -(Math.cos(Math.PI * t) - 1) / 2;
},
easeInExpo: function(t) {
return (t === 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
return (t === 0) ? 0 : Math.pow(2, 10 * (t - 1));
},
easeOutExpo: function(t) {
return (t === d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
return (t === 1) ? 1 : (-Math.pow(2, -10 * t) + 1);
},
easeInOutExpo: function(t) {
if (t === 0) {
return b;
return 0;
}
if (t === d) {
return b + c;
if (t === 1) {
return 1;
}
if ((t /= d / 2) < 1) {
return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
t *= 2;
if (t < 1) {
return 0.5 * Math.pow(2, 10 * (t - 1));
}
return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
return (-Math.pow(2, -10 * (t - 1)) + 2) / 2;
},
easeInCirc: function(t) {
return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
return -(Math.sqrt(1 - t * t) - 1);
},
easeOutCirc: function(t) {
return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
t -= 1;
return Math.sqrt(1 - t * t);
},
easeInOutCirc: function(t) {
if ((t /= d / 2) < 1) {
return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
t *= 2;
if (t < 1) {
return -(Math.sqrt(1 - t * t) - 1) / 2;
}
return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
t -= 2;
return (Math.sqrt(1 - t * t) + 1) / 2;
},
easeInElastic: function(t) {
var s = 1.70158;
var p = 0;
var a = c;
var p = 0.3;
if (t === 0) {
return b;
return 0;
}
if ((t /= d) === 1) {
return b + c;
if (t === 1) {
return 1;
}
if (!p) {
p = d * 0.3;
}
if (a < Math.abs(c)) {
a = c;
var s = p / 4;
} else {
var s = p / (2 * Math.PI) * Math.asin(c / a);
}
return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
var s = p / (2 * Math.PI) * Math.asin(1);
t -= 1;
return -(Math.pow(2, 10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p));
},
easeOutElastic: function(t) {
var s = 1.70158;
var p = 0;
var a = c;
var p = 0.3;
if (t === 0) {
return b;
return 0;
}
if ((t /= d) === 1) {
return b + c;
if (t === 1) {
return 1;
}
if (!p) {
p = d * 0.3;
}
if (a < Math.abs(c)) {
a = c;
var s = p / 4;
} else {
var s = p / (2 * Math.PI) * Math.asin(c / a);
}
return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
var s = p / (2 * Math.PI) * Math.asin(1);
return Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) + 1;
},
easeInOutElastic: function(t) {
var s = 1.70158;
var p = 0;
var a = c;
var p = 0.3 * 1.5;
if (t === 0) {
return b;
return 0;
}
if ((t /= d / 2) === 2) {
return b + c;
}
if (!p) {
p = d * (0.3 * 1.5);
}
if (a < Math.abs(c)) {
a = c;
var s = p / 4;
} else {
var s = p / (2 * Math.PI) * Math.asin(c / a);
t *= 2;
if (t === 2) {
return 1;
}
var s = p / (2 * Math.PI) * Math.asin(1);
if (t < 1) {
return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
t -= 1;
return -(Math.pow(2, 10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)) / 2;
}
return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * 0.5 + c + b;
t -= 1;
return Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) / 2 + 1;
},
easeInBack: function(t) {
var s = 1.70158;
return c * (t /= d) * t * ((s + 1) * t - s) + b;
return t * t * ((s + 1) * t - s);
},
easeOutBack: function(t) {
var s = 1.70158;
return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
t -= 1;
return (t * t * ((s + 1) * t + s) + 1);
},
easeInOutBack: function(t) {
var s = 1.70158;
if ((t /= d / 2) < 1) {
return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
var s = 1.70158 * 1.525;
t *= 2;
if (t < 1) {
return (t * t * ((s + 1) * t - s)) / 2;
}
return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
t -= 2;
return (t * t * ((s + 1) * t + s) + 2) / 2;
},
easeInBounce: function(t) {
return c - this.easeOutBounce(d - t) + b;
return 1 - this.easeOutBounce(1 - t);
},
easeOutBounce: function(t) {
if ((t /= d) < (1 / 2.75)) {
return c * (7.5625 * t * t) + b;
if (t < (1 / 2.75)) {
return 7.5625 * t * t;
} else if (t < (2 / 2.75)) {
return c * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75) + b;
t -= 1.5 / 2.75;
return 7.5625 * t * t + 0.75;
} else if (t < (2.5 / 2.75)) {
return c * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375) + b;
t -= 2.25 / 2.75;
return 7.5625 * t * t + 0.9375;
} else {
return c * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375) + b;
t -= 2.625 / 2.75;
return 7.5625 * t * t + 0.984375;
}
},
easeInOutBounce: function(t) {
if (t < d / 2) {
return this.easeInBounce(t * 2) * 0.5 + b;
if (t < 0.5) {
return this.easeInBounce(t * 2) / 2;
}
return this.easeOutBounce(t * 2 - d) * 0.5 + c * 0.5 + b;
return this.easeOutBounce(t * 2 - 1) / 2 + 0.5;
},
};