123456789101112131415161718192021222324252627282930313233343536 |
- import { __assign, __rest } from "tslib";
- import * as React from 'react';
- import { fullWidthClassName, zeroRightClassName } from 'react-remove-scroll-bar/constants';
- import { useMergeRefs } from 'use-callback-ref';
- import { effectCar } from './medium';
- var nothing = function () {
- return;
- };
- /**
- * Removes scrollbar from the page and contain the scroll within the Lock
- */
- var RemoveScroll = React.forwardRef(function (props, parentRef) {
- var ref = React.useRef(null);
- var _a = React.useState({
- onScrollCapture: nothing,
- onWheelCapture: nothing,
- onTouchMoveCapture: nothing,
- }), callbacks = _a[0], setCallbacks = _a[1];
- var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? 'div' : _b, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as"]);
- var SideCar = sideCar;
- var containerRef = useMergeRefs([ref, parentRef]);
- var containerProps = __assign(__assign({}, rest), callbacks);
- return (React.createElement(React.Fragment, null,
- enabled && (React.createElement(SideCar, { sideCar: effectCar, removeScrollBar: removeScrollBar, shards: shards, noIsolation: noIsolation, inert: inert, setCallbacks: setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref })),
- forwardProps ? (React.cloneElement(React.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef }))) : (React.createElement(Container, __assign({}, containerProps, { className: className, ref: containerRef }), children))));
- });
- RemoveScroll.defaultProps = {
- enabled: true,
- removeScrollBar: true,
- inert: false,
- };
- RemoveScroll.classNames = {
- fullWidth: fullWidthClassName,
- zeroRight: zeroRightClassName,
- };
- export { RemoveScroll };
|