• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 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_SCROLL_SCROLLABLE_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SCROLL_SCROLLABLE_NG_H
18 
19 #include <functional>
20 
21 #include "base/geometry/dimension.h"
22 #include "base/utils/system_properties.h"
23 #include "core/animation/animator.h"
24 #include "core/animation/friction_motion.h"
25 #include "core/animation/scroll_motion.h"
26 #include "core/components_ng/base/frame_scene_status.h"
27 #include "core/components_ng/gestures/recognizers/pan_recognizer.h"
28 #include "core/components_ng/pattern/scrollable/axis/axis_animator.h"
29 #include "core/components_ng/pattern/scrollable/scrollable_properties.h"
30 #include "core/components_ng/render/animation_utils.h"
31 #include "core/event/axis_event.h"
32 #include "core/event/touch_event.h"
33 #include "core/gestures/raw_recognizer.h"
34 #include "core/gestures/timeout_recognizer.h"
35 
36 #ifdef SUPPORT_DIGITAL_CROWN
37 #include "core/event/crown_event.h"
38 #include "core/common/vibrator/vibrator_utils.h"
39 #endif
40 
41 namespace OHOS::Ace::NG {
42 enum class NestedState {
43     GESTURE = 0,
44     CHILD_SCROLL,
45     CHILD_OVER_SCROLL,
46     CHILD_CHECK_OVER_SCROLL,
47 };
48 
49 struct OverScrollOffset {
50     double start;
51     double end;
52 };
53 
54 struct ScrollResult {
55     double remain;
56     bool reachEdge;
57 };
58 
59 using ScrollEventCallback = std::function<void()>;
60 using OutBoundaryCallback = std::function<bool()>;
61 using ScrollOverCallback = std::function<void(double velocity)>;
62 using WatchFixCallback = std::function<double(double final, double current)>;
63 using ScrollBeginCallback = std::function<ScrollInfo(Dimension, Dimension)>;
64 using ScrollFrameBeginCallback = std::function<ScrollFrameResult(Dimension, ScrollState)>;
65 using DragEndForRefreshCallback = std::function<void()>;
66 using DragCancelRefreshCallback = std::function<void()>;
67 using MouseLeftButtonScroll = std::function<bool()>;
68 using ContinuousSlidingCallback = std::function<double()>;
69 using StartSnapAnimationCallback = std::function<bool(SnapAnimationOptions)>;
70 using NeedScrollSnapToSideCallback = std::function<bool(float delta)>;
71 using NestableScrollCallback = std::function<ScrollResult(float, int32_t, NestedState)>;
72 using DragFRCSceneCallback = std::function<void(double velocity, NG::SceneStatus sceneStatus)>;
73 using IsReverseCallback = std::function<bool()>;
74 using RemainVelocityCallback = std::function<bool(float)>;
75 using GetSnapTypeCallback = std::function<SnapType()>;
76 using FixScrollParamCallback = std::function<void(float mainPos, float& correctVelocity, float& finalPos)>;
77 
78 class FrameNode;
79 class PipelineContext;
80 
81 class Scrollable : public TouchEventTarget {
82     DECLARE_ACE_TYPE(Scrollable, TouchEventTarget);
83 
84 public:
85     Scrollable() = default;
Scrollable(ScrollPositionCallback && callback,Axis axis)86     Scrollable(ScrollPositionCallback&& callback, Axis axis) : callback_(std::move(callback)), axis_(axis) {}
Scrollable(const ScrollPositionCallback & callback,Axis axis)87     Scrollable(const ScrollPositionCallback& callback, Axis axis) : callback_(callback), axis_(axis) {}
88     ~Scrollable() override;
89 
90     enum class AnimationState {
91         SPRING,
92         SNAP,
93         FRICTION,
94         TRANSITION, // in between two animations, i.e. from friction to spring
95         IDLE,
96     };
97 
98     static double GetVelocityScale();
99 
100     void Initialize(const RefPtr<FrameNode>& host);
101 
102     void InitAxisAnimator();
103 #ifdef SUPPORT_DIGITAL_CROWN
104     void ListenDigitalCrownEvent(const RefPtr<FrameNode>& frameNode);
SetDigitalCrownSensitivity(CrownSensitivity sensitivity)105     void SetDigitalCrownSensitivity(CrownSensitivity sensitivity)
106     {
107         crownSensitivity_ = sensitivity;
108     }
109 #endif
IsMotionStop()110     bool IsMotionStop() const
111     {
112         return state_ != AnimationState::SPRING && state_ != AnimationState::FRICTION && !moved_;
113     }
114 
IsSpringMotionRunning()115     bool IsSpringMotionRunning() const
116     {
117         return state_ == AnimationState::SPRING;
118     }
119 
IsDragging()120     bool IsDragging() const
121     {
122         return isTouching_ && state_ == AnimationState::FRICTION;
123     }
124 
125     void SetAxis(Axis axis);
126 
GetMainOffset(const Offset & offset)127     double GetMainOffset(const Offset& offset) const
128     {
129         return axis_ == Axis::HORIZONTAL ? offset.GetX() : offset.GetY();
130     }
131 
GetMainSize(const Size & size)132     double GetMainSize(const Size& size) const
133     {
134         return axis_ == Axis::HORIZONTAL ? size.Width() : size.Height();
135     }
136 
SetCallback(const ScrollPositionCallback & callback)137     void SetCallback(const ScrollPositionCallback& callback)
138     {
139         callback_ = callback;
140     }
141 
SetCoordinateOffset(const Offset & offset)142     void SetCoordinateOffset(const Offset& offset) const
143     {
144         if (panRecognizerNG_) {
145             panRecognizerNG_->SetCoordinateOffset(offset);
146         }
147     }
148 
149     void OnCollectTouchTarget(TouchTestResult& result, const RefPtr<FrameNode>& frameNode,
150         const RefPtr<TargetComponent>& targetComponent, ResponseLinkResult& responseLinkResult);
151 
SetDragTouchRestrict(const TouchRestrict & touchRestrict)152     void SetDragTouchRestrict(const TouchRestrict& touchRestrict)
153     {
154         if (panRecognizerNG_) {
155             panRecognizerNG_->SetTouchRestrict(touchRestrict);
156         }
157     }
158 
SetScrollEndCallback(const ScrollEventCallback & scrollEndCallback)159     void SetScrollEndCallback(const ScrollEventCallback& scrollEndCallback)
160     {
161         scrollEndCallback_ = scrollEndCallback;
162     }
163 
SetUnstaticFriction(double friction)164     void SetUnstaticFriction(double friction)
165     {
166         friction_ = friction > 0.0 ? friction : -1.0;
167     }
168 
GetFriction()169     double GetFriction() const
170     {
171         double friction = friction_;
172         if (friction == -1.0) {
173             double ret = SystemProperties::GetSrollableFriction();
174             friction = !NearZero(ret) ? ret : defaultFriction_;
175         }
176         return friction;
177     }
178 
GetRatio()179     float GetRatio() const
180     {
181         return ratio_;
182     }
183 
SetUnstaticVelocityScale(double scale)184     void SetUnstaticVelocityScale(double scale)
185     {
186         flingVelocityScale_ = scale;
187         springVelocityScale_ = scale;
188     }
189 
190     void HandleTouchDown(bool fromcrown = false);
191     void HandleTouchUp();
192     void HandleTouchCancel();
193     void HandleDragStart(const GestureEvent& info);
194     void HandleDragUpdate(const GestureEvent& info);
195     void HandleDragEnd(const GestureEvent& info, bool isFromPanEnd = false);
196     void HandleScrollEnd(const std::optional<float>& velocity);
197     bool HandleOverScroll(double velocity);
198     ScrollResult HandleScroll(double offset, int32_t source, NestedState state);
199     void ProcessAxisUpdateEvent(float mainDelta, bool fromScrollBar = false);
200     void ProcessAxisEndEvent();
201     void LayoutDirectionEst(double correctVelocity, double velocityScale, bool isScrollFromTouchPad);
202     void ReportToDragFRCScene(double velocity, NG::SceneStatus sceneStatus);
203 
SetMoved(bool value)204     void SetMoved(bool value)
205     {
206         moved_ = value;
207     }
SetCanOverScroll(bool value)208     void SetCanOverScroll(bool value)
209     {
210         canOverScroll_ = value;
211     }
CanOverScroll()212     bool CanOverScroll() const
213     {
214         return canOverScroll_;
215     }
216 
217     void ProcessScrollMotionStop();
218 
DispatchEvent(const TouchEvent & point)219     bool DispatchEvent(const TouchEvent& point) override
220     {
221         return true;
222     }
HandleEvent(const TouchEvent & event)223     bool HandleEvent(const TouchEvent& event) override
224     {
225         if (!available_) {
226             return true;
227         }
228         return true;
229     }
HandleEvent(const AxisEvent & event)230     bool HandleEvent(const AxisEvent& event) override
231     {
232         return false;
233     }
234 
SetRemainVelocityCallback(const RemainVelocityCallback & remainVelocityCallback)235     void SetRemainVelocityCallback(const RemainVelocityCallback& remainVelocityCallback)
236     {
237         remainVelocityCallback_ = remainVelocityCallback;
238     }
239 
SetScrollOverCallBack(const ScrollOverCallback & scrollOverCallback)240     void SetScrollOverCallBack(const ScrollOverCallback& scrollOverCallback)
241     {
242         scrollOverCallback_ = scrollOverCallback;
243     }
244 
SetNotifyScrollOverCallBack(const ScrollOverCallback & scrollOverCallback)245     void SetNotifyScrollOverCallBack(const ScrollOverCallback& scrollOverCallback)
246     {
247         notifyScrollOverCallback_ = scrollOverCallback;
248     }
249 
SetCurrentPositionCallback(const std::function<double ()> & currentPositionCallback)250     void SetCurrentPositionCallback(const std::function<double()>& currentPositionCallback)
251     {
252         currentPositionCallback_ = currentPositionCallback;
253     }
254 
SetOutBoundaryCallback(const OutBoundaryCallback & outBoundaryCallback)255     void SetOutBoundaryCallback(const OutBoundaryCallback& outBoundaryCallback)
256     {
257         outBoundaryCallback_ = outBoundaryCallback;
258     }
259 
SetDragEndCallback(const DragEndForRefreshCallback & dragEndCallback)260     void SetDragEndCallback(const DragEndForRefreshCallback& dragEndCallback)
261     {
262         dragEndCallback_ = dragEndCallback;
263     }
264 
SetDragCancelCallback(const DragCancelRefreshCallback & dragCancelCallback)265     void SetDragCancelCallback(const DragCancelRefreshCallback& dragCancelCallback)
266     {
267         dragCancelCallback_ = dragCancelCallback;
268     }
269 
GetDragEndCallback()270     const DragEndForRefreshCallback& GetDragEndCallback() const
271     {
272         return dragEndCallback_;
273     }
274 
GetDragCancelCallback()275     const DragCancelRefreshCallback& GetDragCancelCallback() const
276     {
277         return dragCancelCallback_;
278     }
279 
SetWatchFixCallback(const WatchFixCallback & watchFixCallback)280     void SetWatchFixCallback(const WatchFixCallback& watchFixCallback)
281     {
282         watchFixCallback_ = watchFixCallback;
283     }
284 
MarkNeedCenterFix(bool needFix)285     void MarkNeedCenterFix(bool needFix)
286     {
287         needCenterFix_ = needFix;
288     }
289 
GetCurrentVelocity()290     double GetCurrentVelocity() const
291     {
292         return currentVelocity_;
293     };
294 
SetIsReverseCallback(const IsReverseCallback & isReverseCallback)295     void SetIsReverseCallback(const IsReverseCallback& isReverseCallback)
296     {
297         isReverseCallback_ = isReverseCallback;
298     }
299 
300     void OnAnimateStop();
301     void ProcessScrollSnapStop();
302     void StartSpringMotion(
303         double mainPosition, double mainVelocity, const ExtentPair& extent, const ExtentPair& initExtent);
304     void UpdateSpringMotion(double mainPosition, const ExtentPair& extent, const ExtentPair& initExtent);
305 
306     void UpdateScrollSnapStartOffset(double offset);
307     void StartListSnapAnimation(float predictSnapOffset, float scrollSnapVelocity, bool fromScrollBar);
308     void UpdateScrollSnapEndWithOffset(double offset);
309 
310     bool IsAnimationNotRunning() const;
311 
312     bool Idle() const;
313 
314     bool IsStopped() const;
315 
316     bool IsSpringStopped() const;
317 
318     bool IsSnapStopped() const;
319 
320     void StopScrollable();
321 
Available()322     bool Available() const
323     {
324         return available_;
325     }
326 
MarkAvailable(bool available)327     void MarkAvailable(bool available)
328     {
329         available_ = available;
330     }
331 
GetContext()332     WeakPtr<PipelineContext> GetContext() const
333     {
334         return context_;
335     }
336 
SetNodeId(int32_t nodeId)337     void SetNodeId(int32_t nodeId)
338     {
339         nodeId_ = nodeId;
340     }
341 
GetNodeId()342     int32_t GetNodeId()
343     {
344         return nodeId_;
345     }
346 
SetNodeTag(const std::string & nodeTag)347     void SetNodeTag(const std::string& nodeTag)
348     {
349         nodeTag_ = nodeTag;
350     }
351 
GetNodeTag()352     const std::string& GetNodeTag() const
353     {
354         return nodeTag_;
355     }
356 
357     void ProcessScrollOverCallback(double velocity);
358 
359     void SetSlipFactor(double SlipFactor);
360 
SetOnScrollBegin(const ScrollBeginCallback & scrollBeginCallback)361     void SetOnScrollBegin(const ScrollBeginCallback& scrollBeginCallback)
362     {
363         scrollBeginCallback_ = scrollBeginCallback;
364     }
365 
SetOnContinuousSliding(const ContinuousSlidingCallback & continuousSlidingCallback)366     void SetOnContinuousSliding(const ContinuousSlidingCallback& continuousSlidingCallback)
367     {
368         continuousSlidingCallback_ = continuousSlidingCallback;
369     }
370 
SetGetSnapTypeCallback(const GetSnapTypeCallback & getSnapTypeCallback)371     void SetGetSnapTypeCallback(const GetSnapTypeCallback& getSnapTypeCallback)
372     {
373         getSnapTypeCallback_ = getSnapTypeCallback;
374     }
375 
376     std::optional<float> GetPredictSnapOffset() const;
377 
SetHandleScrollCallback(NestableScrollCallback && func)378     void SetHandleScrollCallback(NestableScrollCallback&& func)
379     {
380         handleScrollCallback_ = std::move(func);
381     }
SetOverScrollCallback(std::function<bool (float)> && func)382     void SetOverScrollCallback(std::function<bool(float)>&& func)
383     {
384         overScrollCallback_ = std::move(func);
385     }
386     void StartScrollAnimation(float mainPosition, float velocity, bool isScrollFromTouchPad = false);
SetOnScrollStartRec(std::function<void (float)> && func)387     void SetOnScrollStartRec(std::function<void(float)>&& func)
388     {
389         onScrollStartRec_ = std::move(func);
390     }
SetOnScrollEndRec(std::function<void (const std::optional<float> &)> && func)391     void SetOnScrollEndRec(std::function<void(const std::optional<float>&)>&& func)
392     {
393         onScrollEndRec_ = std::move(func);
394     }
395 
SetEdgeEffect(EdgeEffect effect)396     void SetEdgeEffect(EdgeEffect effect)
397     {
398         edgeEffect_ = effect;
399     }
400 
SetStartSnapAnimationCallback(const StartSnapAnimationCallback & startSnapAnimationCallback)401     void SetStartSnapAnimationCallback(const StartSnapAnimationCallback& startSnapAnimationCallback)
402     {
403         startSnapAnimationCallback_ = startSnapAnimationCallback;
404     }
405 
SetContinuousDragStatus(bool status)406     void SetContinuousDragStatus(bool status)
407     {
408         continuousDragStatus_ = status;
409     }
IncreaseContinueDragCount()410     void IncreaseContinueDragCount()
411     {
412         dragCount_++;
413     }
ResetContinueDragCount()414     void ResetContinueDragCount()
415     {
416         dragCount_ = 1;
417     }
SetDragStartPosition(double position)418     void SetDragStartPosition(double position)
419     {
420         dragStartPosition_ = position;
421     }
SetDragEndPosition(double position)422     void SetDragEndPosition(double position)
423     {
424         dragEndPosition_ = position;
425     }
GetDragOffset()426     double GetDragOffset()
427     {
428         return dragEndPosition_ - dragStartPosition_;
429     }
430 
SetNeedScrollSnapToSideCallback(NeedScrollSnapToSideCallback && needScrollSnapToSideCallback)431     void SetNeedScrollSnapToSideCallback(NeedScrollSnapToSideCallback&& needScrollSnapToSideCallback)
432     {
433         needScrollSnapToSideCallback_ = std::move(needScrollSnapToSideCallback);
434     }
435 
436     void StartScrollSnapAnimation(float scrollSnapDelta, float scrollSnapVelocity, bool fromScrollBar);
437 
StopSnapController()438     void StopSnapController()
439     {
440         if (state_ == AnimationState::SNAP) {
441             StopSnapAnimation();
442         }
443     }
444 
IsSnapAnimationRunning()445     bool IsSnapAnimationRunning()
446     {
447         return state_ == AnimationState::SNAP;
448     }
449 
IsAxisAnimationRunning()450     bool IsAxisAnimationRunning()
451     {
452         return axisAnimator_ && axisAnimator_->IsRunning();
453     }
454 
GetCurrentPos()455     double GetCurrentPos() const
456     {
457         return currentPos_;
458     }
459 
SetCurrentPos(float currentPos)460     void SetCurrentPos(float currentPos)
461     {
462         currentPos_ = currentPos;
463     }
464 
GetNeedScrollSnapChange()465     bool GetNeedScrollSnapChange() const
466     {
467         return needScrollSnapChange_;
468     }
469 
AddPreviewMenuHandleDragEnd(GestureEventFunc && actionEnd)470     void AddPreviewMenuHandleDragEnd(GestureEventFunc&& actionEnd)
471     {
472         AddPanActionEndEvent(std::move(actionEnd));
473     }
474 
GetIsDragging()475     bool GetIsDragging() const
476     {
477         return isDragging_;
478     }
479 
SetDragFRCSceneCallback(DragFRCSceneCallback && dragFRCSceneCallback)480     void SetDragFRCSceneCallback(DragFRCSceneCallback&& dragFRCSceneCallback)
481     {
482         dragFRCSceneCallback_ = std::move(dragFRCSceneCallback);
483     }
484 
GetFinalPosition()485     float GetFinalPosition()
486     {
487         return finalPosition_;
488     }
489 
GetSnapFinalPosition()490     float GetSnapFinalPosition()
491     {
492         return endPos_;
493     }
494 
495     void SetMaxFlingVelocity(double max);
496 
GetMaxFlingVelocity()497     double GetMaxFlingVelocity() const
498     {
499         return maxFlingVelocity_;
500     }
501 
RegisterFixScrollParamCallback(const FixScrollParamCallback & callback)502     void RegisterFixScrollParamCallback(const FixScrollParamCallback& callback)
503     {
504         fixScrollParamCallback_ = callback;
505     }
506 
507     void StopFrictionAnimation();
508     void StopSpringAnimation(bool reachFinalPosition = false);
509     void StopSnapAnimation();
510     void StopAxisAnimation();
511 
512     void AttachAnimatableProperty(const RefPtr<NodeAnimatablePropertyFloat>& property);
513     RefPtr<NodeAnimatablePropertyFloat> GetFrictionProperty();
514     RefPtr<NodeAnimatablePropertyFloat> GetSpringProperty();
515     RefPtr<NodeAnimatablePropertyFloat> GetSnapProperty();
516 
GetPanDirection()517     Axis GetPanDirection() const
518     {
519         CHECK_NULL_RETURN(panRecognizerNG_, Axis::NONE);
520         return panRecognizerNG_->GetAxisDirection();
521     }
522 
SetNestedScrolling(bool nestedScrolling)523     void SetNestedScrolling(bool nestedScrolling)
524     {
525         nestedScrolling_ = nestedScrolling;
526     }
527 
GetNestedScrolling()528     bool GetNestedScrolling() const
529     {
530         return nestedScrolling_;
531     }
532 
533 #ifdef SUPPORT_DIGITAL_CROWN
GetCrownEventDragging()534     bool GetCrownEventDragging() const
535     {
536         return isCrownEventDragging_;
537     }
538 
SetCrownEventDragging(bool draging)539     void SetCrownEventDragging(bool draging)
540     {
541         isCrownEventDragging_ = draging;
542     }
543 #endif
544 
SetOverScrollOffsetCallback(std::function<double ()> overScrollOffsetCallback)545     void SetOverScrollOffsetCallback(std::function<double()> overScrollOffsetCallback)
546     {
547         overScrollOffsetCallback_ = overScrollOffsetCallback;
548     }
549 
AddPanActionEndEvent(GestureEventFunc && event)550     void AddPanActionEndEvent(GestureEventFunc&& event)
551     {
552         panActionEndEvents_.emplace_back(event);
553     }
554 
GetSnapType()555     SnapType GetSnapType()
556     {
557         CHECK_NULL_RETURN(getSnapTypeCallback_, SnapType::NONE_SNAP);
558         return getSnapTypeCallback_();
559     }
560 
ResetSnapDirection()561     void ResetSnapDirection()
562     {
563         snapDirection_ = SnapDirection::NONE;
564     }
565 
566 private:
567     void InitPanRecognizerNG();
568     void SetOnActionStart();
569     void SetOnActionUpdate();
570     void SetOnActionEnd();
571     void SetOnActionCancel();
572     void SetPanEndCallback();
573     void ProcessPanActionEndEvents(const GestureEvent& info);
574     bool UpdateScrollPosition(double offset, int32_t source) const;
575     void ProcessSpringMotion(double position);
576     void ProcessScrollMotion(double position, int32_t source = SCROLL_FROM_ANIMATION);
577     void ProcessListSnapMotion(double position);
578     void TriggerFrictionAnimation(float mainPosition, float friction, float correctVelocity);
579     void FixScrollMotion(float position, float initVelocity);
580     void ExecuteScrollBegin(double& mainDelta);
581     double ComputeCap(int dragCount);
582     double GetGain(double delta);
583     void SetDelayedTask();
584     void MarkNeedFlushAnimationStartTime();
585     float GetFrictionVelocityByFinalPosition(
586         float final, float position, float signum, float friction, float threshold = DEFAULT_MULTIPLIER);
587     void InitFriction(double friction);
588     void CalcOverScrollVelocity();
589     double CalcNextStep(double position, double mainDelta);
590 
591 #ifdef SUPPORT_DIGITAL_CROWN
592     void HandleCrownEvent(const CrownEvent& event, const OffsetF& center);
593     void HandleCrownActionBegin(const TimeStamp& timeStamp, double mainDelta, GestureEvent& info);
594     void HandleCrownActionUpdate(const TimeStamp& timeStamp, double mainDelta, GestureEvent& info);
595     void HandleCrownActionEnd(const TimeStamp& timeStamp, double mainDelta, GestureEvent& info);
596     void HandleCrownActionCancel(GestureEvent& info);
597     double GetCrownRotatePx(const CrownEvent& event) const;
598     void UpdateCrownVelocity(const TimeStamp& timeStamp, double mainDelta, bool end);
599     void StartVibrateFeedback();
600 #endif
601 
602     /**
603      * @brief Checks if the scroll event is caused by a mouse wheel.
604      *
605      * @param info The GestureEvent containing the scroll event information.
606      * @return true if the scroll event is caused by a mouse wheel, false otherwise.
607      */
608     static inline bool IsMouseWheelScroll(const GestureEvent& info);
609 
610     ScrollPositionCallback callback_;
611     ScrollEventCallback scrollEndCallback_;
612     ScrollOverCallback scrollOverCallback_;       // scroll motion controller when edge set to spring
613     ScrollOverCallback notifyScrollOverCallback_; // scroll motion controller when edge set to spring
614     OutBoundaryCallback outBoundaryCallback_;     // whether out of boundary check when edge set to spring
615     std::function<double()> currentPositionCallback_;
616     IsReverseCallback isReverseCallback_;
617 
618     WatchFixCallback watchFixCallback_;
619     ScrollBeginCallback scrollBeginCallback_;
620     DragEndForRefreshCallback dragEndCallback_;
621     DragCancelRefreshCallback dragCancelCallback_;
622     ContinuousSlidingCallback continuousSlidingCallback_;
623     GetSnapTypeCallback getSnapTypeCallback_;
624     Axis axis_ = Axis::VERTICAL;
625     // used for ng structure.
626     RefPtr<NG::PanRecognizer> panRecognizerNG_;
627 
628     WeakPtr<FrameNode> weakHost_;
629     WeakPtr<PipelineContext> context_;
630     double currentPos_ = 0.0;
631     double currentVelocity_ = 0.0;
632     double maxFlingVelocity_ = 0.0;
633     bool scrollPause_ = false;
634     bool moved_ = false;
635     bool isTouching_ = false;
636     bool isDragging_ = false;
637     bool available_ = true;
638     bool needCenterFix_ = false;
639     bool isDragUpdateStop_ = false;
640     bool isFadingAway_ = false;
641     bool isCrownDragging_ = false;
642     // The accessibilityId of UINode
643     int32_t nodeId_ = 0;
644     // The tag of UINode
645     std::string nodeTag_ = "Scrollable";
646     double slipFactor_ = 0.0;
647     bool continuousDragStatus_ = false;
648     CancelableCallback<void()> task_;
649     int32_t dragCount_ = 0;
650     double lastPos_ = 0.0;
651     double dragStartPosition_ = 0.0;
652     double dragEndPosition_ = 0.0;
653     double lastGestureVelocity_ = 0.0;
654     double friction_ = -1.0;
655     double preGain_ = 1.0;
656 #ifdef OHOS_PLATFORM
657     int64_t startIncreaseTime_ = 0;
658 #endif
659 
660     // ScrollablePattern::HandleScroll
661     NestableScrollCallback handleScrollCallback_;
662     // ScrollablePattern::HandleOverScroll
663     std::function<bool(float)> overScrollCallback_;
664     // ScrollablePattern::onScrollStartRecursiveInner
665     std::function<void(float)> onScrollStartRec_;
666     // ScrollablePattern::onScrollEndRecursiveInner
667     std::function<void(const std::optional<float>&)> onScrollEndRec_;
668     // ScrollablePattern::RemainVelocityToChild
669     RemainVelocityCallback remainVelocityCallback_;
670 
671     EdgeEffect edgeEffect_ = EdgeEffect::NONE;
672     bool canOverScroll_ = true;
673 
674     // scrollSnap
675     bool needScrollSnapChange_ = false;
676     StartSnapAnimationCallback startSnapAnimationCallback_;
677     NeedScrollSnapToSideCallback needScrollSnapToSideCallback_;
678     std::list<GestureEventFunc> panActionEndEvents_;
679 
680     DragFRCSceneCallback dragFRCSceneCallback_;
681     FixScrollParamCallback fixScrollParamCallback_;
682     uint64_t lastVsyncTime_ = 0;
683     uint64_t lastAxisVsyncTime_ = 0; // only used in mouse wheel scenes
684     AnimationState state_ = AnimationState::IDLE;
685     RefPtr<NodeAnimatablePropertyFloat> frictionOffsetProperty_;
686     float finalPosition_ = 0.0f;
687     float lastPosition_ = 0.0f;
688     float initVelocity_ = 0.0f;
689     float frictionVelocity_ = 0.0f;
690     double lastMainDelta_ = 0.0;
691 
692     RefPtr<NodeAnimatablePropertyFloat> springOffsetProperty_;
693     bool skipRestartSpring_ = false; // set to true when need to skip repeated spring animation
694     uint32_t updateSnapAnimationCount_ = 0;
695     uint32_t springAnimationCount_ = 0;
696     double flingVelocityScale_ = 1.5;
697     double springVelocityScale_ = 1.5;
698     double defaultFriction_ = 0;
699     float ratio_ = 1.848f;
700     float springResponse_ = 0.416f;
701     float touchPadVelocityScaleRate_ = 1.0f;
702     std::function<double()> overScrollOffsetCallback_;
703 
704     RefPtr<NodeAnimatablePropertyFloat> snapOffsetProperty_;
705     bool snapAnimationFromScrollBar_ = false;
706     float snapVelocity_ = 0.0f;
707     float endPos_ = 0.0;
708     bool nestedScrolling_ = false;
709     float axisSnapDistance_ = 0.f;
710     SnapDirection snapDirection_ = SnapDirection::NONE;
711     bool isSlow_ = false;
712     std::optional<float> nextStep_;
713 
714     RefPtr<AxisAnimator> axisAnimator_;
715 #ifdef SUPPORT_DIGITAL_CROWN
716     CrownSensitivity crownSensitivity_ = CrownSensitivity::MEDIUM;
717     VelocityTracker crownVelocityTracker_;
718     Offset accumulativeCrownPx_;
719     bool isCrownEventDragging_ = false;
720 
721     int crownEventNum_ = 0;
722     bool reachBoundary_ = false;
723     CancelableCallback<void()> crownTask_;
724 #endif
725 };
726 
727 } // namespace OHOS::Ace::NG
728 
729 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SCROLL_SCROLLABLE_NG_H
730