Permalink
Browse files

Allow extending props supported by native animations

Reviewed By: sahrens

Differential Revision: D6523618

fbshipit-source-id: 547ed7ab1a92f01a18006241d7a74af9cac25c58
  • Loading branch information...
andrewimm authored and facebook-github-bot committed Dec 13, 2017
1 parent 434f432 commit 71751e9cc7c67306ca038c5b254e6e81fe0aff1b
Showing with 23 additions and 7 deletions.
  1. +23 −7 Libraries/Animated/src/NativeAnimatedHelper.js
@@ -169,6 +169,26 @@ const TRANSFORM_WHITELIST = {
perspective: true,
};
const SUPPORTED_INTERPOLATION_PARAMS = {
inputRange: true,
outputRange: true,
extrapolate: true,
extrapolateRight: true,
extrapolateLeft: true,
};
function addWhitelistedStyleProp(prop: string): void {
STYLES_WHITELIST[prop] = true;
}
function addWhitelistedTransformProp(prop: string): void {
TRANSFORM_WHITELIST[prop] = true;
}
function addWhitelistedInterpolationParam(param: string): void {
SUPPORTED_INTERPOLATION_PARAMS[param] = true;
}
function validateTransform(configs: Array<Object>): void {
configs.forEach(config => {
if (!TRANSFORM_WHITELIST.hasOwnProperty(config.property)) {
@@ -192,13 +212,6 @@ function validateStyles(styles: Object): void {
}
function validateInterpolation(config: Object): void {
var SUPPORTED_INTERPOLATION_PARAMS = {
inputRange: true,
outputRange: true,
extrapolate: true,
extrapolateRight: true,
extrapolateLeft: true,
};
for (var key in config) {
if (!SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(key)) {
throw new Error(
@@ -242,6 +255,9 @@ function shouldUseNativeDriver(config: AnimationConfig | EventConfig): boolean {
module.exports = {
API,
addWhitelistedStyleProp,
addWhitelistedTransformProp,
addWhitelistedInterpolationParam,
validateStyles,
validateTransform,
validateInterpolation,

0 comments on commit 71751e9

Please sign in to comment.