Skip to content

Commit

Permalink
chore: 修改事件驱动
Browse files Browse the repository at this point in the history
  • Loading branch information
lareinayanyu committed Dec 19, 2024
1 parent e20f0c2 commit 7190d47
Showing 1 changed file with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import Animated, {
useAnimatedReaction,
withSpring
} from 'react-native-reanimated'
import { collectDataset } from '@mpxjs/utils'
import { noop } from '@mpxjs/utils'

interface MovableViewProps {
children: ReactNode;
Expand Down Expand Up @@ -105,20 +105,10 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
'simultaneous-handlers': originSimultaneousHandlers = [],
'wait-for': waitFor = [],
style = {},
bindtouchstart,
catchtouchstart,
bindhtouchmove,
bindvtouchmove,
bindtouchmove,
catchhtouchmove,
catchvtouchmove,
catchtouchmove,
bindtouchend,
catchtouchend,
bindlongpress,
catchlongpress,
bindtap,
catchtap
catchvtouchmove
} = props

const {
Expand Down Expand Up @@ -354,17 +344,17 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
})
})
Object.assign(e, {
stopPropagation: () => {},
preventDefault: () => {},
persist: () => {},
nativeEvent: {
timestamp: 0,
pageX: e.changedTouches[0].absoluteX,
pageY: e.changedTouches[0].absoluteY,
touches: e.allTouches,
changedTouches: e.changedTouches
},
touches: e.allTouches
touches: e.allTouches,
stopPropagation: noop,
preventDefault: noop,
persist: noop
}, obj)
}, [])

Expand Down Expand Up @@ -403,11 +393,18 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP

const innerProps = useInnerProps(props, {}, [], {
layoutRef
})
}) as {
onTouchStart?: (e: GestureTouchEvent) => void;
onTouchStartCapture?: (e: GestureTouchEvent) => void;
onTouchMove?: (e: GestureTouchEvent) => void;
onTouchMoveCapture?: (e: GestureTouchEvent) => void;
onTouchEnd?: (e: GestureTouchEvent) => void;
onTouchEndCapture?: (e: GestureTouchEvent) => void;
}
const gesture = useMemo(() => {
const handleTriggerMove = (e: GestureTouchEvent) => {
'worklet'
const hasTouchmove = !!bindhtouchmove || !!bindvtouchmove || !!innerProps.onTouchMove || innerProps.onTouchMoveCapture
const hasTouchmove = !!bindhtouchmove || !!bindvtouchmove || !!innerProps.onTouchMove || !!innerProps.onTouchMoveCapture
const hasCatchTouchmove = !!catchhtouchmove || !!catchvtouchmove
if (hasTouchmove || hasCatchTouchmove) {
runOnJS(triggerMoveOnJS)({
Expand Down

0 comments on commit 7190d47

Please sign in to comment.