mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
Add support for native animations on iOS
Summary: Currently on iOS animations are being performed on the JS thread. This ports animations over to the native thread and performs them natively. A lot of this work has already been done on Android, but this PR enables a few animation nodes that Android doesn't yet support such as Transform, Multiplication, and Addition nodes. Also there is a demo of the native animations added to the UIExplorer app. Closes https://github.com/facebook/react-native/pull/7884 Differential Revision: D3401811 Pulled By: nicklockwood fbshipit-source-id: c8d750b75e4410923e17eaeb6dcaf079a09942e2
This commit is contained in:
committed by
Facebook Github Bot 4
parent
7357ccc370
commit
5ecdb252c3
@@ -74,16 +74,22 @@ var API = {
|
||||
var PROPS_WHITELIST = {
|
||||
style: {
|
||||
opacity: true,
|
||||
|
||||
transform: true,
|
||||
/* legacy android transform properties */
|
||||
scaleX: true,
|
||||
scaleY: true,
|
||||
rotation: true,
|
||||
translateX: true,
|
||||
translateY: true,
|
||||
},
|
||||
};
|
||||
|
||||
var TRANSFORM_WHITELIST = {
|
||||
translateX: true,
|
||||
translateY: true,
|
||||
scale: true,
|
||||
rotate: true,
|
||||
};
|
||||
|
||||
function validateProps(params: Object): void {
|
||||
for (var key in params) {
|
||||
if (!PROPS_WHITELIST.hasOwnProperty(key)) {
|
||||
@@ -92,6 +98,14 @@ function validateProps(params: Object): void {
|
||||
}
|
||||
}
|
||||
|
||||
function validateTransform(config: Object): void {
|
||||
for (var key in config) {
|
||||
if (!TRANSFORM_WHITELIST.hasOwnProperty(key)) {
|
||||
throw new Error(`Property '${key}' is not supported by native animated module`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateStyles(styles: Object): void {
|
||||
var STYLES_WHITELIST = PROPS_WHITELIST.style || {};
|
||||
for (var key in styles) {
|
||||
@@ -129,6 +143,7 @@ module.exports = {
|
||||
API,
|
||||
validateProps,
|
||||
validateStyles,
|
||||
validateTransform,
|
||||
validateInterpolation,
|
||||
generateNewNodeTag,
|
||||
generateNewAnimationId,
|
||||
|
||||
Reference in New Issue
Block a user