PromoCursed/node_modules/.cache/babel-loader/fdf59dff90a776342fbaf431b7c045e4727ff43611cdc20121a214a9a6d92687.json

1 line
9.2 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport { useRef } from 'react';\nvar SMOOTH_PTG = 14 / 15;\nexport default function useMobileTouchMove(inVirtual, listRef, callback) {\n var touchedRef = useRef(false);\n var touchXRef = useRef(0);\n var touchYRef = useRef(0);\n var elementRef = useRef(null);\n\n // Smooth scroll\n var intervalRef = useRef(null);\n\n /* eslint-disable prefer-const */\n var cleanUpEvents;\n var onTouchMove = function onTouchMove(e) {\n if (touchedRef.current) {\n var currentX = Math.ceil(e.touches[0].pageX);\n var currentY = Math.ceil(e.touches[0].pageY);\n var offsetX = touchXRef.current - currentX;\n var offsetY = touchYRef.current - currentY;\n var _isHorizontal = Math.abs(offsetX) > Math.abs(offsetY);\n if (_isHorizontal) {\n touchXRef.current = currentX;\n } else {\n touchYRef.current = currentY;\n }\n if (callback(_isHorizontal, _isHorizontal ? offsetX : offsetY)) {\n e.preventDefault();\n }\n // Smooth interval\n clearInterval(intervalRef.current);\n intervalRef.current = setInterval(function () {\n if (_isHorizontal) {\n offsetX *= SMOOTH_PTG;\n } else {\n offsetY *= SMOOTH_PTG;\n }\n var offset = Math.floor(_isHorizontal ? offsetX : offsetY);\n if (!callback(_isHorizontal, offset, true) || Math.abs(offset) <= 0.1) {\n clearInterval(intervalRef.current);\n }\n }, 16);\n }\n };\n var onTouchEnd = function onTouchEnd() {\n touchedRef.current = false;\n cleanUpEvents();\n };\n var onTouchStart = function onTouchStart(e) {\n cleanUpEvents();\n if (e.touches.length === 1 && !touchedRef.current) {\n touchedRef.current = true;\n touchXRef.current = Math.ceil(e.touches[0].pageX);\n touchYRef.current = Math.ceil(e.touches[0].pageY);\n elementRef.current = e.target;\n elementRef.current.addEventListener('touchmove', onTouchMove, {\n passive: false\n });\n elementRef.current.addEventListener('touchend', onTouchEnd, {\n passive: true\n });\n }\n };\n cleanUpEvents = function cleanUpEvents() {\n if (elementRef.current) {\n elementRef.current.removeEventListener('touchmove', onTouchMove);\n elementRef.current.removeEventListener('touchend', onTouchEnd);\n }\n };\n useLayoutEffect(function () {\n if (inVirtual) {\n listRef.current.addEventListener('touchstart', onTouchStart, {\n passive: true\n });\n }\n return function () {\n var _listRef$current;\n (_listRef$current = listRef.current) === null || _listRef$current === void 0 || _listRef$current.removeEventListener('touchstart', onTouchStart);\n cleanUpEvents();\n clearInterval(intervalRef.current);\n };\n }, [inVirtual]);\n}","map":{"version":3,"names":["useLayoutEffect","useRef","SMOOTH_PTG","useMobileTouchMove","inVirtual","listRef","callback","touchedRef","touchXRef","touchYRef","elementRef","intervalRef","cleanUpEvents","onTouchMove","e","current","currentX","Math","ceil","touches","pageX","currentY","pageY","offsetX","offsetY","_isHorizontal","abs","preventDefault","clearInterval","setInterval","offset","floor","onTouchEnd","onTouchStart","length","target","addEventListener","passive","removeEventListener","_listRef$current"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js"],"sourcesContent":["import useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport { useRef } from 'react';\nvar SMOOTH_PTG = 14 / 15;\nexport default function useMobileTouchMove(inVirtual, listRef, callback) {\n var touchedRef = useRef(false);\n var touchXRef = useRef(0);\n var touchYRef = useRef(0);\n var elementRef = useRef(null);\n\n // Smooth scroll\n var intervalRef = useRef(null);\n\n /* eslint-disable prefer-const */\n var cleanUpEvents;\n var onTouchMove = function onTouchMove(e) {\n if (touchedRef.current) {\n var currentX