Skip to content
Merged
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
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Animate value property rather than offset",
"packageName": "react-native-windows",
"email": "erozell@outlook.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ AnimationDriver::~AnimationDriver() {
void AnimationDriver::StartAnimation() {
const auto [animation, scopedBatch] = MakeAnimation(m_config);
if (auto const animatedValue = GetAnimatedValue()) {
animatedValue->PropertySet().StartAnimation(ValueAnimatedNode::s_offsetName, animation);
animatedValue->PropertySet().StartAnimation(ValueAnimatedNode::s_valueName, animation);
animatedValue->AddActiveAnimation(m_id);
}
scopedBatch.End();
Expand All @@ -58,7 +58,6 @@ void AnimationDriver::StartAnimation() {
if (auto manager = weakManager.lock()) {
if (auto const animatedValue = manager->GetValueAnimatedNode(tag)) {
animatedValue->RemoveActiveAnimation(id);
animatedValue->FlattenOffset();
}
manager->RemoveActiveAnimation(id);
}
Expand All @@ -70,7 +69,7 @@ void AnimationDriver::StartAnimation() {

void AnimationDriver::StopAnimation(bool ignoreCompletedHandlers) {
if (const auto animatedValue = GetAnimatedValue()) {
animatedValue->PropertySet().StopAnimation(ValueAnimatedNode::s_offsetName);
animatedValue->PropertySet().StopAnimation(ValueAnimatedNode::s_valueName);
if (!ignoreCompletedHandlers) {
animatedValue->RemoveActiveAnimation(m_id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ std::tuple<comp::CompositionAnimation, comp::CompositionScopedBatch> CalculatedA
std::chrono::milliseconds duration(static_cast<int>(keyFrames.size() / 60.0f * 1000.0f));
animation.Duration(duration);
auto normalizedProgress = 0.0f;
// We are animating the values offset property which should start at 0.
animation.InsertKeyFrame(normalizedProgress, 0.0f, easingFunction);
auto fromValue = static_cast<float>(GetAnimatedValue()->RawValue());
animation.InsertKeyFrame(normalizedProgress, fromValue, easingFunction);
for (const auto keyFrame : keyFrames) {
normalizedProgress = std::min(normalizedProgress + 1.0f / keyFrames.size(), 1.0f);
animation.InsertKeyFrame(normalizedProgress, keyFrame - static_cast<float>(m_startValue), easingFunction);
animation.InsertKeyFrame(normalizedProgress, keyFrame, easingFunction);
}

if (m_iterations == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ std::tuple<comp::CompositionAnimation, comp::CompositionScopedBatch> FrameAnimat
auto fromValue = GetAnimatedValue()->RawValue();
for (auto frame : m_frames) {
normalizedProgress = std::min(normalizedProgress += step, 1.0f);
animation.InsertKeyFrame(normalizedProgress, static_cast<float>(frame * (m_toValue - fromValue)));
animation.InsertKeyFrame(normalizedProgress, static_cast<float>(fromValue + frame * (m_toValue - fromValue)));
}

if (m_iterations == -1) {
Expand Down