@scrolia/react-native
Version:
A headless scrollbar component
1 lines • 2.88 kB
Source Map (JSON)
{"version":3,"file":"y.mjs","names":[],"sources":["../../../src/components/thumb/y.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ViewProps } from \"react-native\";\n\nimport * as React from \"react\";\nimport { Animated, View } from \"react-native\";\n\nimport { useScrollCore } from \"#/contexts/scrollcore\";\nimport { getComponentProps } from \"#/functions/props\";\nimport { useThumbYHandler } from \"#/hooks/thumb\";\n\n/** Props for the `ThumbY` component. */\ntype ThumbYProps = ViewProps & {\n ref?: React.Ref<View>;\n};\n\n/** Vertical thumb component. */\nconst ThumbY = (props: ThumbYProps): React.JSX.Element => {\n const {\n options: { animated, plugins },\n y: { setHvThumb, scrollbarLength, scrollbarOffset },\n } = useScrollCore();\n\n const p: ThumbYProps = getComponentProps({\n name: \"thumbY\",\n props,\n plugins,\n });\n\n React.useEffect((): void => {\n setHvThumb(true);\n }, [\n setHvThumb,\n ]);\n\n const { panResponder } = useThumbYHandler();\n\n if (animated) {\n return (\n <Animated.View\n {...p}\n {...panResponder.panHandlers}\n ref={p.ref}\n style={[\n p.style,\n {\n height: Number.isNaN(scrollbarLength)\n ? 0\n : scrollbarLength,\n top: Number.isNaN(scrollbarOffset)\n ? 0\n : scrollbarOffset,\n },\n ]}\n >\n {p.children}\n </Animated.View>\n );\n }\n\n return (\n <View\n {...p}\n {...panResponder.panHandlers}\n ref={p.ref}\n style={[\n p.style,\n {\n height: Number.isNaN(scrollbarLength) ? 0 : scrollbarLength,\n top: Number.isNaN(scrollbarOffset) ? 0 : scrollbarOffset,\n },\n ]}\n >\n {p.children}\n </View>\n );\n};\n\nexport type { ThumbYProps };\nexport { ThumbY };\n"],"mappings":";;;;;;;;;;AAiBA,MAAM,UAAU,UAA0C;CACtD,MAAM,EACF,SAAS,EAAE,UAAU,WACrB,GAAG,EAAE,YAAY,iBAAiB,sBAClC,eAAe;CAEnB,MAAM,IAAiB,kBAAkB;EACrC,MAAM;EACN;EACA;EACH,CAAC;AAEF,OAAM,gBAAsB;AACxB,aAAW,KAAK;IACjB,CACC,WACH,CAAC;CAEF,MAAM,EAAE,iBAAiB,kBAAkB;AAE3C,KAAI,SACA,QACI,oBAAC,SAAS,MAAV;EACI,GAAI;EACJ,GAAI,aAAa;EACjB,KAAK,EAAE;EACP,OAAO,CACH,EAAE,OACF;GACI,QAAQ,OAAO,MAAM,gBAAgB,GAC/B,IACA;GACN,KAAK,OAAO,MAAM,gBAAgB,GAC5B,IACA;GACT,CACJ;YAEA,EAAE;EACS;AAIxB,QACI,oBAAC,MAAD;EACI,GAAI;EACJ,GAAI,aAAa;EACjB,KAAK,EAAE;EACP,OAAO,CACH,EAAE,OACF;GACI,QAAQ,OAAO,MAAM,gBAAgB,GAAG,IAAI;GAC5C,KAAK,OAAO,MAAM,gBAAgB,GAAG,IAAI;GAC5C,CACJ;YAEA,EAAE;EACA"}