Skip to content

Commit

Permalink
Allow extending props supported by native animations
Browse files Browse the repository at this point in the history
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 71751e9
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions Libraries/Animated/src/NativeAnimatedHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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(
Expand Down Expand Up @@ -242,6 +255,9 @@ function shouldUseNativeDriver(config: AnimationConfig | EventConfig): boolean {

module.exports = {
API,
addWhitelistedStyleProp,
addWhitelistedTransformProp,
addWhitelistedInterpolationParam,
validateStyles,
validateTransform,
validateInterpolation,
Expand Down

0 comments on commit 71751e9

Please sign in to comment.