!37770 修复:Swiper嵌套滚动到边缘触发fade后无法再做位移动画

Merge pull request !37770 from 周沺耳/dev
This commit is contained in:
openharmony_ci 2024-07-16 04:15:06 +00:00 committed by Gitee
commit 2c6bfb4d78
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 25 additions and 20 deletions

View File

@ -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

View File

@ -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

View File

@ -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<FrameNode>& 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<float>& 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<NestableScrollContainer>& 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<TabBarPattern>();
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;

View File

@ -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

View File

@ -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);
}
/**