From e8b054ecf9828f4432efa8421ebef57101bf6b3c Mon Sep 17 00:00:00 2001 From: neostom432 <31119276+neostom432@users.noreply.github.com> Date: Tue, 21 Jan 2020 11:21:33 +0900 Subject: [PATCH] [NUI] Add/change scroll event (#1331) * [NUI] Add/change scroll event ScrollStartDragEvent - Emitted when panning is start ScrollEndDragEvent - Emitted when panning is end ScrollAnimationStartEvent - Emitted when scroll animation is start ScrollAnimationEndEvent - Emitted when scroll animation is end * [NUI] change name of scroll event and its comment Co-authored-by: krown --- .../Controls/ScrollableBase.cs | 55 +++++++++++++++++----- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs index 1e64db7..42b780b 100755 --- a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs +++ b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs @@ -281,20 +281,39 @@ namespace Tizen.NUI.Components } /// - /// An event emitted when the scrolling starts, user can subscribe or unsubscribe to this event handler.
+ /// An event emitted when user starts dragging ScrollableBase, user can subscribe or unsubscribe to this event handler.
///
/// 6 /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API [EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandler ScrollStartedEvent; + public event EventHandler ScrollDragStartEvent; /// - /// An event emitted when the scrolling ends, user can subscribe or unsubscribe to this event handler.
+ /// An event emitted when user stops dragging ScrollableBase, user can subscribe or unsubscribe to this event handler.
///
/// 6 /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API [EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandler ScrollEndedEvent; + public event EventHandler ScrollDragEndEvent; + + + /// + /// An event emitted when the scrolling slide animation starts, user can subscribe or unsubscribe to this event handler.
+ ///
+ /// 6 + /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler ScrollAnimationStartEvent; + + /// + /// An event emitted when the scrolling slide animation ends, user can subscribe or unsubscribe to this event handler.
+ ///
+ /// 6 + /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler ScrollAnimationEndEvent; + + private Animation scrollAnimation; private float maxScrollDistance; @@ -362,16 +381,28 @@ namespace Tizen.NUI.Components mScrollingChild = new View(); } - private void OnScrollStart() + private void OnScrollDragStart() + { + ScrollEventArgs eventArgs = new ScrollEventArgs(); + ScrollDragStartEvent?.Invoke(this, eventArgs); + } + + private void OnScrollDragEnd() + { + ScrollEventArgs eventArgs = new ScrollEventArgs(); + ScrollDragEndEvent?.Invoke(this, eventArgs); + } + + private void OnScrollAnimationStart() { ScrollEventArgs eventArgs = new ScrollEventArgs(); - ScrollStartedEvent?.Invoke(this, eventArgs); + ScrollAnimationStartEvent?.Invoke(this, eventArgs); } - private void OnScrollEnd() + private void OnScrollAnimationEnd() { ScrollEventArgs eventArgs = new ScrollEventArgs(); - ScrollEndedEvent?.Invoke(this, eventArgs); + ScrollAnimationEndEvent?.Invoke(this, eventArgs); } private void StopScroll() @@ -382,7 +413,7 @@ namespace Tizen.NUI.Components { Debug.WriteLineIf(LayoutDebugScrollableBase, "StopScroll Animation Playing"); scrollAnimation.Stop(Animation.EndActions.Cancel); - OnScrollEnd(); + OnScrollAnimationEnd(); } scrollAnimation.Clear(); } @@ -417,7 +448,7 @@ namespace Tizen.NUI.Components scrollAnimation.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSine); scrollAnimation.AnimateTo(mScrollingChild, (ScrollingDirection == Direction.Horizontal) ? "PositionX" : "PositionY", axisPosition); scrolling = true; - OnScrollStart(); + OnScrollAnimationStart(); scrollAnimation.Play(); } @@ -625,6 +656,7 @@ namespace Tizen.NUI.Components } maxScrollDistance = CalculateMaximumScrollDistance(); totalDisplacementForPan = 0.0f; + OnScrollDragStart(); } else if (e.PanGesture.State == Gesture.StateType.Continuing) { @@ -647,6 +679,7 @@ namespace Tizen.NUI.Components float flickDisplacement = CalculateDisplacementFromVelocity(axisVelocity); Debug.WriteLineIf(LayoutDebugScrollableBase, "FlickDisplacement:" + flickDisplacement + "TotalDisplacementForPan:" + totalDisplacementForPan); + OnScrollDragEnd(); if (flickDisplacement > 0 | flickDisplacement < 0)// Flick detected { @@ -680,7 +713,7 @@ namespace Tizen.NUI.Components private void ScrollAnimationFinished(object sender, EventArgs e) { scrolling = false; - OnScrollEnd(); + OnScrollAnimationEnd(); } } -- 2.7.4