PromoCursed/node_modules/.cache/babel-loader/71bdb9cc4e6b2ee69bc3647708ccaa95302af42b6ce0c13b8bb0802b095e3d17.json
2024-08-20 23:25:37 +04:00

1 line
13 KiB
JSON

{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useEffect, useRef, useState } from 'react';\nfunction getPosition(e) {\n var obj = 'touches' in e ? e.touches[0] : e;\n var scrollXOffset = document.documentElement.scrollLeft || document.body.scrollLeft || window.pageXOffset;\n var scrollYOffset = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;\n return {\n pageX: obj.pageX - scrollXOffset,\n pageY: obj.pageY - scrollYOffset\n };\n}\nfunction useColorDrag(props) {\n var targetRef = props.targetRef,\n containerRef = props.containerRef,\n direction = props.direction,\n onDragChange = props.onDragChange,\n onDragChangeComplete = props.onDragChangeComplete,\n calculate = props.calculate,\n color = props.color,\n disabledDrag = props.disabledDrag;\n var _useState = useState({\n x: 0,\n y: 0\n }),\n _useState2 = _slicedToArray(_useState, 2),\n offsetValue = _useState2[0],\n setOffsetValue = _useState2[1];\n var mouseMoveRef = useRef(null);\n var mouseUpRef = useRef(null);\n\n // Always get position from `color`\n useEffect(function () {\n setOffsetValue(calculate());\n }, [color]);\n useEffect(function () {\n return function () {\n document.removeEventListener('mousemove', mouseMoveRef.current);\n document.removeEventListener('mouseup', mouseUpRef.current);\n document.removeEventListener('touchmove', mouseMoveRef.current);\n document.removeEventListener('touchend', mouseUpRef.current);\n mouseMoveRef.current = null;\n mouseUpRef.current = null;\n };\n }, []);\n var updateOffset = function updateOffset(e) {\n var _getPosition = getPosition(e),\n pageX = _getPosition.pageX,\n pageY = _getPosition.pageY;\n var _containerRef$current = containerRef.current.getBoundingClientRect(),\n rectX = _containerRef$current.x,\n rectY = _containerRef$current.y,\n width = _containerRef$current.width,\n height = _containerRef$current.height;\n var _targetRef$current$ge = targetRef.current.getBoundingClientRect(),\n targetWidth = _targetRef$current$ge.width,\n targetHeight = _targetRef$current$ge.height;\n var centerOffsetX = targetWidth / 2;\n var centerOffsetY = targetHeight / 2;\n var offsetX = Math.max(0, Math.min(pageX - rectX, width)) - centerOffsetX;\n var offsetY = Math.max(0, Math.min(pageY - rectY, height)) - centerOffsetY;\n var calcOffset = {\n x: offsetX,\n y: direction === 'x' ? offsetValue.y : offsetY\n };\n\n // Exclusion of boundary cases\n if (targetWidth === 0 && targetHeight === 0 || targetWidth !== targetHeight) {\n return false;\n }\n onDragChange === null || onDragChange === void 0 || onDragChange(calcOffset);\n };\n var onDragMove = function onDragMove(e) {\n e.preventDefault();\n updateOffset(e);\n };\n var onDragStop = function onDragStop(e) {\n e.preventDefault();\n document.removeEventListener('mousemove', mouseMoveRef.current);\n document.removeEventListener('mouseup', mouseUpRef.current);\n document.removeEventListener('touchmove', mouseMoveRef.current);\n document.removeEventListener('touchend', mouseUpRef.current);\n mouseMoveRef.current = null;\n mouseUpRef.current = null;\n onDragChangeComplete === null || onDragChangeComplete === void 0 || onDragChangeComplete();\n };\n var onDragStart = function onDragStart(e) {\n // https://github.com/ant-design/ant-design/issues/43529\n document.removeEventListener('mousemove', mouseMoveRef.current);\n document.removeEventListener('mouseup', mouseUpRef.current);\n if (disabledDrag) {\n return;\n }\n updateOffset(e);\n document.addEventListener('mousemove', onDragMove);\n document.addEventListener('mouseup', onDragStop);\n document.addEventListener('touchmove', onDragMove);\n document.addEventListener('touchend', onDragStop);\n mouseMoveRef.current = onDragMove;\n mouseUpRef.current = onDragStop;\n };\n return [offsetValue, onDragStart];\n}\nexport default useColorDrag;","map":{"version":3,"names":["_slicedToArray","useEffect","useRef","useState","getPosition","e","obj","touches","scrollXOffset","document","documentElement","scrollLeft","body","window","pageXOffset","scrollYOffset","scrollTop","pageYOffset","pageX","pageY","useColorDrag","props","targetRef","containerRef","direction","onDragChange","onDragChangeComplete","calculate","color","disabledDrag","_useState","x","y","_useState2","offsetValue","setOffsetValue","mouseMoveRef","mouseUpRef","removeEventListener","current","updateOffset","_getPosition","_containerRef$current","getBoundingClientRect","rectX","rectY","width","height","_targetRef$current$ge","targetWidth","targetHeight","centerOffsetX","centerOffsetY","offsetX","Math","max","min","offsetY","calcOffset","onDragMove","preventDefault","onDragStop","onDragStart","addEventListener"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/@rc-component/color-picker/es/hooks/useColorDrag.js"],"sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useEffect, useRef, useState } from 'react';\nfunction getPosition(e) {\n var obj = 'touches' in e ? e.touches[0] : e;\n var scrollXOffset = document.documentElement.scrollLeft || document.body.scrollLeft || window.pageXOffset;\n var scrollYOffset = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;\n return {\n pageX: obj.pageX - scrollXOffset,\n pageY: obj.pageY - scrollYOffset\n };\n}\nfunction useColorDrag(props) {\n var targetRef = props.targetRef,\n containerRef = props.containerRef,\n direction = props.direction,\n onDragChange = props.onDragChange,\n onDragChangeComplete = props.onDragChangeComplete,\n calculate = props.calculate,\n color = props.color,\n disabledDrag = props.disabledDrag;\n var _useState = useState({\n x: 0,\n y: 0\n }),\n _useState2 = _slicedToArray(_useState, 2),\n offsetValue = _useState2[0],\n setOffsetValue = _useState2[1];\n var mouseMoveRef = useRef(null);\n var mouseUpRef = useRef(null);\n\n // Always get position from `color`\n useEffect(function () {\n setOffsetValue(calculate());\n }, [color]);\n useEffect(function () {\n return function () {\n document.removeEventListener('mousemove', mouseMoveRef.current);\n document.removeEventListener('mouseup', mouseUpRef.current);\n document.removeEventListener('touchmove', mouseMoveRef.current);\n document.removeEventListener('touchend', mouseUpRef.current);\n mouseMoveRef.current = null;\n mouseUpRef.current = null;\n };\n }, []);\n var updateOffset = function updateOffset(e) {\n var _getPosition = getPosition(e),\n pageX = _getPosition.pageX,\n pageY = _getPosition.pageY;\n var _containerRef$current = containerRef.current.getBoundingClientRect(),\n rectX = _containerRef$current.x,\n rectY = _containerRef$current.y,\n width = _containerRef$current.width,\n height = _containerRef$current.height;\n var _targetRef$current$ge = targetRef.current.getBoundingClientRect(),\n targetWidth = _targetRef$current$ge.width,\n targetHeight = _targetRef$current$ge.height;\n var centerOffsetX = targetWidth / 2;\n var centerOffsetY = targetHeight / 2;\n var offsetX = Math.max(0, Math.min(pageX - rectX, width)) - centerOffsetX;\n var offsetY = Math.max(0, Math.min(pageY - rectY, height)) - centerOffsetY;\n var calcOffset = {\n x: offsetX,\n y: direction === 'x' ? offsetValue.y : offsetY\n };\n\n // Exclusion of boundary cases\n if (targetWidth === 0 && targetHeight === 0 || targetWidth !== targetHeight) {\n return false;\n }\n onDragChange === null || onDragChange === void 0 || onDragChange(calcOffset);\n };\n var onDragMove = function onDragMove(e) {\n e.preventDefault();\n updateOffset(e);\n };\n var onDragStop = function onDragStop(e) {\n e.preventDefault();\n document.removeEventListener('mousemove', mouseMoveRef.current);\n document.removeEventListener('mouseup', mouseUpRef.current);\n document.removeEventListener('touchmove', mouseMoveRef.current);\n document.removeEventListener('touchend', mouseUpRef.current);\n mouseMoveRef.current = null;\n mouseUpRef.current = null;\n onDragChangeComplete === null || onDragChangeComplete === void 0 || onDragChangeComplete();\n };\n var onDragStart = function onDragStart(e) {\n // https://github.com/ant-design/ant-design/issues/43529\n document.removeEventListener('mousemove', mouseMoveRef.current);\n document.removeEventListener('mouseup', mouseUpRef.current);\n if (disabledDrag) {\n return;\n }\n updateOffset(e);\n document.addEventListener('mousemove', onDragMove);\n document.addEventListener('mouseup', onDragStop);\n document.addEventListener('touchmove', onDragMove);\n document.addEventListener('touchend', onDragStop);\n mouseMoveRef.current = onDragMove;\n mouseUpRef.current = onDragStop;\n };\n return [offsetValue, onDragStart];\n}\nexport default useColorDrag;"],"mappings":"AAAA,OAAOA,cAAc,MAAM,0CAA0C;AACrE,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnD,SAASC,WAAWA,CAACC,CAAC,EAAE;EACtB,IAAIC,GAAG,GAAG,SAAS,IAAID,CAA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