1 /*
2  * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SWIPER_SWIPER_PATTERN_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SWIPER_SWIPER_PATTERN_H
18 
19 #include <functional>
20 #include <optional>
21 #include <vector>
22 
23 #include "base/geometry/axis.h"
24 #include "base/geometry/ng/offset_t.h"
25 #include "base/memory/referenced.h"
26 #include "core/components/common/layout/constants.h"
27 #include "core/components/swiper/swiper_controller.h"
28 #include "core/components/swiper/swiper_indicator_theme.h"
29 #include "core/components_ng/base/frame_node.h"
30 #include "core/components_ng/base/frame_scene_status.h"
31 #include "core/components_ng/base/inspector_filter.h"
32 #include "core/components_ng/event/event_hub.h"
33 #include "core/components_ng/event/input_event.h"
34 #include "core/components_ng/pattern/pattern.h"
35 #include "core/components_ng/pattern/scrollable/nestable_scroll_container.h"
36 #include "core/components_ng/pattern/swiper/swiper_accessibility_property.h"
37 #include "core/components_ng/pattern/swiper/swiper_event_hub.h"
38 #include "core/components_ng/pattern/swiper/swiper_layout_algorithm.h"
39 #include "core/components_ng/pattern/swiper/swiper_layout_property.h"
40 #include "core/components_ng/pattern/swiper/swiper_model.h"
41 #include "core/components_ng/pattern/swiper/swiper_paint_property.h"
42 #include "core/components_ng/pattern/swiper/swiper_utils.h"
43 #include "core/components_ng/pattern/tabs/tab_content_transition_proxy.h"
44 #include "core/components_v2/inspector/utils.h"
45 
46 namespace OHOS::Ace::NG {
47 class SwiperPattern : public NestableScrollContainer {
48     DECLARE_ACE_TYPE(SwiperPattern, NestableScrollContainer);
49 
50 public:
51     using CustomContentTransitionPtr = std::shared_ptr<std::function<TabContentAnimatedTransition(int32_t, int32_t)>>;
52 
53     SwiperPattern();
54     ~SwiperPattern() override = default;
55 
IsAtomicNode()56     bool IsAtomicNode() const override
57     {
58         return false;
59     }
60 
IsNeedPercent()61     bool IsNeedPercent() const override
62     {
63         return true;
64     }
65 
ShouldDelayChildPressedState()66     bool ShouldDelayChildPressedState() const override
67     {
68         return true;
69     }
70 
71     void RegisterScrollingListener(const RefPtr<ScrollingListener> listener) override;
72     void FireAndCleanScrollingListener() override;
73     void CleanScrollingListener() override;
74 
UsResRegion()75     bool UsResRegion() override
76     {
77         return false;
78     }
79 
CreateLayoutProperty()80     RefPtr<LayoutProperty> CreateLayoutProperty() override
81     {
82         return MakeRefPtr<SwiperLayoutProperty>();
83     }
84 
CreatePaintProperty()85     RefPtr<PaintProperty> CreatePaintProperty() override
86     {
87         return MakeRefPtr<SwiperPaintProperty>();
88     }
89 
CreateAccessibilityProperty()90     RefPtr<AccessibilityProperty> CreateAccessibilityProperty() override
91     {
92         return MakeRefPtr<SwiperAccessibilityProperty>();
93     }
94 
95     RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override;
96 
97     RefPtr<NodePaintMethod> CreateNodePaintMethod() override;
98 
CreateEventHub()99     RefPtr<EventHub> CreateEventHub() override
100     {
101         return MakeRefPtr<SwiperEventHub>();
102     }
103 
104     void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override;
105     void FromJson(const std::unique_ptr<JsonValue>& json) override;
106 
GetCurrentShownIndex()107     int32_t GetCurrentShownIndex() const
108     {
109         return IsLoop() ? currentIndex_ : GetLoopIndex(currentIndex_);
110     }
111 
GetSwiperController()112     RefPtr<SwiperController> GetSwiperController() const
113     {
114         return swiperController_;
115     }
116 
117     void SetSwiperController(const RefPtr<SwiperController>& controller);
118 
GetCurrentFirstIndex()119     int32_t GetCurrentFirstIndex() const
120     {
121         return currentFirstIndex_;
122     }
123 
GetCurrentIndex()124     int32_t GetCurrentIndex()
125     {
126         return GetLoopIndex(currentIndex_);
127     }
128 
GetTurnPageRate()129     float GetTurnPageRate() const
130     {
131         return turnPageRate_;
132     }
133 
134     GestureState GetGestureState();
135 
GetTouchBottomTypeLoop()136     TouchBottomTypeLoop GetTouchBottomTypeLoop() const
137     {
138         return touchBottomType_;
139     }
140 
IsIndicatorAnimatorRunning()141     bool IsIndicatorAnimatorRunning() const
142     {
143         return indicatorAnimationIsRunning_;
144     }
145 
SetTurnPageRate(float turnPageRate)146     void SetTurnPageRate(float turnPageRate)
147     {
148         turnPageRate_ = turnPageRate;
149     }
150 
GetTouchBottomRate()151     float GetTouchBottomRate() const
152     {
153         return touchBottomRate_;
154     }
155 
SetTouchBottomRate(float touchBottomRate)156     void SetTouchBottomRate(float touchBottomRate)
157     {
158         touchBottomRate_ = touchBottomRate;
159     }
160 
GetController()161     RefPtr<Animator> GetController()
162     {
163         return controller_;
164     }
165 
SetIndicatorDoingAnimation(bool indicatorDoingAnimation)166     void SetIndicatorDoingAnimation(bool indicatorDoingAnimation)
167     {
168         indicatorDoingAnimation_ = indicatorDoingAnimation;
169     }
170 
171     void UpdateCurrentOffset(float offset);
172     /**
173      * @brief Checks if the given offset exceeds the bounds of the swiper container and triggers overScroll.
174      *
175      * @param offset The offset to check.
176      * @return True if overScroll is triggered, false otherwise.
177      */
178     bool CheckOverScroll(float offset);
179 
180     /**
181      * @brief Applies spring effect to the over-scrolling of the swiper.
182      *
183      * @param offset The offset of the swiper.
184      * @return true if the spring effect is applied successfully, false otherwise.
185      */
186     bool SpringOverScroll(float offset);
187 
188     void CheckMarkDirtyNodeForRenderIndicator(
189         float additionalOffset = 0.0f, std::optional<int32_t> nextIndex = std::nullopt);
190 
191     int32_t TotalCount() const;
192 
193     Axis GetDirection() const;
194 
GetFocusPattern()195     FocusPattern GetFocusPattern() const override
196     {
197         return { FocusType::SCOPE, true };
198     }
199 
GetScopeFocusAlgorithm()200     ScopeFocusAlgorithm GetScopeFocusAlgorithm() override
201     {
202         return ScopeFocusAlgorithm(direction_ != Axis::HORIZONTAL, true, ScopeType::OTHERS,
203             [wp = WeakClaim(this)](
204                 FocusStep step, const WeakPtr<FocusHub>& currFocusNode, WeakPtr<FocusHub>& nextFocusNode) {
205                 auto swiper = wp.Upgrade();
206                 if (swiper) {
207                     nextFocusNode = swiper->GetNextFocusNode(step, currFocusNode);
208                 }
209             });
210     }
211 
UpdateChangeEvent(ChangeEvent && event)212     void UpdateChangeEvent(ChangeEvent&& event)
213     {
214         if (!changeEvent_) {
215             changeEvent_ = std::make_shared<ChangeEvent>(event);
216             auto eventHub = GetEventHub<SwiperEventHub>();
217             CHECK_NULL_VOID(eventHub);
218             eventHub->AddOnChangeEvent(changeEvent_);
219         } else {
220             (*changeEvent_).swap(event);
221         }
222     }
223 
UpdateOnChangeEvent(ChangeEvent && event)224     void UpdateOnChangeEvent(ChangeEvent&& event)
225     {
226         if (!onIndexChangeEvent_) {
227             onIndexChangeEvent_ = std::make_shared<ChangeEvent>(event);
228             auto eventHub = GetEventHub<SwiperEventHub>();
229             CHECK_NULL_VOID(eventHub);
230             eventHub->AddOnChangeEvent(onIndexChangeEvent_);
231         } else {
232             (*onIndexChangeEvent_).swap(event);
233         }
234     }
235 
UpdateAnimationStartEvent(AnimationStartEvent && event)236     void UpdateAnimationStartEvent(AnimationStartEvent&& event)
237     {
238         if (!animationStartEvent_) {
239             animationStartEvent_ = std::make_shared<AnimationStartEvent>(event);
240             auto eventHub = GetEventHub<SwiperEventHub>();
241             CHECK_NULL_VOID(eventHub);
242             eventHub->AddAnimationStartEvent(animationStartEvent_);
243         } else {
244             (*animationStartEvent_).swap(event);
245         }
246     }
247 
UpdateAnimationEndEvent(AnimationEndEvent && event)248     void UpdateAnimationEndEvent(AnimationEndEvent&& event)
249     {
250         if (!animationEndEvent_) {
251             animationEndEvent_ = std::make_shared<AnimationEndEvent>(event);
252             auto eventHub = GetEventHub<SwiperEventHub>();
253             CHECK_NULL_VOID(eventHub);
254             eventHub->AddAnimationEndEvent(animationEndEvent_);
255         } else {
256             (*animationEndEvent_).swap(event);
257         }
258     }
259 
SetSwiperParameters(const SwiperParameters & swiperParameters)260     void SetSwiperParameters(const SwiperParameters& swiperParameters)
261     {
262         swiperParameters_ = std::make_shared<SwiperParameters>(swiperParameters);
263     }
264 
SetSwiperDigitalParameters(const SwiperDigitalParameters & swiperDigitalParameters)265     void SetSwiperDigitalParameters(const SwiperDigitalParameters& swiperDigitalParameters)
266     {
267         swiperDigitalParameters_ = std::make_shared<SwiperDigitalParameters>(swiperDigitalParameters);
268     }
269 
270     void ShowNext();
271     void ShowPrevious();
272     void SwipeTo(int32_t index);
273     void ChangeIndex(int32_t index, bool useAnimation);
274 
275     void OnVisibleChange(bool isVisible) override;
276 
GetStartIndex()277     int32_t GetStartIndex() const
278     {
279         return startIndex_;
280     }
281 
GetEndIndex()282     int32_t GetEndIndex() const
283     {
284         return endIndex_;
285     }
286 
HasIndicatorNode()287     bool HasIndicatorNode() const
288     {
289         return indicatorId_.has_value();
290     }
291 
HasLeftButtonNode()292     bool HasLeftButtonNode() const
293     {
294         return leftButtonId_.has_value();
295     }
296 
HasRightButtonNode()297     bool HasRightButtonNode() const
298     {
299         return rightButtonId_.has_value();
300     }
301 
GetIndicatorId()302     int32_t GetIndicatorId()
303     {
304         if (!indicatorId_.has_value()) {
305             indicatorId_ = ElementRegister::GetInstance()->MakeUniqueId();
306         }
307         return indicatorId_.value();
308     }
309 
GetLeftButtonId()310     int32_t GetLeftButtonId()
311     {
312         if (!leftButtonId_.has_value()) {
313             leftButtonId_ = ElementRegister::GetInstance()->MakeUniqueId();
314         }
315         return leftButtonId_.value();
316     }
317 
GetRightButtonId()318     int32_t GetRightButtonId()
319     {
320         if (!rightButtonId_.has_value()) {
321             rightButtonId_ = ElementRegister::GetInstance()->MakeUniqueId();
322         }
323         return rightButtonId_.value();
324     }
325 
RemoveIndicatorNode()326     void RemoveIndicatorNode()
327     {
328         CHECK_NULL_VOID(HasIndicatorNode());
329         auto swiperNode = GetHost();
330         CHECK_NULL_VOID(swiperNode);
331         swiperNode->RemoveChildAtIndex(swiperNode->GetChildIndexById(GetIndicatorId()));
332         indicatorId_ = std::nullopt;
333     }
334 
RemoveLeftButtonNode()335     void RemoveLeftButtonNode()
336     {
337         CHECK_NULL_VOID(HasLeftButtonNode());
338         auto swiperNode = GetHost();
339         CHECK_NULL_VOID(swiperNode);
340         swiperNode->RemoveChildAtIndex(swiperNode->GetChildIndexById(GetLeftButtonId()));
341         leftButtonId_ = std::nullopt;
342     }
343 
RemoveRightButtonNode()344     void RemoveRightButtonNode()
345     {
346         CHECK_NULL_VOID(HasRightButtonNode());
347         auto swiperNode = GetHost();
348         CHECK_NULL_VOID(swiperNode);
349         swiperNode->RemoveChildAtIndex(swiperNode->GetChildIndexById(GetRightButtonId()));
350         rightButtonId_ = std::nullopt;
351     }
352 
353     SwiperIndicatorType GetIndicatorType() const;
354 
IsIndicatorCustomSize()355     bool IsIndicatorCustomSize() const
356     {
357         return isCustomSize_;
358     }
359 
SetIsIndicatorCustomSize(bool isCustomSize)360     void SetIsIndicatorCustomSize(bool isCustomSize)
361     {
362         isCustomSize_ = isCustomSize;
363     }
364 
SetIndicatorIsBoolean(bool isBoolean)365     void SetIndicatorIsBoolean(bool isBoolean)
366     {
367         indicatorIsBoolean_ = isBoolean;
368     }
369 
GetIsAtHotRegion()370     bool GetIsAtHotRegion() const
371     {
372         return isAtHotRegion_;
373     }
374 
HasSurfaceChangedCallback()375     bool HasSurfaceChangedCallback()
376     {
377         return surfaceChangedCallbackId_.has_value();
378     }
379 
UpdateSurfaceChangedCallbackId(int32_t id)380     void UpdateSurfaceChangedCallbackId(int32_t id)
381     {
382         surfaceChangedCallbackId_ = id;
383     }
384 
SetIndicatorLongPress(bool isIndicatorLongPress)385     void SetIndicatorLongPress(bool isIndicatorLongPress)
386     {
387         isIndicatorLongPress_ = isIndicatorLongPress;
388     }
SetCachedCount(int32_t cachedCount)389     void SetCachedCount(int32_t cachedCount)
390     {
391         if (cachedCount_.has_value() && cachedCount_.value() != cachedCount) {
392             SetLazyLoadFeature(true);
393         }
394         cachedCount_ = cachedCount;
395     }
396 
SetFinishCallbackType(FinishCallbackType finishCallbackType)397     void SetFinishCallbackType(FinishCallbackType finishCallbackType)
398     {
399         finishCallbackType_ = finishCallbackType;
400     }
401 
GetFinishCallbackType()402     FinishCallbackType GetFinishCallbackType() const
403     {
404         return finishCallbackType_;
405     }
406 
SetStopIndicatorAnimationCb(const std::function<void (bool)> & stopCallback)407     void SetStopIndicatorAnimationCb(const std::function<void(bool)>& stopCallback)
408     {
409         stopIndicatorAnimationFunc_ = std::move(stopCallback);
410     }
411 
412     std::shared_ptr<SwiperParameters> GetSwiperParameters() const;
413     std::shared_ptr<SwiperDigitalParameters> GetSwiperDigitalParameters() const;
414 
415     void ArrowHover(bool hoverFlag);
416     bool IsLoop() const;
417     bool IsEnabled() const;
418     void OnWindowShow() override;
419     void OnWindowHide() override;
420     std::string ProvideRestoreInfo() override;
421     void OnRestoreInfo(const std::string& restoreInfo) override;
422     bool IsAutoFill() const;
423     void SwipeToWithoutAnimation(int32_t index);
424     void StopAutoPlay();
425     void StartAutoPlay();
426     void StopTranslateAnimation();
427     void StopSpringAnimationImmediately();
428     void StopSpringAnimation();
429     void DumpAdvanceInfo() override;
430     int32_t GetLoopIndex(int32_t originalIndex) const;
431     int32_t GetDuration() const;
432     void UpdateDragFRCSceneInfo(float speed, SceneStatus sceneStatus);
433     void AdjustCurrentIndexOnSwipePage(int32_t index);
434     void OnCustomContentTransition(int32_t toIndex);
435     void OnCustomAnimationFinish(int32_t fromIndex, int32_t toIndex, bool hasOnChanged);
436     void OnSwiperCustomAnimationFinish(CancelableCallback<void()>& task, int32_t index, bool isFinishAnimation);
437 
SetCustomAnimationToIndex(int32_t toIndex)438     void SetCustomAnimationToIndex(int32_t toIndex)
439     {
440         customAnimationToIndex_ = toIndex;
441     }
442 
GetCustomAnimationToIndex()443     std::optional<int32_t> GetCustomAnimationToIndex() const
444     {
445         return customAnimationToIndex_;
446     }
447 
SetTabsCustomContentTransition(std::function<TabContentAnimatedTransition (int32_t,int32_t)> && event)448     void SetTabsCustomContentTransition(std::function<TabContentAnimatedTransition(int32_t, int32_t)>&& event)
449     {
450         onTabsCustomContentTransition_ =
451             std::make_shared<std::function<TabContentAnimatedTransition(int32_t, int32_t)>>(event);
452     }
453 
GetTabsCustomContentTransition()454     CustomContentTransitionPtr GetTabsCustomContentTransition() const
455     {
456         return onTabsCustomContentTransition_;
457     }
458 
SetSwiperCustomContentTransition(SwiperContentAnimatedTransition & transition)459     void SetSwiperCustomContentTransition(SwiperContentAnimatedTransition& transition)
460     {
461         onSwiperCustomContentTransition_ = std::make_shared<SwiperContentAnimatedTransition>(transition);
462     }
463 
GetSwiperCustomContentTransition()464     std::shared_ptr<SwiperContentAnimatedTransition> GetSwiperCustomContentTransition() const
465     {
466         return onSwiperCustomContentTransition_;
467     }
468 
SetOnContentDidScroll(ContentDidScrollEvent && onContentDidScroll)469     void SetOnContentDidScroll(ContentDidScrollEvent&& onContentDidScroll)
470     {
471         onContentDidScroll_ = std::make_shared<ContentDidScrollEvent>(onContentDidScroll);
472     }
473 
GetOnContentDidScroll()474     std::shared_ptr<ContentDidScrollEvent> GetOnContentDidScroll() const
475     {
476         return onContentDidScroll_;
477     }
478 
479     void SetSwiperEventCallback(bool disableSwipe);
480     void UpdateSwiperPanEvent(bool disableSwipe);
481     bool IsUseCustomAnimation() const;
482 
SetTabsPaddingAndBorder(const PaddingPropertyF & tabsPaddingAndBorder)483     void SetTabsPaddingAndBorder(const PaddingPropertyF& tabsPaddingAndBorder)
484     {
485         tabsPaddingAndBorder_ = tabsPaddingAndBorder;
486     }
487 
488     RefPtr<Curve> GetCurveIncludeMotion();
GetMotionVelocity()489     float GetMotionVelocity()
490     {
491         return motionVelocity_;
492     }
493 
494     int32_t RealTotalCount() const;
495     bool IsSwipeByGroup() const;
496     int32_t GetDisplayCount() const;
497     int32_t GetCachedCount() const;
498     bool ContentWillChange(int32_t comingIndex);
499     bool ContentWillChange(int32_t currentIndex, int32_t comingIndex);
500     bool CheckSwiperPanEvent(float mainDeltaOrVelocity);
InitIndexCanChangeMap()501     void InitIndexCanChangeMap()
502     {
503         indexCanChangeMap_.clear();
504     }
505 
GetNextValidIndex()506     int32_t GetNextValidIndex() const
507     {
508         return nextValidIndex_;
509     }
510     void UpdateNextValidIndex();
511     void CheckMarkForIndicatorBoundary();
512     bool IsHorizontalAndRightToLeft() const;
513     TextDirection GetNonAutoLayoutDirection() const;
514     void FireWillHideEvent(int32_t willHideIndex) const;
515     void FireWillShowEvent(int32_t willShowIndex) const;
516     void SetOnHiddenChangeForParent();
517     void RemoveOnHiddenChange();
518 
SetHasTabsAncestor(bool hasTabsAncestor)519     void SetHasTabsAncestor(bool hasTabsAncestor)
520     {
521         hasTabsAncestor_ = hasTabsAncestor;
522     }
523 
SetIndicatorInteractive(bool isInteractive)524     void SetIndicatorInteractive(bool isInteractive)
525     {
526         isIndicatorInteractive_ = isInteractive;
527     }
528 
529     bool IsAtStart() const;
530     bool IsAtEnd() const;
531 
IsIndicatorInteractive()532     bool IsIndicatorInteractive() const
533     {
534         return isIndicatorInteractive_;
535     }
536 
SetNextMarginIgnoreBlank(bool nextMarginIgnoreBlank)537     void SetNextMarginIgnoreBlank(bool nextMarginIgnoreBlank)
538     {
539         nextMarginIgnoreBlank_ = nextMarginIgnoreBlank;
540     }
541 
SetPrevMarginIgnoreBlank(bool prevMarginIgnoreBlank)542     void SetPrevMarginIgnoreBlank(bool prevMarginIgnoreBlank)
543     {
544         prevMarginIgnoreBlank_ = prevMarginIgnoreBlank;
545     }
546 
SetFrameRateRange(const RefPtr<FrameRateRange> & rateRange,SwiperDynamicSyncSceneType type)547     void SetFrameRateRange(const RefPtr<FrameRateRange>& rateRange, SwiperDynamicSyncSceneType type) override
548     {
549         frameRateRange_[type] = rateRange;
550     }
551     void UpdateNodeRate();
552     int32_t GetMaxDisplayCount() const;
553 
GetPrevMarginIgnoreBlank()554     bool GetPrevMarginIgnoreBlank()
555     {
556         return prevMarginIgnoreBlank_;
557     }
558 
GetNextMarginIgnoreBlank()559     bool GetNextMarginIgnoreBlank()
560     {
561         return nextMarginIgnoreBlank_;
562     }
563 
GetCachedItems()564     const std::set<int32_t>& GetCachedItems() const
565     {
566         return cachedItems_;
567     }
568 
SetCachedItems(const std::set<int32_t> & cachedItems)569     void SetCachedItems(const std::set<int32_t>& cachedItems)
570     {
571         cachedItems_ = cachedItems;
572     }
573 
GetLayoutConstraint()574     LayoutConstraintF GetLayoutConstraint() const
575     {
576         return layoutConstraint_;
577     }
578 
SetLayoutConstraint(const LayoutConstraintF & layoutConstraint)579     void SetLayoutConstraint(const LayoutConstraintF& layoutConstraint)
580     {
581         layoutConstraint_ = layoutConstraint;
582     }
583 
GetRequestLongPredict()584     bool GetRequestLongPredict() const
585     {
586         return requestLongPredict_;
587     }
588 
IsPropertyAnimationRunning()589     bool IsPropertyAnimationRunning() const
590     {
591         return usePropertyAnimation_;
592     }
593 
IsTranslateAnimationRunning()594     bool IsTranslateAnimationRunning() const
595     {
596         return translateAnimationIsRunning_;
597     }
598 
IsTouchDown()599     bool IsTouchDown() const
600     {
601         return isTouchDown_;
602     }
603 
IsTouchDownOnOverlong()604     bool IsTouchDownOnOverlong() const
605     {
606         return isTouchDownOnOverlong_;
607     }
608 
609 private:
610     void OnModifyDone() override;
611     void OnAfterModifyDone() override;
612     void OnAttachToFrameNode() override;
613     void OnDetachFromFrameNode(FrameNode* node) override;
614     void OnAttachToMainTree() override;
615     void OnDetachFromMainTree() override;
616     void InitSurfaceChangedCallback();
617     bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
618 
619     // Init pan recognizer to move items when drag update, play translate animation when drag end.
620     void InitPanEvent(const RefPtr<GestureEventHub>& gestureHub);
621     void AddPanEvent(const RefPtr<GestureEventHub>& gestureHub, GestureEventFunc&& actionStart,
622         GestureEventFunc&& actionUpdate, GestureEventFunc&& actionEnd, GestureEventNoParameter&& actionCancel);
623 
624     // Init touch event, stop animation when touch down.
625     void InitTouchEvent(const RefPtr<GestureEventHub>& gestureHub);
626     void InitHoverMouseEvent();
627     // Init on key event
628     void InitOnFocusInternal(const RefPtr<FocusHub>& focusHub);
629     void HandleFocusInternal();
630     void InitOnKeyEvent(const RefPtr<FocusHub>& focusHub);
631     bool OnKeyEvent(const KeyEvent& event);
632     bool IsFocusNodeInItemPosition(const RefPtr<FocusHub>& targetFocusHub);
633     void FlushFocus(const RefPtr<FrameNode>& curShowFrame);
634     WeakPtr<FocusHub> GetNextFocusNode(FocusStep step, const WeakPtr<FocusHub>& currentFocusNode);
635 
636     // Init indicator
637     void InitIndicator();
638     void InitArrow();
639 
640     void HandleDragStart(const GestureEvent& info);
641     void HandleDragUpdate(const GestureEvent& info);
642     void HandleDragEnd(double dragVelocity);
643 
644     bool InsideIndicatorRegion(const TouchLocationInfo& locationInfo);
645     void HandleTouchEvent(const TouchEventInfo& info);
646     void HandleTouchDown(const TouchLocationInfo& locationInfo);
647     void HandleTouchUp();
648 
649     void HandleMouseEvent(const MouseInfo& info);
650     void PlayTranslateAnimation(
651         float startPos, float endPos, int32_t nextIndex, bool restartAutoPlay = false, float velocity = 0.0f);
652     void OnTranslateAnimationFinish();
653     void PlaySpringAnimation(double dragVelocity);
654     void PlayFadeAnimation();
655 
656     // use property animation feature
657     void PlayPropertyTranslateAnimation(
658         float translate, int32_t nextIndex, float velocity = 0.0f, bool stopAutoPlay = false);
659     void StopPropertyTranslateAnimation(
660         bool isFinishAnimation, bool isBeforeCreateLayoutWrapper = false, bool isInterrupt = false);
661     void UpdateOffsetAfterPropertyAnimation(float offset);
662     void OnPropertyTranslateAnimationFinish(const OffsetF& offset);
663     void PlayIndicatorTranslateAnimation(float translate, std::optional<int32_t> nextIndex = std::nullopt);
664 
665     // Implement of swiper controller
666 
667     void FinishAnimation();
668     void StopFadeAnimation();
669 
670     bool IsOutOfBoundary(float mainOffset = 0.0f) const;
671     bool IsOutOfStart(float mainOffset = 0.0f) const;
672     bool IsOutOfEnd(float mainOffset = 0.0f) const;
673     bool AutoLinearIsOutOfBoundary(float mainOffset) const;
674     float GetDistanceToEdge() const;
675     float MainSize() const;
676     float GetMainContentSize() const;
677     void FireChangeEvent(int32_t preIndex, int32_t currentIndex) const;
678     void FireAnimationStartEvent(int32_t currentIndex, int32_t nextIndex, const AnimationCallbackInfo& info) const;
679     void FireAnimationEndEvent(int32_t currentIndex, const AnimationCallbackInfo& info, bool isInterrupt = false) const;
680     void FireGestureSwipeEvent(int32_t currentIndex, const AnimationCallbackInfo& info) const;
681     void FireSwiperCustomAnimationEvent();
682     void FireContentDidScrollEvent();
683     void HandleSwiperCustomAnimation(float offset);
684     void CalculateAndUpdateItemInfo(float offset);
685     void UpdateItemInfoInCustomAnimation(int32_t index, float startPos, float endPos);
686     void UpdateTabBarAnimationDuration(int32_t index);
687 
688     float GetItemSpace() const;
689     float GetPrevMargin() const;
690     float GetNextMargin() const;
GetPrevMarginWithItemSpace()691     float GetPrevMarginWithItemSpace() const
692     {
693         return Positive(GetPrevMargin()) ? GetPrevMargin() + GetItemSpace() : 0.0f;
694     }
GetNextMarginWithItemSpace()695     float GetNextMarginWithItemSpace() const
696     {
697         return Positive(GetNextMargin()) ? GetNextMargin() + GetItemSpace() : 0.0f;
698     }
CalculateVisibleSize()699     float CalculateVisibleSize() const
700     {
701         return contentMainSize_ - GetPrevMarginWithItemSpace() - GetNextMarginWithItemSpace();
702     }
703     int32_t CurrentIndex() const;
704     int32_t CalculateDisplayCount() const;
705     int32_t CalculateCount(
706         float contentWidth, float minSize, float margin, float gutter, float swiperPadding = 0.0f) const;
707     int32_t GetInterval() const;
708     RefPtr<Curve> GetCurve() const;
709     EdgeEffect GetEdgeEffect() const;
710     bool IsAutoPlay() const;
711     bool IsDisableSwipe() const;
712     bool IsShowIndicator() const;
713     std::pair<int32_t, SwiperItemInfo> GetFirstItemInfoInVisibleArea() const;
714     std::pair<int32_t, SwiperItemInfo> GetLastItemInfoInVisibleArea() const;
715     std::pair<int32_t, SwiperItemInfo> GetSecondItemInfoInVisibleArea() const;
716     void OnIndexChange();
717     bool IsOutOfHotRegion(const PointF& dragPoint) const;
718     void SetDigitStartAndEndProperty(const RefPtr<FrameNode>& indicatorNode);
719     void UpdatePaintProperty(const RefPtr<FrameNode>& indicatorNode);
720     void PostTranslateTask(uint32_t delayTime);
721     void HandleVisibleChange(bool visible);
722     void RegisterVisibleAreaChange();
723     bool NeedAutoPlay() const;
724     void OnTranslateFinish(int32_t nextIndex, bool restartAutoPlay, bool isFinishAnimation, bool forceStop = false,
725         bool isInterrupt = false);
726     bool IsShowArrow() const;
727     void SaveArrowProperty(const RefPtr<FrameNode>& arrowNode);
728     RefPtr<FocusHub> GetFocusHubChild(std::string childFrameName);
729     WeakPtr<FocusHub> PreviousFocus(const RefPtr<FocusHub>& curFocusNode);
730     WeakPtr<FocusHub> NextFocus(const RefPtr<FocusHub>& curFocusNode);
731     void SetAccessibilityAction();
732     bool NeedStartAutoPlay() const;
733     void CheckAndSetArrowHoverState(const PointF& mousePoint);
734     RectF GetArrowFrameRect(const int32_t index) const;
735     float GetCustomPropertyOffset() const;
736     float GetCustomPropertyTargetOffset() const;
737     void UpdateAnimationProperty(float velocity);
738     void TriggerAnimationEndOnForceStop(bool isInterrupt = false);
739     void TriggerAnimationEndOnSwipeToLeft();
740     void TriggerAnimationEndOnSwipeToRight();
741     void TriggerEventOnFinish(int32_t nextIndex);
742     bool IsVisibleChildrenSizeLessThanSwiper() const;
743     void BeforeCreateLayoutWrapper() override;
744     int32_t CheckUserSetIndex(int32_t index);
745 
746     void SetLazyLoadFeature(bool useLazyLoad);
747     void SetLazyForEachLongPredict(bool useLazyLoad) const;
748     void SetLazyLoadIsLoop() const;
749     int32_t ComputeNextIndexByVelocity(float velocity, bool onlyDistance = false) const;
750     void UpdateCurrentIndex(int32_t index);
751     void OnSpringAnimationStart(float velocity);
752     void OnSpringAnimationFinish();
753     void OnSpringAndFadeAnimationFinish();
754     void OnFadeAnimationStart();
755     int32_t TotalDisPlayCount() const;
756     void StopAndResetSpringAnimation();
757     void OnLoopChange();
758     void StopSpringAnimationAndFlushImmediately();
759     void UpdateItemRenderGroup(bool itemRenderGroup);
760     void MarkDirtyNodeSelf();
761     void ResetAndUpdateIndexOnAnimationEnd(int32_t nextIndex);
762     int32_t GetLoopIndex(int32_t index, int32_t childrenSize) const;
763     bool IsAutoLinear() const;
764     bool AutoLinearAnimationNeedReset(float translate) const;
765     void OnAnimationTranslateZero(int32_t nextIndex, bool stopAutoPlay);
766     void TriggerCustomContentTransitionEvent(int32_t fromIndex, int32_t toIndex);
767     /**
768      * @brief Preprocess drag delta when received from DragUpdate event.
769      *
770      * Drag offset in Swiper can't go beyond a full page. Apply the restriction through this function.
771      *
772      * @param delta
773      * @param mainSize content length along the main axis.
774      * @param deltaSum accumulated delta in the current drag event.
775      */
776     static void ProcessDelta(float& delta, float mainSize, float deltaSum);
777 
778     /**
779      * @brief Stops animations when the scroll starts.
780      *
781      * @param flushImmediately Whether to flush layout immediately.
782      */
783     void StopAnimationOnScrollStart(bool flushImmediately);
784     /**
785      * @return true if any translate animation (switching page / spring) is running, false otherwise.
786      */
787     inline bool DuringTranslateAnimation() const;
788     /**
789      * @return true if any translate animation (switching page / spring) is running, ignore animation pause etc.
790      */
791     inline bool RunningTranslateAnimation() const;
792     /**
793      * @return true if fade animation is running, false otherwise.
794      */
795     inline bool DuringFadeAnimation() const;
796 
797     /**
798      *  NestableScrollContainer implementations
799      *  ============================================================
800      */
GetAxis()801     Axis GetAxis() const override
802     {
803         return GetDirection();
804     }
805 
806     /**
807      * @brief Closes gap to the edge, called before Swiper transfers extra offset to parent/child to ensure that Swiper
808      * actually reaches the edge.
809      *
810      * @param offset The scroll offset from DragUpdate.
811      */
812     void CloseTheGap(float& offset);
813 
814     ScrollResult HandleScroll(
815         float offset, int32_t source, NestedState state = NestedState::GESTURE, float velocity = 0.f) override;
816 
817     ScrollResult HandleScrollSelfFirst(float offset, int32_t source, NestedState state, float velocity = 0.f);
818 
819     ScrollResult HandleScrollParentFirst(float offset, int32_t source, NestedState state, float velocity = 0.f);
820 
NestedScrollOutOfBoundary()821     bool NestedScrollOutOfBoundary() override
822     {
823         return IsOutOfBoundary();
824     }
825 
826     bool HandleScrollVelocity(float velocity, const RefPtr<NestableScrollContainer>& child = nullptr) override;
827 
828     void OnScrollStartRecursive(WeakPtr<NestableScrollContainer> child, float position, float velocity) override;
829     void OnScrollEndRecursive(const std::optional<float>& velocity) override;
830     void OnScrollDragEndRecursive() override;
831 
832     /**
833      * @brief Notifies the parent component that the scroll has started at the specified position.
834      *
835      * @param position The position where the scroll has started.
836      */
837     void NotifyParentScrollStart(WeakPtr<NestableScrollContainer> child, float position);
838     /**
839      * @brief Notifies the parent NestableScrollContainer that the scroll has ended.
840      */
841     void NotifyParentScrollEnd();
842 
843     inline bool ChildFirst(NestedState state);
844     RefPtr<FrameNode> GetCurrentFrameNode(int32_t currentIndex) const;
845     bool FadeOverScroll(float offset);
846     int32_t ComputeSwipePageNextIndex(float velocity, bool onlyDistance = false) const;
847     int32_t ComputeNextIndexInSinglePage(float velocity, bool onlyDistance) const;
848     int32_t ComputePageIndex(int32_t index) const;
849     void UpdateIndexOnAnimationStop();
850     void UpdateIndexOnSwipePageStop(int32_t pauseTargetIndex);
851     void AdjustCurrentFocusIndex();
852     bool IsContentFocused();
853 
854     int32_t CheckTargetIndex(int32_t targetIndex, bool isForceBackward = false);
855 
856     void HandleTouchBottomLoop();
857     void HandleTouchBottomLoopOnRTL();
858     void CalculateGestureStateOnRTL(float additionalOffset, float currentTurnPageRate, int32_t preFirstIndex);
859     void CalculateGestureState(float additionalOffset, float currentTurnPageRate, int32_t preFirstIndex);
860     std::pair<float, float> CalcCurrentPageStatus(float additionalOffset) const;
861     std::pair<float, float> CalcCurrentPageStatusOnRTL(float additionalOffset) const;
862     void StopIndicatorAnimation(bool ifImmediately = false);
863 
864     void PreloadItems(const std::set<int32_t>& indexSet);
865     void DoTabsPreloadItems(const std::set<int32_t>& indexSet);
866     void DoSwiperPreloadItems(const std::set<int32_t>& indexSet);
867     void FirePreloadFinishEvent(int32_t errorCode, std::string message = "");
868     // capture node start
869     void InitCapture();
GetLeftCaptureId()870     int32_t GetLeftCaptureId()
871     {
872         if (!leftCaptureId_.has_value()) {
873             leftCaptureId_ = ElementRegister::GetInstance()->MakeUniqueId();
874         }
875         return leftCaptureId_.value();
876     }
GetRightCaptureId()877     int32_t GetRightCaptureId()
878     {
879         if (!rightCaptureId_.has_value()) {
880             rightCaptureId_ = ElementRegister::GetInstance()->MakeUniqueId();
881         }
882         return rightCaptureId_.value();
883     }
RemoveAllCaptureNode()884     void RemoveAllCaptureNode()
885     {
886         auto swiperNode = GetHost();
887         CHECK_NULL_VOID(swiperNode);
888         swiperNode->RemoveChildAtIndex(swiperNode->GetChildIndexById(GetLeftCaptureId()));
889         leftCaptureId_ = std::nullopt;
890         swiperNode->RemoveChildAtIndex(swiperNode->GetChildIndexById(GetRightCaptureId()));
891         rightCaptureId_ = std::nullopt;
892     }
GetLeftCaptureNode()893     RefPtr<FrameNode> GetLeftCaptureNode()
894     {
895         auto swiperNode = GetHost();
896         CHECK_NULL_RETURN(swiperNode, nullptr);
897         return DynamicCast<FrameNode>(swiperNode->GetChildAtIndex(swiperNode->GetChildIndexById(GetLeftCaptureId())));
898     }
GetRightCaptureNode()899     RefPtr<FrameNode> GetRightCaptureNode()
900     {
901         auto swiperNode = GetHost();
902         CHECK_NULL_RETURN(swiperNode, nullptr);
903         return DynamicCast<FrameNode>(swiperNode->GetChildAtIndex(swiperNode->GetChildIndexById(GetRightCaptureId())));
904     }
IsCaptureNodeValid()905     bool IsCaptureNodeValid()
906     {
907         return hasCachedCapture_ && GetLeftCaptureNode() && GetRightCaptureNode();
908     }
909     void UpdateTargetCapture(bool forceUpdate);
910     void CreateCaptureCallback(int32_t targetIndex, int32_t captureId, bool forceUpdate);
911     void UpdateCaptureSource(std::shared_ptr<Media::PixelMap> pixelMap, int32_t captureId, int32_t targetIndex);
912 
SupportSwiperCustomAnimation()913     bool SupportSwiperCustomAnimation()
914     {
915         auto swiperLayoutProperty = GetLayoutProperty<SwiperLayoutProperty>();
916         return (onSwiperCustomContentTransition_ || onContentDidScroll_) && !hasCachedCapture_ &&
917                SwiperUtils::IsStretch(swiperLayoutProperty);
918     }
919 
920     bool NeedStartNewAnimation(const OffsetF& offset) const;
921     void ResetOnForceMeasure();
922     void UpdateTabBarIndicatorCurve();
923     bool CheckDragOutOfBoundary(double dragVelocity);
924     void UpdateCurrentFocus();
925 
926     void CreateSpringProperty();
927 
928     std::optional<RefPtr<UINode>> FindLazyForEachNode(RefPtr<UINode> baseNode, bool isSelfNode = true) const;
929     bool NeedForceMeasure() const;
930     void SetIndicatorChangeIndexStatus(bool withAnimation, std::optional<int32_t> startIndex = std::nullopt);
931     void SetIndicatorJumpIndex(std::optional<int32_t> jumpIndex);
932     bool ParseTabsIsRtl();
933 
934     void PostIdleTask(const RefPtr<FrameNode>& frameNode);
935 
936     float AdjustIgnoreBlankOverScrollOffSet(bool isStartOverScroll) const;
937     void UpdateIgnoreBlankOffsetWithIndex();
938     // overSrollDirection is true means over start boundary, false means over end boundary.
939     void UpdateIgnoreBlankOffsetWithDrag(bool overSrollDirection);
940     void UpdateIgnoreBlankOffsetInMap(float lastIgnoreBlankOffset);
941 
942     std::set<int32_t> CalcVisibleIndex(float offset = 0.0f) const;
943 
944     bool IsItemOverlay() const;
945     void UpdateIndicatorOnChildChange();
946 
947     void CheckSpecialItemCount() const;
948 
949     friend class SwiperHelper;
950 
951     RefPtr<PanEvent> panEvent_;
952     RefPtr<TouchEventImpl> touchEvent_;
953     RefPtr<InputEvent> hoverEvent_;
954 
955     // Control translate animation when drag end.
956     RefPtr<Animator> controller_;
957 
958     // Control spring animation when drag beyond boundary and drag end.
959     std::shared_ptr<AnimationUtils::Animation> springAnimation_;
960 
961     // Control fade animation when drag beyond boundary and drag end.
962     std::shared_ptr<AnimationUtils::Animation> fadeAnimation_;
963 
964     // Control translate animation for indicator.
965     std::shared_ptr<AnimationUtils::Animation> indicatorAnimation_;
966 
967     std::shared_ptr<AnimationUtils::Animation> translateAnimation_;
968 
969     bool indicatorAnimationIsRunning_ = false;
970     bool translateAnimationIsRunning_ = false;
971 
972     // stop indicator animation callback
973     std::function<void(bool)> stopIndicatorAnimationFunc_;
974 
975     RefPtr<SwiperController> swiperController_;
976     RefPtr<InputEvent> mouseEvent_;
977 
978     bool isLastIndicatorFocused_ = false;
979     int32_t startIndex_ = 0;
980     int32_t endIndex_ = 0;
981     int32_t currentIndex_ = 0;
982     int32_t oldIndex_ = 0;
983     int32_t nextIndex_ = 0;
984 
985     PanDirection panDirection_;
986 
987     float currentOffset_ = 0.0f;
988     float fadeOffset_ = 0.0f;
989     float turnPageRate_ = 0.0f;
990     float translateAnimationEndPos_ = 0.0f;
991     GestureState gestureState_ = GestureState::GESTURE_STATE_INIT;
992     TouchBottomTypeLoop touchBottomType_ = TouchBottomTypeLoop::TOUCH_BOTTOM_TYPE_LOOP_NONE;
993     float touchBottomRate_ = 1.0f;
994     float currentIndexOffset_ = 0.0f;
995     int32_t gestureSwipeIndex_ = 0;
996     int32_t currentFirstIndex_ = 0;
997     int32_t nextValidIndex_ = 0;
998     int32_t currentFocusIndex_ = 0;
999 
1000     bool moveDirection_ = false;
1001     bool indicatorDoingAnimation_ = false;
1002     bool isInit_ = true;
1003     bool hasVisibleChangeRegistered_ = false;
1004     bool isVisible_ = true;
1005     bool isVisibleArea_ = false;
1006     bool isWindowShow_ = true;
1007     bool isCustomSize_ = false;
1008     bool indicatorIsBoolean_ = true;
1009     bool isAtHotRegion_ = false;
1010     bool isDragging_ = false;
1011     bool needTurn_ = false;
1012     bool isParentHiddenChange_ = false;
1013     /**
1014      * @brief Indicates whether the child NestableScrollContainer is currently scrolling and affecting Swiper.
1015      */
1016     bool childScrolling_ = false;
1017     bool isTouchDown_ = false;
1018     bool isTouchDownOnOverlong_ = false;
1019     std::optional<bool> preLoop_;
1020 
1021     Axis direction_ = Axis::HORIZONTAL;
1022 
1023     ChangeEventPtr changeEvent_;
1024     ChangeEventPtr onIndexChangeEvent_;
1025     AnimationStartEventPtr animationStartEvent_;
1026     AnimationEndEventPtr animationEndEvent_;
1027 
1028     mutable std::shared_ptr<SwiperParameters> swiperParameters_;
1029     mutable std::shared_ptr<SwiperDigitalParameters> swiperDigitalParameters_;
1030 
1031     WeakPtr<FrameNode> lastWeakShowNode_;
1032 
1033     CancelableCallback<void()> translateTask_;
1034     CancelableCallback<void()> resetLayoutTask_;
1035 
1036     std::optional<int32_t> indicatorId_;
1037     std::optional<int32_t> leftButtonId_;
1038     std::optional<int32_t> rightButtonId_;
1039     std::optional<int32_t> leftCaptureId_;
1040     std::optional<int32_t> rightCaptureId_;
1041     std::optional<SwiperIndicatorType> lastSwiperIndicatorType_;
1042 
1043     float startMainPos_ = 0.0f;
1044     float endMainPos_ = 0.0f;
1045     float contentMainSize_ = 0.0f;
1046     float oldContentMainSize_ = 0.0f;
1047     float contentCrossSize_ = 0.0f;
1048     bool crossMatchChild_ = false;
1049 
1050     std::optional<int32_t> uiCastJumpIndex_;
1051     std::optional<int32_t> jumpIndex_;
1052     std::optional<int32_t> targetIndex_;
1053     std::optional<int32_t> preTargetIndex_;
1054     std::optional<int32_t> pauseTargetIndex_;
1055     std::optional<int32_t> oldChildrenSize_;
1056     std::optional<float> placeItemWidth_;
1057     float currentDelta_ = 0.0f;
1058     // cumulated delta in a single drag event
1059     float mainDeltaSum_ = 0.0f;
1060     SwiperLayoutAlgorithm::PositionMap itemPosition_;
1061     std::optional<float> velocity_;
1062     float motionVelocity_ = 0.0f;
1063     bool isFinishAnimation_ = false;
1064     bool mainSizeIsMeasured_ = false;
1065     bool usePropertyAnimation_ = false;
1066     bool springAnimationIsRunning_ = false;
1067     bool isTouchDownSpringAnimation_ = false;
1068     bool isTouchDownFadeAnimation_ = false;
1069     int32_t propertyAnimationIndex_ = -1;
1070     bool isUserFinish_ = true;
1071     bool isVoluntarilyClear_ = false;
1072     bool isIndicatorLongPress_ = false;
1073     bool stopIndicatorAnimation_ = true;
1074     bool isTouchPad_ = false;
1075     bool fadeAnimationIsRunning_ = false;
1076     bool autoLinearReachBoundary = false;
1077     bool needAdjustIndex_ = false;
1078     bool hasTabsAncestor_ = false;
1079     bool isIndicatorInteractive_ = true;
1080     bool nextMarginIgnoreBlank_ = false;
1081     bool prevMarginIgnoreBlank_ = false;
1082     float ignoreBlankOffset_ = 0.0f;
1083 
1084     std::optional<int32_t> cachedCount_;
1085 
1086     std::optional<int32_t> surfaceChangedCallbackId_;
1087     SwiperLayoutAlgorithm::PositionMap itemPositionInAnimation_;
1088 
1089     WindowSizeChangeReason windowSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED;
1090     std::vector<RefPtr<ScrollingListener>> scrollingListener_;
1091     FinishCallbackType finishCallbackType_ = FinishCallbackType::REMOVED;
1092 
1093     CustomContentTransitionPtr onTabsCustomContentTransition_;
1094     std::shared_ptr<SwiperContentAnimatedTransition> onSwiperCustomContentTransition_;
1095     std::shared_ptr<ContentDidScrollEvent> onContentDidScroll_;
1096     std::set<int32_t> indexsInAnimation_;
1097     std::set<int32_t> needUnmountIndexs_;
1098     std::optional<int32_t> customAnimationToIndex_;
1099     RefPtr<TabContentTransitionProxy> currentProxyInAnimation_;
1100     PaddingPropertyF tabsPaddingAndBorder_;
1101     std::map<int32_t, bool> indexCanChangeMap_;
1102     std::unordered_map<SwiperDynamicSyncSceneType, RefPtr<FrameRateRange>> frameRateRange_;
1103     // capture
1104     std::optional<int32_t> leftCaptureIndex_;
1105     std::optional<int32_t> rightCaptureIndex_;
1106     bool hasCachedCapture_ = false;
1107     bool isCaptureReverse_ = false;
1108     OffsetF captureFinalOffset_;
1109     bool isInAutoPlay_ = false;
1110     bool needResetCurrentIndex_ = false;
1111 
1112     bool needFireCustomAnimationEvent_ = true;
1113     std::optional<bool> isSwipeByGroup_;
1114     std::set<WeakPtr<FrameNode>> groupedItems_;
1115 
1116     std::set<int32_t> cachedItems_;
1117     LayoutConstraintF layoutConstraint_;
1118     bool requestLongPredict_ = false;
1119 };
1120 } // namespace OHOS::Ace::NG
1121 
1122 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SWIPER_SWIPER_PATTERN_H
1123