Skip to content

Commit 71751e9

Browse files
andrewimmfacebook-github-bot
authored andcommitted
Allow extending props supported by native animations
Reviewed By: sahrens Differential Revision: D6523618 fbshipit-source-id: 547ed7ab1a92f01a18006241d7a74af9cac25c58
1 parent 434f432 commit 71751e9

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

Libraries/Animated/src/NativeAnimatedHelper.js

+23-7
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,26 @@ const TRANSFORM_WHITELIST = {
169169
perspective: true,
170170
};
171171

172+
const SUPPORTED_INTERPOLATION_PARAMS = {
173+
inputRange: true,
174+
outputRange: true,
175+
extrapolate: true,
176+
extrapolateRight: true,
177+
extrapolateLeft: true,
178+
};
179+
180+
function addWhitelistedStyleProp(prop: string): void {
181+
STYLES_WHITELIST[prop] = true;
182+
}
183+
184+
function addWhitelistedTransformProp(prop: string): void {
185+
TRANSFORM_WHITELIST[prop] = true;
186+
}
187+
188+
function addWhitelistedInterpolationParam(param: string): void {
189+
SUPPORTED_INTERPOLATION_PARAMS[param] = true;
190+
}
191+
172192
function validateTransform(configs: Array<Object>): void {
173193
configs.forEach(config => {
174194
if (!TRANSFORM_WHITELIST.hasOwnProperty(config.property)) {
@@ -192,13 +212,6 @@ function validateStyles(styles: Object): void {
192212
}
193213

194214
function validateInterpolation(config: Object): void {
195-
var SUPPORTED_INTERPOLATION_PARAMS = {
196-
inputRange: true,
197-
outputRange: true,
198-
extrapolate: true,
199-
extrapolateRight: true,
200-
extrapolateLeft: true,
201-
};
202215
for (var key in config) {
203216
if (!SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(key)) {
204217
throw new Error(
@@ -242,6 +255,9 @@ function shouldUseNativeDriver(config: AnimationConfig | EventConfig): boolean {
242255

243256
module.exports = {
244257
API,
258+
addWhitelistedStyleProp,
259+
addWhitelistedTransformProp,
260+
addWhitelistedInterpolationParam,
245261
validateStyles,
246262
validateTransform,
247263
validateInterpolation,

0 commit comments

Comments
 (0)