@scrolia/react-native-reanimated
Version:
A set of reanimated components for Scrolia React Native
1 lines • 3.25 kB
Source Map (JSON)
{"version":3,"file":"y.mjs","names":["props: ReanimatedThumbYProps","p: ReanimatedThumbYProps"],"sources":["../../src/thumb/y.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ViewProps } from \"react-native\";\n\nimport { useScrollCore } from \"@scrolia/react-native/contexts/scrollcore\";\nimport { getComponentProps } from \"@scrolia/react-native/functions/props\";\nimport { useThumbYHandler } from \"@scrolia/react-native/hooks/thumb\";\nimport * as React from \"react\";\nimport { View } from \"react-native\";\nimport Reanimated from \"react-native-reanimated\";\n\n/** Props for the `ReanimatedThumbY` component. */\ntype ReanimatedThumbYProps = ViewProps & {\n ref?: React.Ref<View>;\n};\n\n/**\n * Vertical thumb component based on `react-native-reanimated`.\n *\n * **This component requires `react-native-reanimated` to be installed.**\n */\nconst ReanimatedThumbY = (props: ReanimatedThumbYProps): React.JSX.Element => {\n const {\n options: { animated, plugins },\n y: { setHvThumb, scrollbarLength, scrollbarOffset },\n } = useScrollCore();\n\n const p: ReanimatedThumbYProps = 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 <Reanimated.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 </Reanimated.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 { ReanimatedThumbYProps };\nexport { ReanimatedThumbY };\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,MAAM,mBAAmB,CAACA,UAAoD;CAC1E,MAAM,EACF,SAAS,EAAE,UAAU,SAAS,EAC9B,GAAG,EAAE,YAAY,iBAAiB,iBAAiB,EACtD,GAAG,eAAe;CAEnB,MAAMC,IAA2B,kBAAkB;EAC/C,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,WAAW;EACR,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;GACW;AAI1B,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"}