mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-30 10:43:03 +00:00
fix the bug of Swiper
Signed-off-by: zhangrongjie <zhangrongjie4@huawei.com> Change-Id: I8f8dbe66482b3efe4f2cf44270bba24f3cdf2fa0
This commit is contained in:
parent
25081d9f08
commit
48d744d045
@ -194,7 +194,7 @@ RefPtr<LayoutAlgorithm> SwiperPattern::CreateLayoutAlgorithm()
|
||||
|
||||
void SwiperPattern::OnIndexChange()
|
||||
{
|
||||
auto totalCount = RealTotalCount();
|
||||
auto totalCount = TotalCount();
|
||||
if (NonPositive(totalCount)) {
|
||||
return;
|
||||
}
|
||||
@ -477,11 +477,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;
|
||||
}
|
||||
}
|
||||
int32_t maxValidIndex = IsLoop() ? RealTotalCount() : TotalCount() - GetDisplayCount() + 1;
|
||||
if (userSetCurrentIndex < 0 || userSetCurrentIndex >= maxValidIndex || GetDisplayCount() >= RealTotalCount()) {
|
||||
@ -1057,7 +1060,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