Skip to content

Commit

Permalink
Fix reflow logic in flow layouts (#59)
Browse files Browse the repository at this point in the history
* Fix reflow logic

* fix typo
  • Loading branch information
ranjeshj committed Dec 10, 2018
1 parent 09c5545 commit 68a573b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions dev/Repeater/FlowLayoutAlgorithm.cpp
Expand Up @@ -52,12 +52,11 @@ winrt::Size FlowLayoutAlgorithm::Measure(
}

m_elementManager.OnBeginMeasure(orientation);
bool firstElementNotRealizedBefore = m_elementManager.GetRealizedElementCount() == 0 || m_elementManager.GetDataIndexFromRealizedRangeIndex(0) != 0;

int anchorIndex = GetAnchorIndex(availableSize, isWrapping, minItemSpacing, layoutId);
Generate(GenerateDirection::Forward, anchorIndex, availableSize, minItemSpacing, lineSpacing, layoutId);
Generate(GenerateDirection::Backward, anchorIndex, availableSize, minItemSpacing, lineSpacing, layoutId);
if (firstElementNotRealizedBefore && IsReflowRequired())
if (isWrapping && IsReflowRequired())
{
REPEATER_TRACE_INFO(L"%ls: \tReflow Pass \n", layoutId.data());
auto firstElementBounds = m_elementManager.GetLayoutBoundsForRealizedIndex(0);
Expand Down Expand Up @@ -364,8 +363,7 @@ void FlowLayoutAlgorithm::Generate(

bool FlowLayoutAlgorithm::IsReflowRequired() const
{
// Is the MinorStart of element for data index 0 at 0 ?
// For stack layout it will always be at 0, so this will always return false
// If first element is realized and is not at the very beginning we need to reflow.
return
m_elementManager.GetRealizedElementCount() > 0 &&
m_elementManager.GetDataIndexFromRealizedRangeIndex(0) == 0 &&
Expand Down Expand Up @@ -639,4 +637,4 @@ bool FlowLayoutAlgorithm::IsVirtualizingContext()
return false;
}

#pragma endregion
#pragma endregion

0 comments on commit 68a573b

Please sign in to comment.