Skip to content

Commit

Permalink
fix(ohos): fix pager change index bug (#4198)
Browse files Browse the repository at this point in the history
  • Loading branch information
etkmao authored Feb 26, 2025
1 parent 8d08f29 commit 733dd75
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class PagerView : public BaseView, public SwiperNodeDelegate {
std::shared_ptr<PagerItemAdapter> adapter_;

int32_t initialPage_ = 0;
bool initialPageUsed_ = false;
int32_t index_ = 0;
float prevMargin_ = 0;
float nextMargin_ = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,13 @@ void PagerView::DestroyArkUINodeImpl() {
swiperNode_->ResetLazyAdapter();
swiperNode_ = nullptr;
adapter_.reset();
initialPageUsed_ = false;
}

bool PagerView::SetPropImpl(const std::string &propKey, const HippyValue &propValue) {
if (propKey == "initialPage") {
if (!initialPageUsed_) {
initialPageUsed_ = true;
initialPage_ = HRValueUtils::GetInt32(propValue);
index_ = initialPage_;
GetLocalRootArkUINode()->SetSwiperIndex(index_);
}
initialPage_ = HRValueUtils::GetInt32(propValue);
index_ = initialPage_;
GetLocalRootArkUINode()->SetSwiperIndex(index_);
return true;
} else if (propKey == "scrollEnabled") {
bool enable = HRValueUtils::GetBool(propValue, true);
Expand Down

0 comments on commit 733dd75

Please sign in to comment.