Skip to content

Commit c577dfd

Browse files
bodymovinphilter
andcommitted
Prevent layout animation on Artboards just added to ArtboardHosts (#11548) f16f751405
* Prevent layout animation on List items just added to List * Rebaseline silvers Co-authored-by: Philip Chung <philterdesign@gmail.com>
1 parent 4bcd8fc commit c577dfd

7 files changed

Lines changed: 28 additions & 1 deletion

File tree

.rive_head

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e86db167edbb949225333e31aa06915a29dfc67e
1+
f16f751405686bab7f51b16131af210b1bf1cee8

include/rive/artboard.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class Artboard : public ArtboardBase,
138138
void updateDataBinds(bool applyTargetToSource = true) override;
139139
void host(ArtboardHost* artboardHost);
140140
ArtboardHost* host() const;
141+
void addedToHost() { m_justAddedToHost = true; }
141142

142143
// Implemented for ShapePaintContainer.
143144
const Mat2D& shapeWorldTransform() const override

include/rive/layout_component.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class LayoutComponent : public LayoutComponentBase,
118118
ShapePaintPath m_localPath;
119119
ShapePaintPath m_worldPath;
120120
DrawableProxy m_proxy;
121+
bool m_justAddedToHost = false;
121122

122123
Artboard* getArtboard() override { return artboard(); }
123124
LayoutAnimationData* currentAnimationData();

src/artboard.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,7 @@ void Artboard::cloneObjectDataBinds(const Core* object,
869869
}
870870
void Artboard::host(ArtboardHost* artboardHost)
871871
{
872+
addedToHost();
872873
m_host = artboardHost;
873874
#ifdef WITH_RIVE_LAYOUT
874875
if (!sharesLayoutWithHost())

src/layout_component.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,30 @@ void LayoutComponent::updateLayoutBounds(bool animate)
10271027
Layout newLayout = layoutFromYoga(yogaLayout);
10281028
m_layoutPadding = layoutPaddingFromYoga(yogaLayout);
10291029

1030+
if (m_justAddedToHost)
1031+
{
1032+
m_justAddedToHost = false;
1033+
// In cases were we have a host (ie, Component List, etc), we
1034+
// don't want to animate the x/y/width/height because the initial
1035+
// x/y/width/height will have been 0,0,0,0 within the parent host.
1036+
//
1037+
// Instead, we want to the position/size to start at whatever this
1038+
// layout's computed position is within its host.
1039+
//
1040+
// We'll keep this as an entirely seperate code path because
1041+
// this may be useful in adding support for animate in/out of
1042+
// items in an ArtboardHost.
1043+
m_layout = newLayout;
1044+
auto animationData = currentAnimationData();
1045+
animationData->from = newLayout;
1046+
animationData->to = newLayout;
1047+
animationData->elapsedSeconds = 0.0f;
1048+
propagateSize();
1049+
markWorldTransformDirty();
1050+
m_forceUpdateLayoutBounds = false;
1051+
return;
1052+
}
1053+
10301054
if (animate && animates())
10311055
{
10321056
auto animationData = currentAnimationData();
285 Bytes
Binary file not shown.
95 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)