[NUI] Change InterceptTouchEvent.
authorJoogab Yun <joogab.yun@samsung.com>
Fri, 9 Jul 2021 03:01:12 +0000 (12:01 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Mon, 19 Jul 2021 09:01:03 +0000 (18:01 +0900)
src/Tizen.NUI.Components/Controls/ScrollableBase.cs

index 9405f47..3c894ba 100755 (executable)
@@ -293,10 +293,12 @@ namespace Tizen.NUI.Components
                     if (mScrollEnabled)
                     {
                         mPanGestureDetector.Detected += OnPanGestureDetected;
+                        this.InterceptTouchEvent += OnInterruptTouchingChildTouched;
                     }
                     else
                     {
                         mPanGestureDetector.Detected -= OnPanGestureDetected;
+                        this.InterceptTouchEvent -= OnInterruptTouchingChildTouched;
                     }
                 }
             }
@@ -585,6 +587,7 @@ namespace Tizen.NUI.Components
         private PropertyNotification propertyNotification;
         private float noticeAnimationEndBeforePosition = 0.0f;
         private bool readyToNotice = false;
+        private bool shouldIntercept = false;
 
         /// <summary>
         /// Notice before animation is finished.
@@ -635,6 +638,8 @@ namespace Tizen.NUI.Components
             mPanGestureDetector.AddDirection(PanGestureDetector.DirectionVertical);
             if (mPanGestureDetector.GetMaximumTouchesRequired() < 2) mPanGestureDetector.SetMaximumTouchesRequired(2);
             mPanGestureDetector.Detected += OnPanGestureDetected;
+            //Interrupt touching when panning is started
+            this.InterceptTouchEvent += OnInterruptTouchingChildTouched;
 
             ClippingMode = ClippingModeType.ClipToBoundingBox;
 
@@ -703,7 +708,7 @@ namespace Tizen.NUI.Components
                     StopScroll();
                 }
             }
-            return true;
+            return shouldIntercept;
         }
 
         private void OnPropertyChanged(object source, PropertyNotification.NotifyEventArgs args)
@@ -848,8 +853,6 @@ namespace Tizen.NUI.Components
         private void OnScrollAnimationEnded()
         {
             scrolling = false;
-            this.InterceptTouchEvent -= OnInterruptTouchingChildTouched;
-
             ScrollEventArgs eventArgs = new ScrollEventArgs(ContentContainer.CurrentPosition);
             ScrollAnimationEnded?.Invoke(this, eventArgs);
         }
@@ -1030,6 +1033,7 @@ namespace Tizen.NUI.Components
                     mPanGestureDetector.Dispose();
                     mPanGestureDetector = null;
                 }
+                this.InterceptTouchEvent -= OnInterruptTouchingChildTouched;
 
                 propertyNotification.Dispose();
             }
@@ -1340,9 +1344,8 @@ namespace Tizen.NUI.Components
 
             if (panGesture.State == Gesture.StateType.Started)
             {
+                shouldIntercept = false;
                 readyToNotice = false;
-                //Interrupt touching when panning is started
-                this.InterceptTouchEvent += OnInterruptTouchingChildTouched;
                 AttachOverShootingShadowView();
                 Debug.WriteLineIf(LayoutDebugScrollableBase, "Gesture Start");
                 if (scrolling && !SnapToPage)
@@ -1354,6 +1357,7 @@ namespace Tizen.NUI.Components
             }
             else if (panGesture.State == Gesture.StateType.Continuing)
             {
+                shouldIntercept = true;
                 if (ScrollingDirection == Direction.Horizontal)
                 {
                     // if vertical shadow is shown, does not scroll.
@@ -1414,6 +1418,7 @@ namespace Tizen.NUI.Components
                 totalDisplacementForPan = 0;
                 scrolling = true;
                 readyToNotice = true;
+                shouldIntercept = false;
                 OnScrollAnimationStarted();
             }
         }