UNPKG

@scrolia/react-native-reanimated

Version:

A set of reanimated components for Scrolia React Native

1 lines 3.19 kB
{"version":3,"file":"y.mjs","names":["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,oBAAoB,UAAoD;CAC1E,MAAM,EACF,SAAS,EAAE,UAAU,WACrB,GAAG,EAAE,YAAY,iBAAiB,sBAClC,eAAe;CAEnB,MAAMA,IAA2B,kBAAkB;EAC/C,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,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;GACT,CACJ;YAEA,EAAE;GACW;AAI1B,QACI,oBAAC;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;GAC5C,CACJ;YAEA,EAAE;GACA"}