Allow extending props supported by native animations
Reviewed By: sahrens Differential Revision: D6523618 fbshipit-source-id: 547ed7ab1a92f01a18006241d7a74af9cac25c58
This commit is contained in:
parent
434f432d5d
commit
71751e9cc7
|
@ -169,6 +169,26 @@ const TRANSFORM_WHITELIST = {
|
||||||
perspective: true,
|
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 {
|
function validateTransform(configs: Array<Object>): void {
|
||||||
configs.forEach(config => {
|
configs.forEach(config => {
|
||||||
if (!TRANSFORM_WHITELIST.hasOwnProperty(config.property)) {
|
if (!TRANSFORM_WHITELIST.hasOwnProperty(config.property)) {
|
||||||
|
@ -192,13 +212,6 @@ function validateStyles(styles: Object): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateInterpolation(config: 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) {
|
for (var key in config) {
|
||||||
if (!SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(key)) {
|
if (!SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(key)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
@ -242,6 +255,9 @@ function shouldUseNativeDriver(config: AnimationConfig | EventConfig): boolean {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
API,
|
API,
|
||||||
|
addWhitelistedStyleProp,
|
||||||
|
addWhitelistedTransformProp,
|
||||||
|
addWhitelistedInterpolationParam,
|
||||||
validateStyles,
|
validateStyles,
|
||||||
validateTransform,
|
validateTransform,
|
||||||
validateInterpolation,
|
validateInterpolation,
|
||||||
|
|
Loading…
Reference in New Issue