Skip to content

Commit 72b30b4

Browse files
committed
๐Ÿ›fix: drag & drop ์‹œ mouse์™€ tag ์œ„์น˜ ๊ฐ™๊ฒŒ ๊ณ ์ •
1 parent 3639917 commit 72b30b4

2 files changed

Lines changed: 9 additions & 25 deletions

File tree

โ€Žsrc/components/common/Bottom.tsxโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ const Container = styled.div`
110110
left: 0;
111111
z-index: 10;
112112
113-
/* -ms-user-select: none;
113+
-ms-user-select: none;
114114
-moz-user-select: -moz-none;
115115
-webkit-user-select: none;
116116
-khtml-user-select: none;
117-
user-select: none; */
117+
user-select: none;
118118
`;
119119

120120
const Top = styled.div`

โ€Žsrc/components/common/Tag.tsxโ€Ž

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,6 @@ const Tag = (props: TagProps) => {
162162
return "";
163163
};
164164

165-
//ref๋ผ๋ฆฌ ๊ฒน์น˜๋Š” ์˜์—ญ ๊ณ„์‚ฐ
166-
const getOverlapArea = (rect1: DOMRect, rect2: DOMRect) => {
167-
const x_overlap = Math.max(
168-
0,
169-
Math.min(rect1.right, rect2.right) - Math.max(rect1.left, rect2.left)
170-
);
171-
const y_overlap = Math.max(
172-
0,
173-
Math.min(rect1.bottom, rect2.bottom) - Math.max(rect1.top, rect2.top)
174-
);
175-
const overlapArea = x_overlap * y_overlap;
176-
return overlapArea;
177-
};
178-
179165
//๋ชจ๋ฐ”์ผ ํ„ฐ์น˜ ๋“œ๋ž˜๊ทธ
180166
const handleTouchStart = (e: React.TouchEvent<HTMLDivElement>) => {
181167
if (tagType === "letter") {
@@ -185,13 +171,7 @@ const Tag = (props: TagProps) => {
185171
e.stopPropagation();
186172
console.log("ํ„ฐ์น˜ ์‹œ์ž‘");
187173
const touch = e.touches[0];
188-
//setStartPosition({ x: touch.clientX, y: touch.clientY });
189-
// ์ปจํ…Œ์ด๋„ˆ์˜ ์ดˆ๊ธฐ ์œ„์น˜๋ฅผ ๊ฐ€์ ธ์™€ ์‹œ์ž‘ ์œ„์น˜์— ๋ฐ˜์˜
190-
const container = e.currentTarget.getBoundingClientRect();
191-
setStartPosition({
192-
x: touch.clientX - container.left,
193-
y: touch.clientY - container.top,
194-
});
174+
setStartPosition({ x: touch.clientX, y: touch.clientY });
195175

196176
e.currentTarget.addEventListener("touchmove", handleTouchMove, {
197177
passive: false,
@@ -206,9 +186,13 @@ const Tag = (props: TagProps) => {
206186
console.log("ํ„ฐ์น˜ ์›€์ง์ž„");
207187
if (startPosition) {
208188
const touch = e.touches[0];
209-
const deltaX = touch.clientX - startPosition.x;
189+
console.log(startPosition.x);
190+
const deltaX = touch.clientX - 60;
210191
const deltaY = touch.clientY - startPosition.y;
211-
setTranslate({ x: deltaX, y: deltaY });
192+
setTranslate({
193+
x: touch.clientX - startPosition.x,
194+
y: touch.clientY - startPosition.y,
195+
});
212196

213197
if (tagRef.current) {
214198
tagRef.current.style.zIndex = "999999";

0 commit comments

Comments
ย (0)