diff --git a/.gitee/CODEOWNERS b/.gitee/CODEOWNERS index c44de4fc9b1..2e436d0e956 100644 --- a/.gitee/CODEOWNERS +++ b/.gitee/CODEOWNERS @@ -150,6 +150,7 @@ frameworks/core/components_ng/pattern/root/ @zhoutianer frameworks/core/components_ng/pattern/scroll/ @rongShao-Z frameworks/core/components_ng/pattern/scroll_bar/ @rongShao-Z frameworks/core/components_ng/pattern/scrollable/ @yeyinglong_admin +frameworks/core/components_ng/pattern/scrollable/nestabe_scroll_container.h @zhoutianer frameworks/core/components_ng/pattern/search/ @jyj_0306 frameworks/core/components_ng/pattern/security_component/ @ frameworks/core/components_ng/pattern/select/ @fredtt diff --git a/frameworks/core/components_ng/pattern/scrollable/nestable_scroll_container.h b/frameworks/core/components_ng/pattern/scrollable/nestable_scroll_container.h index 57e51f17eee..b7760160007 100644 --- a/frameworks/core/components_ng/pattern/scrollable/nestable_scroll_container.h +++ b/frameworks/core/components_ng/pattern/scrollable/nestable_scroll_container.h @@ -142,7 +142,7 @@ public: { isNestedInterrupt_ = isNestedInterrupt; } - + bool GetIsNestedInterrupt() const { return isNestedInterrupt_; @@ -170,7 +170,7 @@ private: bool isFixedNestedScrollMode_ = false; bool isSearchRefresh_ = true; - bool isNestedInterrupt_ = false; + bool isNestedInterrupt_ = false; // nested scroll interrupted by change of nested mode }; } // namespace OHOS::Ace::NG #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SCROLLABLE_NESTABLE_SCROLL_CONTAINER_H diff --git a/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp b/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp index bd963ef74b4..b1f222f1804 100644 --- a/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp +++ b/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp @@ -1830,8 +1830,7 @@ void SwiperPattern::StopSpringAnimationImmediately() }); PerfMonitor::GetPerfMonitor()->End(PerfConstants::APP_LIST_FLING, false); AceAsyncTraceEnd(0, TRAILING_ANIMATION); - TAG_LOGI(AceLogTag::ACE_SWIPER, "Swiper finish spring animation offset %{public}f", - currentIndexOffset_); + TAG_LOGI(AceLogTag::ACE_SWIPER, "Swiper finish spring animation offset %{public}f", currentIndexOffset_); ACE_SCOPED_TRACE("Swiper finish spring animation offset %f", currentIndexOffset_); isTouchDownSpringAnimation_ = false; OnSpringAndFadeAnimationFinish(); @@ -2686,7 +2685,6 @@ void SwiperPattern::HandleDragStart(const GestureEvent& info) mainDeltaSum_ = 0.0f; // in drag process, close lazy feature. SetLazyLoadFeature(false); - StopFadeAnimation(); } void SwiperPattern::StopAnimationOnScrollStart(bool flushImmediately) @@ -2697,6 +2695,7 @@ void SwiperPattern::StopAnimationOnScrollStart(bool flushImmediately) StopIndicatorAnimation(); StopTranslateAnimation(); + StopFadeAnimation(); if (flushImmediately) { StopSpringAnimationAndFlushImmediately(); } else { @@ -4191,15 +4190,16 @@ void SwiperPattern::SetDigitStartAndEndProperty(const RefPtr& indicat CHECK_NULL_VOID(swiperDigitalParameters); bool isRtl = GetNonAutoLayoutDirection() == TextDirection::RTL; if (swiperDigitalParameters->dimStart.has_value()) { - auto dimValue = swiperDigitalParameters->dimStart.value().Value() >= 0.0 ? - swiperDigitalParameters->dimStart.value() : Dimension(0.0, DimensionUnit::VP); + auto dimValue = swiperDigitalParameters->dimStart.value().Value() >= 0.0 + ? swiperDigitalParameters->dimStart.value() + : Dimension(0.0, DimensionUnit::VP); isRtl ? layoutProperty->UpdateRight(dimValue) : layoutProperty->UpdateLeft(dimValue); isRtl ? swiperLayoutProperty->UpdateRight(dimValue) : swiperLayoutProperty->UpdateLeft(swiperDigitalParameters->dimLeft.value_or(0.0_vp)); ; } else if (swiperDigitalParameters->dimEnd.has_value()) { - auto dimValue = swiperDigitalParameters->dimEnd.value().Value() >= 0.0 ? - swiperDigitalParameters->dimEnd.value() : Dimension(0.0, DimensionUnit::VP); + auto dimValue = swiperDigitalParameters->dimEnd.value().Value() >= 0.0 ? swiperDigitalParameters->dimEnd.value() + : Dimension(0.0, DimensionUnit::VP); isRtl ? layoutProperty->UpdateLeft(dimValue) : layoutProperty->UpdateRight(dimValue); isRtl ? swiperLayoutProperty->UpdateLeft(dimValue) : swiperLayoutProperty->UpdateRight(swiperDigitalParameters->dimRight.value_or(0.0_vp)); @@ -4977,7 +4977,7 @@ void SwiperPattern::OnScrollEndRecursive(const std::optional& velocity) return; } // in case child didn't call swiper's HandleScrollVelocity - if (!AnimationRunning()) { + if (!DuringTranslateAnimation()) { HandleDragEnd(velocity.value_or(0.0f)); } SetIsNestedInterrupt(false); @@ -4994,10 +4994,9 @@ void SwiperPattern::NotifyParentScrollEnd() } } -inline bool SwiperPattern::AnimationRunning() const +inline bool SwiperPattern::DuringTranslateAnimation() const { - return (controller_ && controller_->IsRunning()) || (springAnimation_ && springAnimationIsRunning_) || - (fadeAnimation_ && fadeAnimationIsRunning_) || targetIndex_ || usePropertyAnimation_; + return (springAnimation_ && springAnimationIsRunning_) || targetIndex_ || usePropertyAnimation_; } bool SwiperPattern::HandleScrollVelocity(float velocity, const RefPtr& child) @@ -5031,7 +5030,7 @@ ScrollResult SwiperPattern::HandleScroll(float offset, int32_t source, NestedSta if (IsDisableSwipe()) { return { offset, true }; } - if (source == SCROLL_FROM_ANIMATION && AnimationRunning()) { + if (source == SCROLL_FROM_ANIMATION && DuringTranslateAnimation()) { // deny conflicting animation from child return { offset, true }; } @@ -5589,8 +5588,8 @@ bool SwiperPattern::ContentWillChange(int32_t currentIndex, int32_t comingIndex) CHECK_NULL_RETURN(tabBarNode, true); auto tabBarPattern = tabBarNode->GetPattern(); CHECK_NULL_RETURN(tabBarPattern, true); - if (!tabBarPattern->GetTabContentWillChangeFlag() && - tabsPattern->GetInterceptStatus() && currentIndex != comingIndex) { + if (!tabBarPattern->GetTabContentWillChangeFlag() && tabsPattern->GetInterceptStatus() && + currentIndex != comingIndex) { tabBarPattern->ResetTabContentWillChangeFlag(); auto ret = tabsPattern->OnContentWillChange(currentIndex, comingIndex); return ret.has_value() ? ret.value() : true; diff --git a/frameworks/core/components_ng/pattern/swiper/swiper_pattern.h b/frameworks/core/components_ng/pattern/swiper/swiper_pattern.h index 601c724876d..d5ebbdd81a6 100644 --- a/frameworks/core/components_ng/pattern/swiper/swiper_pattern.h +++ b/frameworks/core/components_ng/pattern/swiper/swiper_pattern.h @@ -777,11 +777,9 @@ private: */ void StopAnimationOnScrollStart(bool flushImmediately); /** - * @brief Checks if the animation is currently running. - * - * @return true if the animation is running, false otherwise. + * @return true if any translate animation (switching page / spring) is running, false otherwise. */ - inline bool AnimationRunning() const; + inline bool DuringTranslateAnimation() const; /** * NestableScrollContainer implementations diff --git a/test/unittest/core/pattern/swiper/swiper_event_test_ng.cpp b/test/unittest/core/pattern/swiper/swiper_event_test_ng.cpp index 67537e43335..4901d1ce6e2 100644 --- a/test/unittest/core/pattern/swiper/swiper_event_test_ng.cpp +++ b/test/unittest/core/pattern/swiper/swiper_event_test_ng.cpp @@ -559,6 +559,13 @@ HWTEST_F(SwiperEventTestNg, SwiperPatternHandleScroll006, TestSize.Level1) auto res = pattern_->HandleScroll(5.0f, SCROLL_FROM_ANIMATION, NestedState::CHILD_SCROLL); EXPECT_EQ(res.remain, 5.0f); + pattern_->targetIndex_.reset(); + + pattern_->fadeAnimation_ = AnimationUtils::StartAnimation({}, [&]() {}); + pattern_->fadeAnimationIsRunning_ = true; + res = pattern_->HandleScroll(5.0f, SCROLL_FROM_ANIMATION, NestedState::CHILD_SCROLL); + // fade animation doesn't affect scrolling + EXPECT_EQ(res.remain, 0.0f); } /**