rm findNodeHandle from tabbar
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import {ForwardedRef, useEffect, useMemo, useRef} from 'react'
|
import {type ForwardedRef, useEffect, useMemo, useRef} from 'react'
|
||||||
import type {ScrollView} from 'react-native'
|
import {type ScrollView} from 'react-native'
|
||||||
import {findNodeHandle, Platform} from 'react-native'
|
import {Platform} from 'react-native'
|
||||||
|
|
||||||
import {mergeRefs} from '#/lib/merge-refs'
|
import {mergeRefs} from '#/lib/merge-refs'
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ export function useDraggableScroll<Scrollable extends ScrollView = ScrollView>({
|
|||||||
if (Platform.OS !== 'web' || !ref.current) {
|
if (Platform.OS !== 'web' || !ref.current) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const slider = findNodeHandle(ref.current) as unknown as HTMLDivElement
|
const slider = ref.current as unknown as HTMLDivElement
|
||||||
if (!slider) {
|
if (!slider) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,25 @@
|
|||||||
import React, {ComponentProps} from 'react'
|
import {type ComponentPropsWithRef} from 'react'
|
||||||
import {ScrollView} from 'react-native'
|
import {ScrollView} from 'react-native'
|
||||||
|
|
||||||
import {useDraggableScroll} from '#/lib/hooks/useDraggableScrollView'
|
import {useDraggableScroll} from '#/lib/hooks/useDraggableScrollView'
|
||||||
|
import {atoms as a, web} from '#/alf'
|
||||||
|
|
||||||
export const DraggableScrollView = React.forwardRef<
|
export function DraggableScrollView({
|
||||||
ScrollView,
|
ref,
|
||||||
ComponentProps<typeof ScrollView>
|
style,
|
||||||
>(function DraggableScrollView(props, ref) {
|
...props
|
||||||
|
}: ComponentPropsWithRef<typeof ScrollView>) {
|
||||||
const {refs} = useDraggableScroll<ScrollView>({
|
const {refs} = useDraggableScroll<ScrollView>({
|
||||||
outerRef: ref,
|
outerRef: ref,
|
||||||
cursor: 'grab', // optional, default
|
cursor: 'grab', // optional, default
|
||||||
})
|
})
|
||||||
|
|
||||||
return <ScrollView ref={refs} horizontal {...props} />
|
return (
|
||||||
})
|
<ScrollView
|
||||||
|
ref={refs}
|
||||||
|
style={[style, web(a.user_select_none)]}
|
||||||
|
horizontal
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user