From cd585deca73d22de66fb60cab2c3dc1e08fce3e6 Mon Sep 17 00:00:00 2001 From: Tianer Zhou Date: Sun, 9 Jun 2024 11:44:09 +0800 Subject: [PATCH] use existing postJumpOffset for extra jump offset Signed-off-by: Tianer Zhou Change-Id: I7ad87c2ee658afb804bcb6b11a3b8b56a0b92580 --- .gitee/CODEOWNERS | 1 + .../core/components_ng/pattern/grid/grid_pattern.cpp | 1 + .../grid/irregular/grid_irregular_layout_algorithm.cpp | 8 ++++---- .../layout/top_down/water_flow_segmented_layout.cpp | 10 +++++----- .../pattern/waterflow/water_flow_pattern.cpp | 1 + 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.gitee/CODEOWNERS b/.gitee/CODEOWNERS index 275ba6f6f328..ad9021c12af8 100644 --- a/.gitee/CODEOWNERS +++ b/.gitee/CODEOWNERS @@ -91,6 +91,7 @@ frameworks/core/components_ng/pattern/form/ @arondave @arcticsun frameworks/core/components_ng/pattern/gauge/ @Hu_ZeQi frameworks/core/components_ng/pattern/gesture/ @zheng-qiyi frameworks/core/components_ng/pattern/grid/ @zcdqs +frameworks/core/components_ng/pattern/grid/irregular/ @zhoutianer frameworks/core/components_ng/pattern/grid_col/ @xiexiyun frameworks/core/components_ng/pattern/grid_container/ @xiexiyun frameworks/core/components_ng/pattern/grid_row/ @xiexiyun diff --git a/frameworks/core/components_ng/pattern/grid/grid_pattern.cpp b/frameworks/core/components_ng/pattern/grid/grid_pattern.cpp index 4d858b97f226..ea4ab0a2cabe 100644 --- a/frameworks/core/components_ng/pattern/grid/grid_pattern.cpp +++ b/frameworks/core/components_ng/pattern/grid/grid_pattern.cpp @@ -411,6 +411,7 @@ bool GridPattern::OnDirtyLayoutWrapperSwap(const RefPtr& dirty, c } ProcessEvent(indexChanged, gridLayoutInfo_.currentHeight_ - gridLayoutInfo_.prevHeight_); gridLayoutInfo_.prevHeight_ = gridLayoutInfo_.currentHeight_; + gridLayoutInfo_.extraOffset_.reset(); SetScrollSource(SCROLL_FROM_NONE); UpdateScrollBarOffset(); if (config.frameSizeChange) { diff --git a/frameworks/core/components_ng/pattern/grid/irregular/grid_irregular_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/grid/irregular/grid_irregular_layout_algorithm.cpp index d90dfdc480b0..8d7d65ae3924 100644 --- a/frameworks/core/components_ng/pattern/grid/irregular/grid_irregular_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/grid/irregular/grid_irregular_layout_algorithm.cpp @@ -50,10 +50,6 @@ void GridIrregularLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper) gridLayoutInfo_.currentOffset_ = postJumpOffset_; MeasureOnOffset(mainSize); } - if (gridLayoutInfo_.extraOffset_.has_value()) { - gridLayoutInfo_.currentOffset_ += gridLayoutInfo_.extraOffset_.value(); - gridLayoutInfo_.extraOffset_.reset(); - } } else { MeasureOnOffset(mainSize); } @@ -119,6 +115,10 @@ void GridIrregularLayoutAlgorithm::Init(const RefPtr& props) info.crossCount_ = static_cast(crossLens_.size()); CheckForReset(); + + if (info.extraOffset_) { + postJumpOffset_ += *info.extraOffset_; + } } namespace { diff --git a/frameworks/core/components_ng/pattern/waterflow/layout/top_down/water_flow_segmented_layout.cpp b/frameworks/core/components_ng/pattern/waterflow/layout/top_down/water_flow_segmented_layout.cpp index 8cf049b5fe5a..0218eda051f5 100644 --- a/frameworks/core/components_ng/pattern/waterflow/layout/top_down/water_flow_segmented_layout.cpp +++ b/frameworks/core/components_ng/pattern/waterflow/layout/top_down/water_flow_segmented_layout.cpp @@ -22,8 +22,8 @@ #include "core/components_ng/base/frame_node.h" #include "core/components_ng/layout/layout_wrapper.h" #include "core/components_ng/pattern/waterflow/layout/top_down/water_flow_layout_info.h" -#include "core/components_ng/pattern/waterflow/water_flow_layout_property.h" #include "core/components_ng/pattern/waterflow/layout/water_flow_layout_utils.h" +#include "core/components_ng/pattern/waterflow/water_flow_layout_property.h" #include "core/components_ng/pattern/waterflow/water_flow_pattern.h" #include "core/components_ng/pattern/waterflow/water_flow_sections.h" #include "core/components_ng/property/calc_length.h" @@ -178,6 +178,10 @@ void WaterFlowSegmentedLayout::Init(const SizeF& frameSize) if (!wrapper_->IsConstraintNoChanged()) { postJumpOffset_ = PrepareJump(info_); } + + if (info_->extraOffset_) { + postJumpOffset_ += *info_->extraOffset_; + } } void WaterFlowSegmentedLayout::SegmentInit( @@ -334,10 +338,6 @@ void WaterFlowSegmentedLayout::MeasureOnJump(int32_t jumpIdx) info_->align_ = TransformAutoScroll(item); } info_->currentOffset_ = SolveJumpOffset(item) + postJumpOffset_; - if (info_->extraOffset_.has_value()) { - info_->currentOffset_ += info_->extraOffset_.value(); - info_->extraOffset_.reset(); - } Fill(jumpIdx); info_->Sync(mainSize_, false); diff --git a/frameworks/core/components_ng/pattern/waterflow/water_flow_pattern.cpp b/frameworks/core/components_ng/pattern/waterflow/water_flow_pattern.cpp index 6e3fd807eceb..61c2d168f313 100644 --- a/frameworks/core/components_ng/pattern/waterflow/water_flow_pattern.cpp +++ b/frameworks/core/components_ng/pattern/waterflow/water_flow_pattern.cpp @@ -262,6 +262,7 @@ bool WaterFlowPattern::OnDirtyLayoutWrapperSwap(const RefPtr& dir prevOffset_ = layoutInfo_->Offset(); layoutInfo_->jumpIndex_ = EMPTY_JUMP_INDEX; layoutInfo_->targetIndex_.reset(); + layoutInfo_->extraOffset_.reset(); UpdateScrollBarOffset(); CheckScrollable();