2022-04-08 15:42:32 +00:00
|
|
|
import { isSmallTablet, isTouchDevice } from "../../utils/device";
|
|
|
|
|
2022-04-08 14:37:22 +00:00
|
|
|
let y1 = null;
|
|
|
|
|
|
|
|
export const handleTouchStart = (e) => {
|
2022-04-08 15:42:32 +00:00
|
|
|
if (!(isTouchDevice && isSmallTablet())) {
|
|
|
|
y1 = null;
|
|
|
|
return false;
|
|
|
|
}
|
2022-04-08 14:37:22 +00:00
|
|
|
|
2022-04-08 15:42:32 +00:00
|
|
|
const firstTouch = e.touches[0];
|
2022-04-08 14:37:22 +00:00
|
|
|
if (firstTouch.target.id !== "modal-header-swipe") {
|
|
|
|
y1 = null;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
y1 = firstTouch.clientY;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const handleTouchMove = (e, onClose) => {
|
2022-04-08 15:42:32 +00:00
|
|
|
if (!y1) return 0;
|
2022-04-08 14:37:22 +00:00
|
|
|
|
|
|
|
let y2 = e.touches[0].clientY;
|
|
|
|
if (y2 - y1 > 120) onClose();
|
|
|
|
|
|
|
|
return y1 - y2;
|
|
|
|
};
|