Skip to content

Commit

Permalink
Fixes swipedown listener (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipbrembeck committed Feb 19, 2023
1 parent e01d2c9 commit 2406fa5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/elements/modalwrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ const ModalWrapper: React.FC<ModalProps> = ({ children, id, buttonType, buttonCl

const handleTouchStart = (event: TouchEvent) => {
const touchY = event.changedTouches[0].clientY;
const swipeThreshold = 0;

document.body.addEventListener("touchmove", handleTouchMove);

function handleTouchMove(event: TouchEvent) {
const currentY = event.changedTouches[0].clientY;
if (currentY > touchY) {
const deltaY = currentY - touchY;
if (deltaY > swipeThreshold) {
closeModal();
}
document.body.removeEventListener("touchmove", handleTouchMove);
}
};



document.addEventListener("keydown", handleEscapeKeyPress);
document.addEventListener("touchstart", handleTouchStart);
Expand Down

0 comments on commit 2406fa5

Please sign in to comment.