Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable animating transform matrix #36935

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ const SUPPORTED_TRANSFORMS = {
rotateY: true,
rotateZ: true,
perspective: true,
matrix: ReactNativeFeatureFlags.shouldUseAnimatedObjectForTransform(),
};

const SUPPORTED_INTERPOLATION_PARAMS = {
Expand All @@ -451,19 +452,19 @@ function addWhitelistedInterpolationParam(param: string): void {
}

function isSupportedColorStyleProp(prop: string): boolean {
return SUPPORTED_COLOR_STYLES.hasOwnProperty(prop);
return SUPPORTED_COLOR_STYLES[prop] === true;
}

function isSupportedStyleProp(prop: string): boolean {
return SUPPORTED_STYLES.hasOwnProperty(prop);
return SUPPORTED_STYLES[prop] === true;
}

function isSupportedTransformProp(prop: string): boolean {
return SUPPORTED_TRANSFORMS.hasOwnProperty(prop);
return SUPPORTED_TRANSFORMS[prop] === true;
}

function isSupportedInterpolationParam(param: string): boolean {
return SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(param);
return SUPPORTED_INTERPOLATION_PARAMS[param] === true;
}

function validateTransform(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import type {PlatformConfig} from '../AnimatedPlatformConfig';

import ReactNativeFeatureFlags from '../../ReactNative/ReactNativeFeatureFlags';
import flattenStyle from '../../StyleSheet/flattenStyle';
import Platform from '../../Utilities/Platform';
import NativeAnimatedHelper from '../NativeAnimatedHelper';
Expand All @@ -30,7 +31,10 @@ function createAnimatedStyle(
for (const key in style) {
const value = style[key];
if (key === 'transform') {
animatedStyles[key] = new AnimatedTransform(value);
animatedStyles[key] =
ReactNativeFeatureFlags.shouldUseAnimatedObjectForTransform()
? new AnimatedObject(value)
: new AnimatedTransform(value);
} else if (value instanceof AnimatedNode) {
animatedStyles[key] = value;
} else if (hasAnimatedNode(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export type FeatureFlags = {|
* Enables access to the host tree in Fabric using DOM-compatible APIs.
*/
enableAccessToHostTreeInFabric: () => boolean,
/**
* Enables use of AnimatedObject for animating transform values.
*/
shouldUseAnimatedObjectForTransform: () => boolean,
|};

const ReactNativeFeatureFlags: FeatureFlags = {
Expand All @@ -55,6 +59,7 @@ const ReactNativeFeatureFlags: FeatureFlags = {
animatedShouldUseSingleOp: () => false,
isGlobalWebPerformanceLoggerEnabled: () => false,
enableAccessToHostTreeInFabric: () => false,
shouldUseAnimatedObjectForTransform: () => false,
};

module.exports = ReactNativeFeatureFlags;