카테고리 없음

ReactSortable 안에 버튼 안눌리는 이슈 (안드로이드만)

비니_ 2025. 12. 31. 13:22
728x90

 

const handleTouchStart = (e) => {
  const touch = e.touches[0];
  e.target.startX = touch.clientX;
  e.target.startY = touch.clientY;
};

const handleTouchEnd = (e, callback) => {
  const touch = e.changedTouches[0];
  const dx = Math.abs(touch.clientX - e.target.startX);
  const dy = Math.abs(touch.clientY - e.target.startY);

  // 터치 이동이 거의 없으면 클릭 처리
  if (dx < 5 && dy < 5) {
    callback();
  }
};



return(
	<button
      onTouchStart={handleTouchStart}
      onTouchEnd={(e) => handleTouchEnd(e, 드래그가 아닐 시 실행할 함수내용)}
    >
      삭제
    </button>

)

 

728x90