Skip to content

Commit

Permalink
chore: adjust scrollposition of content on initial render
Browse files Browse the repository at this point in the history
  • Loading branch information
azimgd committed Nov 17, 2024
1 parent ac354a4 commit 0a1e41e
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "SLContainerShadowNode.h"
#include <iostream>

#define MEASURE_CHILDREN(childrenMeasurements, childNodeMetrics, isHorizontal) \
if (isHorizontal) { \
Expand Down Expand Up @@ -66,6 +65,7 @@ SLFenwickTree SLContainerShadowNode::calculateChildrenMeasurements(const Concret

Point SLContainerShadowNode::calculateScrollPosition(const ConcreteStateData prevStateData, const ConcreteStateData nextStateData) {
auto &props = getConcreteProps();
bool isFirstRender = prevStateData.childrenMeasurements.size() == 0 && nextStateData.childrenMeasurements.size() > 0;

float verticalPosition;
float horizontalPosition;
Expand Down Expand Up @@ -95,6 +95,10 @@ Point SLContainerShadowNode::calculateScrollPosition(const ConcreteStateData pre
horizontalPosition = nextStateData.scrollContent.width - prevStateData.scrollContent.width + nextStateData.scrollPosition.x;
}
verticalPosition = 0;

if (isFirstRender) {
horizontalPosition = 0;
}
} else {
horizontalPosition = 0;

Expand All @@ -103,6 +107,10 @@ Point SLContainerShadowNode::calculateScrollPosition(const ConcreteStateData pre
} else {
verticalPosition = nextStateData.scrollContent.height - prevStateData.scrollContent.height + nextStateData.scrollPosition.y;
}

if (isFirstRender) {
verticalPosition = 0;
}
}
}

Expand Down

0 comments on commit 0a1e41e

Please sign in to comment.