@fruits-chain/react-native-xiaoshu
Version:
🌈 React Native UI library
52 lines (51 loc) • 1.95 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _index = _interopRequireDefault(require("../theme/index.js"));
var _floatingPanel = _interopRequireDefault(require("./floating-panel.js"));
var _style = require("./style.js");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const FloatingPanelScrollView = ({
onAnimationEnd,
children,
...restProps
}) => {
const TOKENS = _index.default.useThemeTokens();
const CV = _index.default.createVar(TOKENS, _style.varCreator);
const STYLES = _index.default.createStyle(CV, _style.styleCreator);
const [scrollEnabled, setScrollEnabled] = (0, _react.useState)(false);
const scrollTopRef = (0, _react.useRef)(0);
const _onMoveShouldSetPanResponder = (0, _react.useCallback)(() => {
if (scrollTopRef.current > 0) {
return false;
}
}, []);
const _onAnimationEnd = (0, _react.useCallback)(opened => {
setScrollEnabled(opened);
onAnimationEnd?.(opened);
}, [onAnimationEnd]);
const onScroll = (0, _react.useCallback)(e => {
scrollTopRef.current = e.nativeEvent.contentOffset.y;
}, []);
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_floatingPanel.default, {
...restProps,
_onMoveShouldSetPanResponder: _onMoveShouldSetPanResponder,
onAnimationEnd: _onAnimationEnd,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: STYLES.wrapper,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
scrollEventThrottle: 16,
scrollEnabled: scrollEnabled,
onScroll: onScroll,
children: children
})
})
});
};
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(FloatingPanelScrollView);
//# sourceMappingURL=floating-panel-scroll-view.js.map
;