UNPKG

@scrolia/react-native-reanimated

Version:

A set of reanimated components for Scrolia React Native

1 lines 2.1 kB
{"version":3,"file":"x.mjs","names":["props: ReanimatedTrackXProps","p: ReanimatedTrackXProps"],"sources":["../../src/track/x.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 * as React from \"react\";\nimport { View } from \"react-native\";\nimport Reanimated from \"react-native-reanimated\";\n\n/** Props for the `ReanimatedTrackX` component. */\ntype ReanimatedTrackXProps = ViewProps & {\n ref?: React.Ref<View>;\n};\n\n/**\n * Horizontal track component based on `react-native-reanimated`.\n *\n * **This component requires `react-native-reanimated` to be installed.**\n */\nconst ReanimatedTrackX = (props: ReanimatedTrackXProps): React.JSX.Element => {\n const {\n options: { disabled, animated, plugins },\n x: { setHvTrack },\n } = useScrollCore();\n\n const p: ReanimatedTrackXProps = getComponentProps({\n name: \"trackX\",\n props,\n plugins,\n });\n\n React.useEffect((): void => {\n setHvTrack(true);\n }, [\n setHvTrack,\n ]);\n\n if (disabled) return <>{}</>;\n\n if (animated) {\n return (\n <Reanimated.View\n {...p}\n ref={p.ref}\n >\n {p.children}\n </Reanimated.View>\n );\n }\n\n return (\n <View\n {...p}\n ref={p.ref}\n >\n {p.children}\n </View>\n );\n};\n\nexport type { ReanimatedTrackXProps };\nexport { ReanimatedTrackX };\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,MAAM,mBAAmB,CAACA,UAAoD;CAC1E,MAAM,EACF,SAAS,EAAE,UAAU,UAAU,SAAS,EACxC,GAAG,EAAE,YAAY,EACpB,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;AAEF,KAAI,SAAU,yCAAc;AAE5B,KAAI,SACA,4BACK,WAAW;EACR,GAAI;EACJ,KAAK,EAAE;YAEN,EAAE;GACW;AAI1B,4BACK;EACG,GAAI;EACJ,KAAK,EAAE;YAEN,EAAE;GACA;AAEd"}