mirror of
https://github.com/imezx/Warp.git
synced 2025-04-25 07:30:02 +00:00
27 lines
971 B
JavaScript
27 lines
971 B
JavaScript
|
import React from 'react';
|
||
|
export function useTouchEvents(_ref) {
|
||
|
var getEnvironmentProps = _ref.getEnvironmentProps,
|
||
|
panelElement = _ref.panelElement,
|
||
|
formElement = _ref.formElement,
|
||
|
inputElement = _ref.inputElement;
|
||
|
React.useEffect(function () {
|
||
|
if (!(panelElement && formElement && inputElement)) {
|
||
|
return undefined;
|
||
|
}
|
||
|
|
||
|
var _getEnvironmentProps = getEnvironmentProps({
|
||
|
panelElement: panelElement,
|
||
|
formElement: formElement,
|
||
|
inputElement: inputElement
|
||
|
}),
|
||
|
onTouchStart = _getEnvironmentProps.onTouchStart,
|
||
|
onTouchMove = _getEnvironmentProps.onTouchMove;
|
||
|
|
||
|
window.addEventListener('touchstart', onTouchStart);
|
||
|
window.addEventListener('touchmove', onTouchMove);
|
||
|
return function () {
|
||
|
window.removeEventListener('touchstart', onTouchStart);
|
||
|
window.removeEventListener('touchmove', onTouchMove);
|
||
|
};
|
||
|
}, [getEnvironmentProps, panelElement, formElement, inputElement]);
|
||
|
}
|