@scrolia/react-native-reanimated
Version:
A set of reanimated components for Scrolia React Native
50 lines (47 loc) • 1.5 kB
JavaScript
"use client";
import { useScrollCore } from "@scrolia/react-native/contexts/scrollcore";
import { getComponentProps } from "@scrolia/react-native/functions/props";
import { useThumbXHandler } from "@scrolia/react-native/hooks/thumb";
import * as React from "react";
import { View } from "react-native";
import Reanimated from "react-native-reanimated";
import { jsx } from "react/jsx-runtime";
/**
* Horizontal thumb component based on `react-native-reanimated`.
*
* **This component requires `react-native-reanimated` to be installed.**
*/
const ReanimatedThumbX = (props) => {
const { options: { animated, plugins }, x: { setHvThumb, scrollbarLength, scrollbarOffset } } = useScrollCore();
const p = getComponentProps({
name: "thumbX",
props,
plugins
});
React.useEffect(() => {
setHvThumb(true);
}, [setHvThumb]);
const { panResponder } = useThumbXHandler();
if (animated) return /* @__PURE__ */ jsx(Reanimated.View, {
...p,
...panResponder.panHandlers,
ref: p.ref,
style: [p.style, {
width: Number.isNaN(scrollbarLength) ? 0 : scrollbarLength,
left: Number.isNaN(scrollbarOffset) ? 0 : scrollbarOffset
}],
children: p.children
});
return /* @__PURE__ */ jsx(View, {
...p,
...panResponder.panHandlers,
ref: p.ref,
style: [p.style, {
width: Number.isNaN(scrollbarLength) ? 0 : scrollbarLength,
left: Number.isNaN(scrollbarOffset) ? 0 : scrollbarOffset
}],
children: p.children
});
};
export { ReanimatedThumbX };
//# sourceMappingURL=x.mjs.map