mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
!42540 Swiper: current index need to be adjusted when itemcount change
Merge pull request !42540 from Hu_zq/0904_master4
This commit is contained in:
commit
f9cc996583
@ -181,7 +181,7 @@ RefPtr<LayoutAlgorithm> SwiperPattern::CreateLayoutAlgorithm()
|
||||
|
||||
void SwiperPattern::OnIndexChange()
|
||||
{
|
||||
auto totalCount = RealTotalCount();
|
||||
auto totalCount = TotalCount();
|
||||
if (NonPositive(totalCount)) {
|
||||
return;
|
||||
}
|
||||
@ -472,11 +472,14 @@ void SwiperPattern::BeforeCreateLayoutWrapper()
|
||||
auto userSetCurrentIndex = CurrentIndex();
|
||||
userSetCurrentIndex = CheckUserSetIndex(userSetCurrentIndex);
|
||||
auto oldIndex = GetLoopIndex(oldIndex_);
|
||||
if (oldChildrenSize_.has_value() && oldChildrenSize_.value() != RealTotalCount()) {
|
||||
if (oldChildrenSize_.has_value() && oldChildrenSize_.value() != TotalCount()) {
|
||||
oldIndex = GetLoopIndex(oldIndex_, oldChildrenSize_.value());
|
||||
UpdateIndicatorOnChildChange();
|
||||
StartAutoPlay();
|
||||
InitArrow();
|
||||
if (IsLoop() && oldIndex != GetLoopIndex(currentIndex_)) {
|
||||
currentIndex_ = oldIndex >= TotalCount() ? 0 : oldIndex;
|
||||
}
|
||||
}
|
||||
auto index = CheckIndexRange(userSetCurrentIndex);
|
||||
if (index != userSetCurrentIndex) {
|
||||
@ -1055,7 +1058,7 @@ bool SwiperPattern::OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty,
|
||||
contentMainSize_ = algo->GetContentMainSize();
|
||||
crossMatchChild_ = algo->IsCrossMatchChild();
|
||||
oldIndex_ = currentIndex_;
|
||||
oldChildrenSize_ = RealTotalCount();
|
||||
oldChildrenSize_ = TotalCount();
|
||||
needFireCustomAnimationEvent_ = true;
|
||||
|
||||
if (windowSizeChangeReason_ == WindowSizeChangeReason::ROTATION) {
|
||||
|
Loading…
Reference in New Issue
Block a user