Created
October 9, 2019 18:21
-
-
Save rotorgames/89b124dd85a5bd22c4ca7883183e17e1 to your computer and use it in GitHub Desktop.
Carousel Gestures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public override bool OnTouchEvent(MotionEvent e) | |
| { | |
| switch(e.Action) | |
| { | |
| case MotionEventActions.Down: | |
| case MotionEventActions.PointerDown: | |
| case MotionEventActions.Pointer2Down: | |
| if(Element?.Content != null && IsHorizontalScrollStarted()) | |
| Parent?.RequestDisallowInterceptTouchEvent(true); | |
| break; | |
| case MotionEventActions.Cancel: | |
| case MotionEventActions.Up: | |
| Parent?.RequestDisallowInterceptTouchEvent(false); | |
| break; | |
| } | |
| return base.OnTouchEvent(e); | |
| } | |
| bool IsHorizontalScrollStarted() | |
| { | |
| return //Return true is scroll is started; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public override void AddGestureRecognizer(UIGestureRecognizer gestureRecognizer) | |
| { | |
| base.AddGestureRecognizer(gestureRecognizer); | |
| if (gestureRecognizer is UIPanGestureRecognizer) | |
| gestureRecognizer.ShouldBeRequiredToFailBy = ShouldBeRequiredToFailBy; | |
| gestureRecognizer.ShouldRecognizeSimultaneously = ShouldRecognizeSimultaneously; | |
| } | |
| bool ShouldBeRequiredToFailBy(UIGestureRecognizer gestureRecognizer, UIGestureRecognizer otherGestureRecognizer) | |
| { | |
| if (IsHorizontalScrollStarted() && gestureRecognizer is UIPanGestureRecognizer && otherGestureRecognizer.View != this) | |
| return true; | |
| return false; | |
| } | |
| bool ShouldRecognizeSimultaneously(UIGestureRecognizer gestureRecognizer, UIGestureRecognizer otherGestureRecognizer) | |
| { | |
| return !IsHorizontalScrollStarted(); | |
| } | |
| bool IsHorizontalScrollStarted() | |
| { | |
| return // Return true is scroll is started; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment