PromoCursed/node_modules/.cache/babel-loader/51f6f90faed63b1f83f119f0fffd7eb613ccd460ea31d5fc43cf9c183819bab2.json

1 line
27 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport classNames from 'classnames';\nimport raf from \"rc-util/es/raf\";\nimport * as React from 'react';\nfunction getPageXY(e, horizontal) {\n var obj = 'touches' in e ? e.touches[0] : e;\n return obj[horizontal ? 'pageX' : 'pageY'];\n}\nvar ScrollBar = /*#__PURE__*/React.forwardRef(function (props, ref) {\n var prefixCls = props.prefixCls,\n rtl = props.rtl,\n scrollOffset = props.scrollOffset,\n scrollRange = props.scrollRange,\n onStartMove = props.onStartMove,\n onStopMove = props.onStopMove,\n onScroll = props.onScroll,\n horizontal = props.horizontal,\n spinSize = props.spinSize,\n containerSize = props.containerSize,\n style = props.style,\n propsThumbStyle = props.thumbStyle;\n var _React$useState = React.useState(false),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n dragging = _React$useState2[0],\n setDragging = _React$useState2[1];\n var _React$useState3 = React.useState(null),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n pageXY = _React$useState4[0],\n setPageXY = _React$useState4[1];\n var _React$useState5 = React.useState(null),\n _React$useState6 = _slicedToArray(_React$useState5, 2),\n startTop = _React$useState6[0],\n setStartTop = _React$useState6[1];\n var isLTR = !rtl;\n\n // ========================= Refs =========================\n var scrollbarRef = React.useRef();\n var thumbRef = React.useRef();\n\n // ======================= Visible ========================\n var _React$useState7 = React.useState(false),\n _React$useState8 = _slicedToArray(_React$useState7, 2),\n visible = _React$useState8[0],\n setVisible = _React$useState8[1];\n var visibleTimeoutRef = React.useRef();\n var delayHidden = function delayHidden() {\n clearTimeout(visibleTimeoutRef.current);\n setVisible(true);\n visibleTimeoutRef.current = setTimeout(function () {\n setVisible(false);\n }, 3000);\n };\n\n // ======================== Range =========================\n var enableScrollRange = scrollRange - containerSize || 0;\n var enableOffsetRange = containerSize - spinSize || 0;\n\n // ========================= Top ==========================\n var top = React.useMemo(function () {\n if (scrollOffset === 0 || enableScrollRange === 0) {\n return 0;\n }\n var ptg = scrollOffset / enableScrollRange;\n return ptg * enableOffsetRange;\n }, [scrollOffset, enableScrollRange, enableOffsetRange]);\n\n // ====================== Container =======================\n var onContainerMouseDown = function onContainerMouseDown(e) {\n e.stopPropagation();\n e.preventDefault();\n };\n\n // ======================== Thumb =========================\n var stateRef = React.useRef({\n top: top,\n dragging: dragging,\n pageY: pageXY,\n startTop: startTop\n });\n stateRef.current = {\n top: top,\n dragging: dragging,\n pageY: pageXY,\n startTop: startTop\n };\n var onThumbMouseDown = function onThumbMouseDown(e) {\n setDragging(true);\n setPageXY(getPageXY(e, horizontal));\n setStartTop(stateRef.current.top);\n onStartMove();\n e.stopPropagation();\n e.preventDefault();\n };\n\n // ======================== Effect ========================\n\n // React make event as passive, but we need to preventDefault\n // Add event on dom directly instead.\n // ref: https://github.com/facebook/react/issues/9809\n React.useEffect(function () {\n var onScrollbarTouchStart = function onScrollbarTouchStart(e) {\n e.preventDefault();\n };\n var scrollbarEle = scrollbarRef.current;\n var thumbEle = thumbRef.current;\n scrollbarEle.addEventListener('touchstart', onScrollbarTouchStart, {\n passive: false\n });\n thumbEle.addEventListener('touchstart', onThumbMouseDown, {\n passive: false\n