UNPKG

@scrolia/react-native

Version:
1 lines 2.94 kB
{"version":3,"file":"y.mjs","names":["props: ThumbYProps","p: ThumbYProps"],"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,SAAS,CAACA,UAA0C;CACtD,MAAM,EACF,SAAS,EAAE,UAAU,SAAS,EAC9B,GAAG,EAAE,YAAY,iBAAiB,iBAAiB,EACtD,GAAG,eAAe;CAEnB,MAAMC,IAAiB,kBAAkB;EACrC,MAAM;EACN;EACA;CACH,EAAC;CAEF,MAAM,UAAU,MAAY;EACxB,WAAW,KAAK;CACnB,GAAE,CACC,UACH,EAAC;CAEF,MAAM,EAAE,cAAc,GAAG,kBAAkB;AAE3C,KAAI,SACA,4BACK,SAAS;EACN,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;EACT,CACJ;YAEA,EAAE;GACS;AAIxB,4BACK;EACG,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;EAC5C,CACJ;YAEA,EAAE;GACA;AAEd"}