UNPKG

@fruits-chain/react-native-xiaoshu

Version:
47 lines (46 loc) • 1.56 kB
"use strict"; import { memo, useCallback, useRef, useState } from 'react'; import { View, ScrollView } from 'react-native'; import Theme from "../theme/index.js"; import FloatingPanel from "./floating-panel.js"; import { varCreator, styleCreator } from "./style.js"; import { jsx as _jsx } from "react/jsx-runtime"; const FloatingPanelScrollView = ({ onAnimationEnd, children, ...restProps }) => { const TOKENS = Theme.useThemeTokens(); const CV = Theme.createVar(TOKENS, varCreator); const STYLES = Theme.createStyle(CV, styleCreator); const [scrollEnabled, setScrollEnabled] = useState(false); const scrollTopRef = useRef(0); const _onMoveShouldSetPanResponder = useCallback(() => { if (scrollTopRef.current > 0) { return false; } }, []); const _onAnimationEnd = useCallback(opened => { setScrollEnabled(opened); onAnimationEnd?.(opened); }, [onAnimationEnd]); const onScroll = useCallback(e => { scrollTopRef.current = e.nativeEvent.contentOffset.y; }, []); return /*#__PURE__*/_jsx(FloatingPanel, { ...restProps, _onMoveShouldSetPanResponder: _onMoveShouldSetPanResponder, onAnimationEnd: _onAnimationEnd, children: /*#__PURE__*/_jsx(View, { style: STYLES.wrapper, children: /*#__PURE__*/_jsx(ScrollView, { scrollEventThrottle: 16, scrollEnabled: scrollEnabled, onScroll: onScroll, children: children }) }) }); }; export default /*#__PURE__*/memo(FloatingPanelScrollView); //# sourceMappingURL=floating-panel-scroll-view.js.map