UNPKG

@scrolia/react-native-reanimated

Version:

A set of reanimated components for Scrolia React Native

51 lines (47 loc) 1.5 kB
"use client"; import { useScrollCore } from "@scrolia/react-native/contexts/scrollcore"; import { getComponentProps } from "@scrolia/react-native/functions/props"; import { useThumbYHandler } 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"; /** * Vertical thumb component based on `react-native-reanimated`. * * **This component requires `react-native-reanimated` to be installed.** */ const ReanimatedThumbY = (props) => { const { options: { animated, plugins }, y: { setHvThumb, scrollbarLength, scrollbarOffset } } = useScrollCore(); const p = getComponentProps({ name: "thumbY", props, plugins }); React.useEffect(() => { setHvThumb(true); }, [setHvThumb]); const { panResponder } = useThumbYHandler(); if (animated) return /* @__PURE__ */ jsx(Reanimated.View, { ...p, ...panResponder.panHandlers, ref: p.ref, style: [p.style, { height: Number.isNaN(scrollbarLength) ? 0 : scrollbarLength, top: Number.isNaN(scrollbarOffset) ? 0 : scrollbarOffset }], children: p.children }); return /* @__PURE__ */ jsx(View, { ...p, ...panResponder.panHandlers, ref: p.ref, style: [p.style, { height: Number.isNaN(scrollbarLength) ? 0 : scrollbarLength, top: Number.isNaN(scrollbarOffset) ? 0 : scrollbarOffset }], children: p.children }); }; export { ReanimatedThumbY }; //# sourceMappingURL=y.mjs.map