Buckets:
| import {disableTextSelection as $14c0b72509d70225$export$16a4697467175487, restoreTextSelection as $14c0b72509d70225$export$b0d6fa1ab32e3295} from "./textSelection.module.js"; | |
| import {useRef as $5GN7j$useRef, useMemo as $5GN7j$useMemo} from "react"; | |
| import {useGlobalListeners as $5GN7j$useGlobalListeners, useEffectEvent as $5GN7j$useEffectEvent} from "@react-aria/utils"; | |
| /* | |
| * Copyright 2020 Adobe. All rights reserved. | |
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. You may obtain a copy | |
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software distributed under | |
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | |
| * OF ANY KIND, either express or implied. See the License for the specific language | |
| * governing permissions and limitations under the License. | |
| */ | |
| function $e8a7022cf87cba2a$export$36da96379f79f245(props) { | |
| let { onMoveStart: onMoveStart, onMove: onMove, onMoveEnd: onMoveEnd } = props; | |
| let state = (0, $5GN7j$useRef)({ | |
| didMove: false, | |
| lastPosition: null, | |
| id: null | |
| }); | |
| let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $5GN7j$useGlobalListeners)(); | |
| let move = (0, $5GN7j$useEffectEvent)((originalEvent, pointerType, deltaX, deltaY)=>{ | |
| if (deltaX === 0 && deltaY === 0) return; | |
| if (!state.current.didMove) { | |
| state.current.didMove = true; | |
| onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart({ | |
| type: 'movestart', | |
| pointerType: pointerType, | |
| shiftKey: originalEvent.shiftKey, | |
| metaKey: originalEvent.metaKey, | |
| ctrlKey: originalEvent.ctrlKey, | |
| altKey: originalEvent.altKey | |
| }); | |
| } | |
| onMove === null || onMove === void 0 ? void 0 : onMove({ | |
| type: 'move', | |
| pointerType: pointerType, | |
| deltaX: deltaX, | |
| deltaY: deltaY, | |
| shiftKey: originalEvent.shiftKey, | |
| metaKey: originalEvent.metaKey, | |
| ctrlKey: originalEvent.ctrlKey, | |
| altKey: originalEvent.altKey | |
| }); | |
| }); | |
| let end = (0, $5GN7j$useEffectEvent)((originalEvent, pointerType)=>{ | |
| (0, $14c0b72509d70225$export$b0d6fa1ab32e3295)(); | |
| if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({ | |
| type: 'moveend', | |
| pointerType: pointerType, | |
| shiftKey: originalEvent.shiftKey, | |
| metaKey: originalEvent.metaKey, | |
| ctrlKey: originalEvent.ctrlKey, | |
| altKey: originalEvent.altKey | |
| }); | |
| }); | |
| let moveProps = (0, $5GN7j$useMemo)(()=>{ | |
| let moveProps = {}; | |
| let start = ()=>{ | |
| (0, $14c0b72509d70225$export$16a4697467175487)(); | |
| state.current.didMove = false; | |
| }; | |
| if (typeof PointerEvent === 'undefined') { | |
| let onMouseMove = (e)=>{ | |
| if (e.button === 0) { | |
| var _state_current_lastPosition, _state_current_lastPosition1; | |
| var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY; | |
| move(e, 'mouse', e.pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), e.pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0)); | |
| state.current.lastPosition = { | |
| pageX: e.pageX, | |
| pageY: e.pageY | |
| }; | |
| } | |
| }; | |
| let onMouseUp = (e)=>{ | |
| if (e.button === 0) { | |
| end(e, 'mouse'); | |
| removeGlobalListener(window, 'mousemove', onMouseMove, false); | |
| removeGlobalListener(window, 'mouseup', onMouseUp, false); | |
| } | |
| }; | |
| moveProps.onMouseDown = (e)=>{ | |
| if (e.button === 0) { | |
| start(); | |
| e.stopPropagation(); | |
| e.preventDefault(); | |
| state.current.lastPosition = { | |
| pageX: e.pageX, | |
| pageY: e.pageY | |
| }; | |
| addGlobalListener(window, 'mousemove', onMouseMove, false); | |
| addGlobalListener(window, 'mouseup', onMouseUp, false); | |
| } | |
| }; | |
| let onTouchMove = (e)=>{ | |
| let touch = [ | |
| ...e.changedTouches | |
| ].findIndex(({ identifier: identifier })=>identifier === state.current.id); | |
| if (touch >= 0) { | |
| var _state_current_lastPosition, _state_current_lastPosition1; | |
| let { pageX: pageX, pageY: pageY } = e.changedTouches[touch]; | |
| var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY; | |
| move(e, 'touch', pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0)); | |
| state.current.lastPosition = { | |
| pageX: pageX, | |
| pageY: pageY | |
| }; | |
| } | |
| }; | |
| let onTouchEnd = (e)=>{ | |
| let touch = [ | |
| ...e.changedTouches | |
| ].findIndex(({ identifier: identifier })=>identifier === state.current.id); | |
| if (touch >= 0) { | |
| end(e, 'touch'); | |
| state.current.id = null; | |
| removeGlobalListener(window, 'touchmove', onTouchMove); | |
| removeGlobalListener(window, 'touchend', onTouchEnd); | |
| removeGlobalListener(window, 'touchcancel', onTouchEnd); | |
| } | |
| }; | |
| moveProps.onTouchStart = (e)=>{ | |
| if (e.changedTouches.length === 0 || state.current.id != null) return; | |
| let { pageX: pageX, pageY: pageY, identifier: identifier } = e.changedTouches[0]; | |
| start(); | |
| e.stopPropagation(); | |
| e.preventDefault(); | |
| state.current.lastPosition = { | |
| pageX: pageX, | |
| pageY: pageY | |
| }; | |
| state.current.id = identifier; | |
| addGlobalListener(window, 'touchmove', onTouchMove, false); | |
| addGlobalListener(window, 'touchend', onTouchEnd, false); | |
| addGlobalListener(window, 'touchcancel', onTouchEnd, false); | |
| }; | |
| } else { | |
| let onPointerMove = (e)=>{ | |
| if (e.pointerId === state.current.id) { | |
| var _state_current_lastPosition, _state_current_lastPosition1; | |
| let pointerType = e.pointerType || 'mouse'; | |
| var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY; | |
| // Problems with PointerEvent#movementX/movementY: | |
| // 1. it is always 0 on macOS Safari. | |
| // 2. On Chrome Android, it's scaled by devicePixelRatio, but not on Chrome macOS | |
| move(e, pointerType, e.pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), e.pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0)); | |
| state.current.lastPosition = { | |
| pageX: e.pageX, | |
| pageY: e.pageY | |
| }; | |
| } | |
| }; | |
| let onPointerUp = (e)=>{ | |
| if (e.pointerId === state.current.id) { | |
| let pointerType = e.pointerType || 'mouse'; | |
| end(e, pointerType); | |
| state.current.id = null; | |
| removeGlobalListener(window, 'pointermove', onPointerMove, false); | |
| removeGlobalListener(window, 'pointerup', onPointerUp, false); | |
| removeGlobalListener(window, 'pointercancel', onPointerUp, false); | |
| } | |
| }; | |
| moveProps.onPointerDown = (e)=>{ | |
| if (e.button === 0 && state.current.id == null) { | |
| start(); | |
| e.stopPropagation(); | |
| e.preventDefault(); | |
| state.current.lastPosition = { | |
| pageX: e.pageX, | |
| pageY: e.pageY | |
| }; | |
| state.current.id = e.pointerId; | |
| addGlobalListener(window, 'pointermove', onPointerMove, false); | |
| addGlobalListener(window, 'pointerup', onPointerUp, false); | |
| addGlobalListener(window, 'pointercancel', onPointerUp, false); | |
| } | |
| }; | |
| } | |
| let triggerKeyboardMove = (e, deltaX, deltaY)=>{ | |
| start(); | |
| move(e, 'keyboard', deltaX, deltaY); | |
| end(e, 'keyboard'); | |
| }; | |
| moveProps.onKeyDown = (e)=>{ | |
| switch(e.key){ | |
| case 'Left': | |
| case 'ArrowLeft': | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| triggerKeyboardMove(e, -1, 0); | |
| break; | |
| case 'Right': | |
| case 'ArrowRight': | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| triggerKeyboardMove(e, 1, 0); | |
| break; | |
| case 'Up': | |
| case 'ArrowUp': | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| triggerKeyboardMove(e, 0, -1); | |
| break; | |
| case 'Down': | |
| case 'ArrowDown': | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| triggerKeyboardMove(e, 0, 1); | |
| break; | |
| } | |
| }; | |
| return moveProps; | |
| }, [ | |
| state, | |
| addGlobalListener, | |
| removeGlobalListener, | |
| move, | |
| end | |
| ]); | |
| return { | |
| moveProps: moveProps | |
| }; | |
| } | |
| export {$e8a7022cf87cba2a$export$36da96379f79f245 as useMove}; | |
| //# sourceMappingURL=useMove.module.js.map | |
Xet Storage Details
- Size:
- 11.8 kB
- Xet hash:
- e2da7db93d337eb3d961f038a510d7f318ea3a741fc57840975797b1758316db
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.