about summary refs log tree commit diff
path: root/src/view/com/pager/DraggableScrollView.tsx
blob: c98e340548cda112faacbde2e773384a2d956537 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import {type ComponentPropsWithRef} from 'react'
import {ScrollView} from 'react-native'

import {useDraggableScroll} from '#/lib/hooks/useDraggableScrollView'
import {atoms as a, web} from '#/alf'

export function DraggableScrollView({
  ref,
  style,
  ...props
}: ComponentPropsWithRef<typeof ScrollView>) {
  const {refs} = useDraggableScroll<ScrollView>({
    outerRef: ref,
    cursor: 'grab', // optional, default
  })

  return (
    <ScrollView
      ref={refs}
      style={[style, web(a.user_select_none)]}
      horizontal
      {...props}
    />
  )
}