File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
packages/react-native-sdk/src/components Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change 1- import type { ReactNode } from 'react' ;
1+ import { type ReactNode , useRef } from 'react' ;
22import Animated , {
33 clamp ,
44 scrollTo ,
@@ -17,9 +17,28 @@ export const MarkdownReactiveScrollView = ({
1717 const contentWidth = useSharedValue ( 0 ) ;
1818 const visibleContentWidth = useSharedValue ( 0 ) ;
1919 const offsetBeforeScroll = useSharedValue ( 0 ) ;
20+ const touchStart = useSharedValue < { x : number ; y : number } | null > ( null ) ;
2021
2122 const panGesture = Gesture . Pan ( )
22- . activeOffsetX ( [ - 5 , 5 ] )
23+ . onBegin ( ( event ) => {
24+ touchStart . value = { x : event . x , y : event . y } ;
25+ } )
26+ . onTouchesMove ( ( event , state ) => {
27+ if ( ! touchStart . value || ! event . changedTouches . length ) {
28+ state . fail ( ) ;
29+ return ;
30+ }
31+
32+ const xDiff = Math . abs ( event . changedTouches [ 0 ] ! . x - touchStart . value . x ) ;
33+ const yDiff = Math . abs ( event . changedTouches [ 0 ] ! . y - touchStart . value . y ) ;
34+ const isHorizontalPanning = xDiff > yDiff ;
35+
36+ if ( isHorizontalPanning ) {
37+ state . activate ( ) ;
38+ } else {
39+ state . fail ( ) ;
40+ }
41+ } )
2342 . onUpdate ( ( event ) => {
2443 const { translationX } = event ;
2544
You can’t perform that action at this time.
0 commit comments