Files
react-native/ReactCommon/react/renderer/components/view/ViewComponentDescriptor.h
T
Joshua Gross 907b574cf6 LayoutAnimations: change default prop interpolation on Android: set new non-interpolated prop values at beginning of animation, not end
Summary:
In Android, only changed prop values are sent to the mounting layer via folly::dynamic maps. In the LayoutAnimation system, before this, we only sent that
map at the /end/ of the animation for any non-interpolated values (for example, image source is not interpolated so it was not updated until the end of the animation).

However, what we probably expect is that all non-interpolated values change immediately, and interpolated values smoothly transition. This diff makes that change on Android
by using the final RawProps as the /initial/ value that interpolations are stacked on.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25727483

fbshipit-source-id: e692d37b9965fedcdf429a81d60b7cb7f0c6abe1
2020-12-29 15:54:45 -08:00

47 lines
1.3 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <react/renderer/components/view/ViewShadowNode.h>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include "ViewProps.h"
#include "ViewPropsInterpolation.h"
namespace facebook {
namespace react {
class ViewComponentDescriptor
: public ConcreteComponentDescriptor<ViewShadowNode> {
public:
ViewComponentDescriptor(ComponentDescriptorParameters const &parameters)
: ConcreteComponentDescriptor<ViewShadowNode>(parameters) {}
virtual SharedProps interpolateProps(
float animationProgress,
const SharedProps &props,
const SharedProps &newProps) const override {
#ifdef ANDROID
// On Android only, the merged props should have the same RawProps as the
// final props struct
SharedProps interpolatedPropsShared =
(newProps != nullptr ? cloneProps(newProps, newProps->rawProps)
: cloneProps(newProps, {}));
#else
SharedProps interpolatedPropsShared = cloneProps(newProps, {});
#endif
interpolateViewProps(
animationProgress, props, newProps, interpolatedPropsShared);
return interpolatedPropsShared;
};
};
} // namespace react
} // namespace facebook