From 8c5dd17225591d5318e76e085e5d36fc3d256f30 Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Fri, 15 Oct 2021 13:57:15 +0900 Subject: [PATCH] [NUI] Check if pan gesture need to propagation If it's a nested scroll, calculate whether the gesture should be sent to the parent. --- .../Controls/ScrollableBase.cs | 30 ++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs index 98078bf..d0f323a 100755 --- a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs +++ b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs @@ -1329,25 +1329,19 @@ namespace Tizen.NUI.Components private void OnPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e) { - OnPanGesture(e.PanGesture); - if(!((SnapToPage && scrollAnimation != null && scrollAnimation.State == Animation.States.Playing) || e.PanGesture.State == Gesture.StateType.Started)) - { - e.Handled = !((int)finalTargetPosition == 0 || -(int)finalTargetPosition == (int)maxScrollDistance); - } + e.Handled = OnPanGesture(e.PanGesture); } - private void OnPanGesture(PanGesture panGesture) + private bool OnPanGesture(PanGesture panGesture) { + bool handled = true; if (SnapToPage && scrollAnimation != null && scrollAnimation.State == Animation.States.Playing) { - return; + return handled; } - if (panGesture.State == Gesture.StateType.Started) { readyToNotice = false; - //Interrupt touching when panning is started - this.InterceptTouchEvent += OnInterruptTouchingChildTouched; AttachOverShootingShadowView(); Debug.WriteLineIf(LayoutDebugScrollableBase, "Gesture Start"); if (scrolling && !SnapToPage) @@ -1355,6 +1349,21 @@ namespace Tizen.NUI.Components StopScroll(); } totalDisplacementForPan = 0.0f; + + // check if gesture need to propagation + var checkDisplacement = (ScrollingDirection == Direction.Horizontal) ? panGesture.Displacement.X : panGesture.Displacement.Y; + var checkChildCurrentPosition = (ScrollingDirection == Direction.Horizontal) ? ContentContainer.PositionX : ContentContainer.PositionY; + var checkChildTargetPosition = checkChildCurrentPosition + checkDisplacement; + var checkFinalTargetPosition = BoundScrollPosition(checkChildTargetPosition); + handled = !((int)checkFinalTargetPosition == 0 || -(int)checkFinalTargetPosition == (int)maxScrollDistance); + // If you propagate a gesture event, return; + if(!handled) + { + return handled; + } + + //Interrupt touching when panning is started + this.InterceptTouchEvent += OnInterruptTouchingChildTouched; OnScrollDragStarted(); } else if (panGesture.State == Gesture.StateType.Continuing) @@ -1421,6 +1430,7 @@ namespace Tizen.NUI.Components readyToNotice = true; OnScrollAnimationStarted(); } + return handled; } internal void BaseRemove(View view) -- 2.7.4