From 71751e9cc7c67306ca038c5b254e6e81fe0aff1b Mon Sep 17 00:00:00 2001 From: Andrew Imm Date: Wed, 13 Dec 2017 13:34:58 -0800 Subject: [PATCH] Allow extending props supported by native animations Reviewed By: sahrens Differential Revision: D6523618 fbshipit-source-id: 547ed7ab1a92f01a18006241d7a74af9cac25c58 --- .../Animated/src/NativeAnimatedHelper.js | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Libraries/Animated/src/NativeAnimatedHelper.js b/Libraries/Animated/src/NativeAnimatedHelper.js index ab7c7df15fff64..6bebbe427cb50e 100644 --- a/Libraries/Animated/src/NativeAnimatedHelper.js +++ b/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): 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,