ninegrid2 6.1069.0 → 6.1071.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -121406,9 +121406,6 @@ class nxSplitter extends HTMLElement {
121406
121406
  const splitterRect = this.getBoundingClientRect();
121407
121407
  const isHorizontal = this.#mode === "h";
121408
121408
 
121409
- // ⭐ 마우스 초기 위치 저장 ⭐
121410
- const initialMousePos = isHorizontal ? e.clientX : e.clientY;
121411
-
121412
121409
  // 마우스 포인터와 스플리터 시작점 사이의 거리
121413
121410
  isHorizontal
121414
121411
  ? e.clientX - splitterRect.left
@@ -121436,23 +121433,25 @@ class nxSplitter extends HTMLElement {
121436
121433
  }
121437
121434
 
121438
121435
  (parent.shadowRoot || parent).appendChild(dragBar);
121439
- //const parentRect = parent.getBoundingClientRect();
121436
+ const dragBarOffsetParentRect = dragBar.offsetParent.getBoundingClientRect();
121437
+
121440
121438
  const prevRect = prev.getBoundingClientRect();
121441
121439
  const nextRect = next.getBoundingClientRect();
121442
121440
 
121443
121441
  // 드래그 바의 초기 위치와 크기 설정
121444
- // startDrag 메서드 내부
121445
- const dragBarOffsetParentRect = dragBar.offsetParent.getBoundingClientRect();
121442
+ const initialSplitterPosInParent = isHorizontal
121443
+ ? splitterRect.left - dragBarOffsetParentRect.left
121444
+ : splitterRect.top - dragBarOffsetParentRect.top;
121446
121445
 
121447
121446
  if (isHorizontal) {
121448
121447
  dragBar.style.top = "0";
121449
- dragBar.style.left = `${e.clientX - dragBarOffsetParentRect.left}px`;
121450
- dragBar.style.width = "1px"; // ⭐ 1px로 변경
121448
+ dragBar.style.left = `${initialSplitterPosInParent}px`;
121449
+ dragBar.style.width = "1px";
121451
121450
  dragBar.style.height = "100%";
121452
121451
  } else {
121453
121452
  dragBar.style.left = "0";
121454
- dragBar.style.top = `${e.clientY - dragBarOffsetParentRect.top}px`;
121455
- dragBar.style.height = "1px"; // ⭐ 1px로 변경
121453
+ dragBar.style.top = `${initialSplitterPosInParent}px`;
121454
+ dragBar.style.height = "1px";
121456
121455
  dragBar.style.width = "100%";
121457
121456
  }
121458
121457
 
@@ -121476,11 +121475,9 @@ class nxSplitter extends HTMLElement {
121476
121475
  } else {
121477
121476
  dragBar.style.top = `${clampedPos}px`;
121478
121477
  }
121479
-
121480
- console.log(clampedPos);
121481
121478
  };
121482
121479
 
121483
- const onUp = (e) => {
121480
+ const onUp = () => {
121484
121481
  window.removeEventListener("mousemove", onMove);
121485
121482
  window.removeEventListener("mouseup", onUp);
121486
121483
  dragBar.remove();
@@ -121488,10 +121485,17 @@ class nxSplitter extends HTMLElement {
121488
121485
  const allChildren = Array.from(parent.children);
121489
121486
  const allPanels = allChildren.filter(el => el.tagName.toLowerCase() !== 'nx-splitter');
121490
121487
 
121491
- // ⭐⭐ 부모의 픽셀 크기 ⭐⭐
121492
- const totalContainerSize = isHorizontal ? parent.getBoundingClientRect().width : parent.getBoundingClientRect().height;
121488
+ const finalDragBarPos = isHorizontal ? parseFloat(dragBar.style.left) : parseFloat(dragBar.style.top);
121489
+ const dragOffset = finalDragBarPos - initialSplitterPosInParent;
121490
+
121491
+ const prevSize = isHorizontal ? prev.getBoundingClientRect().width : prev.getBoundingClientRect().height;
121492
+ const nextSize = isHorizontal ? next.getBoundingClientRect().width : next.getBoundingClientRect().height;
121493
+
121494
+ const newPrevSize = prevSize + dragOffset;
121495
+ const newNextSize = nextSize - dragOffset;
121496
+
121497
+ const initialSizes = allPanels.map(panel => isHorizontal ? panel.getBoundingClientRect().width : panel.getBoundingClientRect().height);
121493
121498
 
121494
- // ⭐⭐ 모든 스플리터의 총 픽셀 크기 ⭐⭐
121495
121499
  const totalSplitterSize = allChildren.reduce((sum, child) => {
121496
121500
  if (child.tagName.toLowerCase() === 'nx-splitter') {
121497
121501
  return sum + (isHorizontal ? child.getBoundingClientRect().width : child.getBoundingClientRect().height);
@@ -121499,32 +121503,8 @@ class nxSplitter extends HTMLElement {
121499
121503
  return sum;
121500
121504
  }, 0);
121501
121505
 
121502
- // ⭐⭐ Flexbox의 'gap' 크기 계산 (하드코딩된 8px 사용) ⭐⭐
121503
- allChildren.length - 1;
121504
- const totalGapSize = 0;//gapCount * 8;
121505
-
121506
- // ⭐⭐ Flexbox 컨테이너의 '총 유효 공간' (패널들이 차지할 수 있는 공간) 계산 ⭐⭐
121507
- const totalFlexSpace = totalContainerSize - totalSplitterSize - totalGapSize;
121508
-
121509
- // ⭐⭐ 모든 패널의 초기 크기를 미리 저장 ⭐⭐
121510
- const initialSizes = allPanels.map(panel => isHorizontal ? panel.getBoundingClientRect().width : panel.getBoundingClientRect().height);
121511
-
121512
-
121513
- // 드래그로 인한 픽셀 변화량 계산
121514
- //const dragOffset = (isHorizontal ? parseFloat(dragBar.style.left) : parseFloat(dragBar.style.top)) -
121515
- // (isHorizontal ? this.getBoundingClientRect().left - parent.getBoundingClientRect().left : this.getBoundingClientRect().top - parent.getBoundingClientRect().top);
121516
-
121517
- // ⭐ 정확한 dragOffset 계산 ⭐
121518
- const finalMousePos = isHorizontal ? e.clientX : e.clientY;
121519
- const dragOffset = finalMousePos - initialMousePos;
121520
-
121521
- const prevSize = isHorizontal ? prev.getBoundingClientRect().width : prev.getBoundingClientRect().height;
121522
- const nextSize = isHorizontal ? next.getBoundingClientRect().width : next.getBoundingClientRect().height;
121523
-
121524
- const newPrevSize = prevSize + dragOffset;
121525
- const newNextSize = nextSize - dragOffset;
121526
-
121527
- console.log(prevSize, newPrevSize);
121506
+ const totalContainerSize = (isHorizontal ? parent.getBoundingClientRect().width : parent.getBoundingClientRect().height);
121507
+ const totalFlexSpace = totalContainerSize - totalSplitterSize;
121528
121508
 
121529
121509
  let flexSum = 0;
121530
121510
  allPanels.forEach((panel, index) => {
@@ -121537,16 +121517,12 @@ class nxSplitter extends HTMLElement {
121537
121517
  newSize = initialSizes[index];
121538
121518
  }
121539
121519
 
121540
- //console.log(newSize)
121541
-
121542
- // ⭐⭐ 새로운 FlexBasis 계산 ⭐⭐
121543
121520
  const newFlexBasis = newSize / totalFlexSpace;
121544
121521
  panel.style.flex = `${newFlexBasis} ${newFlexBasis} 0`;
121545
121522
  flexSum += newFlexBasis;
121546
121523
  });
121547
121524
 
121548
- // ⭐⭐ 계산된 합계를 로그로 출력하여 확인 ⭐⭐
121549
- console.log(`newTotalFlexSpace: ${totalFlexSpace}`);
121525
+ console.log(`dragOffset: ${dragOffset}`);
121550
121526
  console.log(`Calculated FlexSum: ${flexSum}`);
121551
121527
  };
121552
121528
 
@@ -121402,9 +121402,6 @@ class nxSplitter extends HTMLElement {
121402
121402
  const splitterRect = this.getBoundingClientRect();
121403
121403
  const isHorizontal = this.#mode === "h";
121404
121404
 
121405
- // ⭐ 마우스 초기 위치 저장 ⭐
121406
- const initialMousePos = isHorizontal ? e.clientX : e.clientY;
121407
-
121408
121405
  // 마우스 포인터와 스플리터 시작점 사이의 거리
121409
121406
  isHorizontal
121410
121407
  ? e.clientX - splitterRect.left
@@ -121432,23 +121429,25 @@ class nxSplitter extends HTMLElement {
121432
121429
  }
121433
121430
 
121434
121431
  (parent.shadowRoot || parent).appendChild(dragBar);
121435
- //const parentRect = parent.getBoundingClientRect();
121432
+ const dragBarOffsetParentRect = dragBar.offsetParent.getBoundingClientRect();
121433
+
121436
121434
  const prevRect = prev.getBoundingClientRect();
121437
121435
  const nextRect = next.getBoundingClientRect();
121438
121436
 
121439
121437
  // 드래그 바의 초기 위치와 크기 설정
121440
- // startDrag 메서드 내부
121441
- const dragBarOffsetParentRect = dragBar.offsetParent.getBoundingClientRect();
121438
+ const initialSplitterPosInParent = isHorizontal
121439
+ ? splitterRect.left - dragBarOffsetParentRect.left
121440
+ : splitterRect.top - dragBarOffsetParentRect.top;
121442
121441
 
121443
121442
  if (isHorizontal) {
121444
121443
  dragBar.style.top = "0";
121445
- dragBar.style.left = `${e.clientX - dragBarOffsetParentRect.left}px`;
121446
- dragBar.style.width = "1px"; // ⭐ 1px로 변경
121444
+ dragBar.style.left = `${initialSplitterPosInParent}px`;
121445
+ dragBar.style.width = "1px";
121447
121446
  dragBar.style.height = "100%";
121448
121447
  } else {
121449
121448
  dragBar.style.left = "0";
121450
- dragBar.style.top = `${e.clientY - dragBarOffsetParentRect.top}px`;
121451
- dragBar.style.height = "1px"; // ⭐ 1px로 변경
121449
+ dragBar.style.top = `${initialSplitterPosInParent}px`;
121450
+ dragBar.style.height = "1px";
121452
121451
  dragBar.style.width = "100%";
121453
121452
  }
121454
121453
 
@@ -121472,11 +121471,9 @@ class nxSplitter extends HTMLElement {
121472
121471
  } else {
121473
121472
  dragBar.style.top = `${clampedPos}px`;
121474
121473
  }
121475
-
121476
- console.log(clampedPos);
121477
121474
  };
121478
121475
 
121479
- const onUp = (e) => {
121476
+ const onUp = () => {
121480
121477
  window.removeEventListener("mousemove", onMove);
121481
121478
  window.removeEventListener("mouseup", onUp);
121482
121479
  dragBar.remove();
@@ -121484,10 +121481,17 @@ class nxSplitter extends HTMLElement {
121484
121481
  const allChildren = Array.from(parent.children);
121485
121482
  const allPanels = allChildren.filter(el => el.tagName.toLowerCase() !== 'nx-splitter');
121486
121483
 
121487
- // ⭐⭐ 부모의 픽셀 크기 ⭐⭐
121488
- const totalContainerSize = isHorizontal ? parent.getBoundingClientRect().width : parent.getBoundingClientRect().height;
121484
+ const finalDragBarPos = isHorizontal ? parseFloat(dragBar.style.left) : parseFloat(dragBar.style.top);
121485
+ const dragOffset = finalDragBarPos - initialSplitterPosInParent;
121486
+
121487
+ const prevSize = isHorizontal ? prev.getBoundingClientRect().width : prev.getBoundingClientRect().height;
121488
+ const nextSize = isHorizontal ? next.getBoundingClientRect().width : next.getBoundingClientRect().height;
121489
+
121490
+ const newPrevSize = prevSize + dragOffset;
121491
+ const newNextSize = nextSize - dragOffset;
121492
+
121493
+ const initialSizes = allPanels.map(panel => isHorizontal ? panel.getBoundingClientRect().width : panel.getBoundingClientRect().height);
121489
121494
 
121490
- // ⭐⭐ 모든 스플리터의 총 픽셀 크기 ⭐⭐
121491
121495
  const totalSplitterSize = allChildren.reduce((sum, child) => {
121492
121496
  if (child.tagName.toLowerCase() === 'nx-splitter') {
121493
121497
  return sum + (isHorizontal ? child.getBoundingClientRect().width : child.getBoundingClientRect().height);
@@ -121495,32 +121499,8 @@ class nxSplitter extends HTMLElement {
121495
121499
  return sum;
121496
121500
  }, 0);
121497
121501
 
121498
- // ⭐⭐ Flexbox의 'gap' 크기 계산 (하드코딩된 8px 사용) ⭐⭐
121499
- allChildren.length - 1;
121500
- const totalGapSize = 0;//gapCount * 8;
121501
-
121502
- // ⭐⭐ Flexbox 컨테이너의 '총 유효 공간' (패널들이 차지할 수 있는 공간) 계산 ⭐⭐
121503
- const totalFlexSpace = totalContainerSize - totalSplitterSize - totalGapSize;
121504
-
121505
- // ⭐⭐ 모든 패널의 초기 크기를 미리 저장 ⭐⭐
121506
- const initialSizes = allPanels.map(panel => isHorizontal ? panel.getBoundingClientRect().width : panel.getBoundingClientRect().height);
121507
-
121508
-
121509
- // 드래그로 인한 픽셀 변화량 계산
121510
- //const dragOffset = (isHorizontal ? parseFloat(dragBar.style.left) : parseFloat(dragBar.style.top)) -
121511
- // (isHorizontal ? this.getBoundingClientRect().left - parent.getBoundingClientRect().left : this.getBoundingClientRect().top - parent.getBoundingClientRect().top);
121512
-
121513
- // ⭐ 정확한 dragOffset 계산 ⭐
121514
- const finalMousePos = isHorizontal ? e.clientX : e.clientY;
121515
- const dragOffset = finalMousePos - initialMousePos;
121516
-
121517
- const prevSize = isHorizontal ? prev.getBoundingClientRect().width : prev.getBoundingClientRect().height;
121518
- const nextSize = isHorizontal ? next.getBoundingClientRect().width : next.getBoundingClientRect().height;
121519
-
121520
- const newPrevSize = prevSize + dragOffset;
121521
- const newNextSize = nextSize - dragOffset;
121522
-
121523
- console.log(prevSize, newPrevSize);
121502
+ const totalContainerSize = (isHorizontal ? parent.getBoundingClientRect().width : parent.getBoundingClientRect().height);
121503
+ const totalFlexSpace = totalContainerSize - totalSplitterSize;
121524
121504
 
121525
121505
  let flexSum = 0;
121526
121506
  allPanels.forEach((panel, index) => {
@@ -121533,16 +121513,12 @@ class nxSplitter extends HTMLElement {
121533
121513
  newSize = initialSizes[index];
121534
121514
  }
121535
121515
 
121536
- //console.log(newSize)
121537
-
121538
- // ⭐⭐ 새로운 FlexBasis 계산 ⭐⭐
121539
121516
  const newFlexBasis = newSize / totalFlexSpace;
121540
121517
  panel.style.flex = `${newFlexBasis} ${newFlexBasis} 0`;
121541
121518
  flexSum += newFlexBasis;
121542
121519
  });
121543
121520
 
121544
- // ⭐⭐ 계산된 합계를 로그로 출력하여 확인 ⭐⭐
121545
- console.log(`newTotalFlexSpace: ${totalFlexSpace}`);
121521
+ console.log(`dragOffset: ${dragOffset}`);
121546
121522
  console.log(`Calculated FlexSum: ${flexSum}`);
121547
121523
  };
121548
121524
 
@@ -39,9 +39,6 @@ class nxSplitter extends HTMLElement {
39
39
  const splitterRect = this.getBoundingClientRect();
40
40
  const isHorizontal = this.#mode === "h";
41
41
 
42
- // ⭐ 마우스 초기 위치 저장 ⭐
43
- const initialMousePos = isHorizontal ? e.clientX : e.clientY;
44
-
45
42
  // 마우스 포인터와 스플리터 시작점 사이의 거리
46
43
  const clickOffset = isHorizontal
47
44
  ? e.clientX - splitterRect.left
@@ -69,23 +66,25 @@ class nxSplitter extends HTMLElement {
69
66
  }
70
67
 
71
68
  (parent.shadowRoot || parent).appendChild(dragBar);
72
- //const parentRect = parent.getBoundingClientRect();
69
+ const dragBarOffsetParentRect = dragBar.offsetParent.getBoundingClientRect();
70
+
73
71
  const prevRect = prev.getBoundingClientRect();
74
72
  const nextRect = next.getBoundingClientRect();
75
73
 
76
74
  // 드래그 바의 초기 위치와 크기 설정
77
- // startDrag 메서드 내부
78
- const dragBarOffsetParentRect = dragBar.offsetParent.getBoundingClientRect();
75
+ const initialSplitterPosInParent = isHorizontal
76
+ ? splitterRect.left - dragBarOffsetParentRect.left
77
+ : splitterRect.top - dragBarOffsetParentRect.top;
79
78
 
80
79
  if (isHorizontal) {
81
80
  dragBar.style.top = "0";
82
- dragBar.style.left = `${e.clientX - dragBarOffsetParentRect.left}px`;
83
- dragBar.style.width = "1px"; // ⭐ 1px로 변경
81
+ dragBar.style.left = `${initialSplitterPosInParent}px`;
82
+ dragBar.style.width = "1px";
84
83
  dragBar.style.height = "100%";
85
84
  } else {
86
85
  dragBar.style.left = "0";
87
- dragBar.style.top = `${e.clientY - dragBarOffsetParentRect.top}px`;
88
- dragBar.style.height = "1px"; // ⭐ 1px로 변경
86
+ dragBar.style.top = `${initialSplitterPosInParent}px`;
87
+ dragBar.style.height = "1px";
89
88
  dragBar.style.width = "100%";
90
89
  }
91
90
 
@@ -109,11 +108,9 @@ class nxSplitter extends HTMLElement {
109
108
  } else {
110
109
  dragBar.style.top = `${clampedPos}px`;
111
110
  }
112
-
113
- console.log(clampedPos);
114
111
  };
115
112
 
116
- const onUp = (e) => {
113
+ const onUp = () => {
117
114
  window.removeEventListener("mousemove", onMove);
118
115
  window.removeEventListener("mouseup", onUp);
119
116
  dragBar.remove();
@@ -121,10 +118,17 @@ class nxSplitter extends HTMLElement {
121
118
  const allChildren = Array.from(parent.children);
122
119
  const allPanels = allChildren.filter(el => el.tagName.toLowerCase() !== 'nx-splitter');
123
120
 
124
- // ⭐⭐ 부모의 픽셀 크기 ⭐⭐
125
- const totalContainerSize = isHorizontal ? parent.getBoundingClientRect().width : parent.getBoundingClientRect().height;
121
+ const finalDragBarPos = isHorizontal ? parseFloat(dragBar.style.left) : parseFloat(dragBar.style.top);
122
+ const dragOffset = finalDragBarPos - initialSplitterPosInParent;
123
+
124
+ const prevSize = isHorizontal ? prev.getBoundingClientRect().width : prev.getBoundingClientRect().height;
125
+ const nextSize = isHorizontal ? next.getBoundingClientRect().width : next.getBoundingClientRect().height;
126
+
127
+ const newPrevSize = prevSize + dragOffset;
128
+ const newNextSize = nextSize - dragOffset;
129
+
130
+ const initialSizes = allPanels.map(panel => isHorizontal ? panel.getBoundingClientRect().width : panel.getBoundingClientRect().height);
126
131
 
127
- // ⭐⭐ 모든 스플리터의 총 픽셀 크기 ⭐⭐
128
132
  const totalSplitterSize = allChildren.reduce((sum, child) => {
129
133
  if (child.tagName.toLowerCase() === 'nx-splitter') {
130
134
  return sum + (isHorizontal ? child.getBoundingClientRect().width : child.getBoundingClientRect().height);
@@ -132,32 +136,8 @@ class nxSplitter extends HTMLElement {
132
136
  return sum;
133
137
  }, 0);
134
138
 
135
- // ⭐⭐ Flexbox의 'gap' 크기 계산 (하드코딩된 8px 사용) ⭐⭐
136
- const gapCount = allChildren.length - 1;
137
- const totalGapSize = 0;//gapCount * 8;
138
-
139
- // ⭐⭐ Flexbox 컨테이너의 '총 유효 공간' (패널들이 차지할 수 있는 공간) 계산 ⭐⭐
140
- const totalFlexSpace = totalContainerSize - totalSplitterSize - totalGapSize;
141
-
142
- // ⭐⭐ 모든 패널의 초기 크기를 미리 저장 ⭐⭐
143
- const initialSizes = allPanels.map(panel => isHorizontal ? panel.getBoundingClientRect().width : panel.getBoundingClientRect().height);
144
-
145
-
146
- // 드래그로 인한 픽셀 변화량 계산
147
- //const dragOffset = (isHorizontal ? parseFloat(dragBar.style.left) : parseFloat(dragBar.style.top)) -
148
- // (isHorizontal ? this.getBoundingClientRect().left - parent.getBoundingClientRect().left : this.getBoundingClientRect().top - parent.getBoundingClientRect().top);
149
-
150
- // ⭐ 정확한 dragOffset 계산 ⭐
151
- const finalMousePos = isHorizontal ? e.clientX : e.clientY;
152
- const dragOffset = finalMousePos - initialMousePos;
153
-
154
- const prevSize = isHorizontal ? prev.getBoundingClientRect().width : prev.getBoundingClientRect().height;
155
- const nextSize = isHorizontal ? next.getBoundingClientRect().width : next.getBoundingClientRect().height;
156
-
157
- const newPrevSize = prevSize + dragOffset;
158
- const newNextSize = nextSize - dragOffset;
159
-
160
- console.log(prevSize, newPrevSize);
139
+ const totalContainerSize = (isHorizontal ? parent.getBoundingClientRect().width : parent.getBoundingClientRect().height);
140
+ const totalFlexSpace = totalContainerSize - totalSplitterSize;
161
141
 
162
142
  let flexSum = 0;
163
143
  allPanels.forEach((panel, index) => {
@@ -170,16 +150,12 @@ class nxSplitter extends HTMLElement {
170
150
  newSize = initialSizes[index];
171
151
  }
172
152
 
173
- //console.log(newSize)
174
-
175
- // ⭐⭐ 새로운 FlexBasis 계산 ⭐⭐
176
153
  const newFlexBasis = newSize / totalFlexSpace;
177
154
  panel.style.flex = `${newFlexBasis} ${newFlexBasis} 0`;
178
155
  flexSum += newFlexBasis;
179
156
  });
180
157
 
181
- // ⭐⭐ 계산된 합계를 로그로 출력하여 확인 ⭐⭐
182
- console.log(`newTotalFlexSpace: ${totalFlexSpace}`);
158
+ console.log(`dragOffset: ${dragOffset}`);
183
159
  console.log(`Calculated FlexSum: ${flexSum}`);
184
160
  };
185
161
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.1069.0",
4
+ "version": "6.1071.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -39,9 +39,6 @@ class nxSplitter extends HTMLElement {
39
39
  const splitterRect = this.getBoundingClientRect();
40
40
  const isHorizontal = this.#mode === "h";
41
41
 
42
- // ⭐ 마우스 초기 위치 저장 ⭐
43
- const initialMousePos = isHorizontal ? e.clientX : e.clientY;
44
-
45
42
  // 마우스 포인터와 스플리터 시작점 사이의 거리
46
43
  const clickOffset = isHorizontal
47
44
  ? e.clientX - splitterRect.left
@@ -69,23 +66,25 @@ class nxSplitter extends HTMLElement {
69
66
  }
70
67
 
71
68
  (parent.shadowRoot || parent).appendChild(dragBar);
72
- //const parentRect = parent.getBoundingClientRect();
69
+ const dragBarOffsetParentRect = dragBar.offsetParent.getBoundingClientRect();
70
+
73
71
  const prevRect = prev.getBoundingClientRect();
74
72
  const nextRect = next.getBoundingClientRect();
75
73
 
76
74
  // 드래그 바의 초기 위치와 크기 설정
77
- // startDrag 메서드 내부
78
- const dragBarOffsetParentRect = dragBar.offsetParent.getBoundingClientRect();
75
+ const initialSplitterPosInParent = isHorizontal
76
+ ? splitterRect.left - dragBarOffsetParentRect.left
77
+ : splitterRect.top - dragBarOffsetParentRect.top;
79
78
 
80
79
  if (isHorizontal) {
81
80
  dragBar.style.top = "0";
82
- dragBar.style.left = `${e.clientX - dragBarOffsetParentRect.left}px`;
83
- dragBar.style.width = "1px"; // ⭐ 1px로 변경
81
+ dragBar.style.left = `${initialSplitterPosInParent}px`;
82
+ dragBar.style.width = "1px";
84
83
  dragBar.style.height = "100%";
85
84
  } else {
86
85
  dragBar.style.left = "0";
87
- dragBar.style.top = `${e.clientY - dragBarOffsetParentRect.top}px`;
88
- dragBar.style.height = "1px"; // ⭐ 1px로 변경
86
+ dragBar.style.top = `${initialSplitterPosInParent}px`;
87
+ dragBar.style.height = "1px";
89
88
  dragBar.style.width = "100%";
90
89
  }
91
90
 
@@ -109,11 +108,9 @@ class nxSplitter extends HTMLElement {
109
108
  } else {
110
109
  dragBar.style.top = `${clampedPos}px`;
111
110
  }
112
-
113
- console.log(clampedPos);
114
111
  };
115
112
 
116
- const onUp = (e) => {
113
+ const onUp = () => {
117
114
  window.removeEventListener("mousemove", onMove);
118
115
  window.removeEventListener("mouseup", onUp);
119
116
  dragBar.remove();
@@ -121,10 +118,17 @@ class nxSplitter extends HTMLElement {
121
118
  const allChildren = Array.from(parent.children);
122
119
  const allPanels = allChildren.filter(el => el.tagName.toLowerCase() !== 'nx-splitter');
123
120
 
124
- // ⭐⭐ 부모의 픽셀 크기 ⭐⭐
125
- const totalContainerSize = isHorizontal ? parent.getBoundingClientRect().width : parent.getBoundingClientRect().height;
121
+ const finalDragBarPos = isHorizontal ? parseFloat(dragBar.style.left) : parseFloat(dragBar.style.top);
122
+ const dragOffset = finalDragBarPos - initialSplitterPosInParent;
123
+
124
+ const prevSize = isHorizontal ? prev.getBoundingClientRect().width : prev.getBoundingClientRect().height;
125
+ const nextSize = isHorizontal ? next.getBoundingClientRect().width : next.getBoundingClientRect().height;
126
+
127
+ const newPrevSize = prevSize + dragOffset;
128
+ const newNextSize = nextSize - dragOffset;
129
+
130
+ const initialSizes = allPanels.map(panel => isHorizontal ? panel.getBoundingClientRect().width : panel.getBoundingClientRect().height);
126
131
 
127
- // ⭐⭐ 모든 스플리터의 총 픽셀 크기 ⭐⭐
128
132
  const totalSplitterSize = allChildren.reduce((sum, child) => {
129
133
  if (child.tagName.toLowerCase() === 'nx-splitter') {
130
134
  return sum + (isHorizontal ? child.getBoundingClientRect().width : child.getBoundingClientRect().height);
@@ -132,32 +136,8 @@ class nxSplitter extends HTMLElement {
132
136
  return sum;
133
137
  }, 0);
134
138
 
135
- // ⭐⭐ Flexbox의 'gap' 크기 계산 (하드코딩된 8px 사용) ⭐⭐
136
- const gapCount = allChildren.length - 1;
137
- const totalGapSize = 0;//gapCount * 8;
138
-
139
- // ⭐⭐ Flexbox 컨테이너의 '총 유효 공간' (패널들이 차지할 수 있는 공간) 계산 ⭐⭐
140
- const totalFlexSpace = totalContainerSize - totalSplitterSize - totalGapSize;
141
-
142
- // ⭐⭐ 모든 패널의 초기 크기를 미리 저장 ⭐⭐
143
- const initialSizes = allPanels.map(panel => isHorizontal ? panel.getBoundingClientRect().width : panel.getBoundingClientRect().height);
144
-
145
-
146
- // 드래그로 인한 픽셀 변화량 계산
147
- //const dragOffset = (isHorizontal ? parseFloat(dragBar.style.left) : parseFloat(dragBar.style.top)) -
148
- // (isHorizontal ? this.getBoundingClientRect().left - parent.getBoundingClientRect().left : this.getBoundingClientRect().top - parent.getBoundingClientRect().top);
149
-
150
- // ⭐ 정확한 dragOffset 계산 ⭐
151
- const finalMousePos = isHorizontal ? e.clientX : e.clientY;
152
- const dragOffset = finalMousePos - initialMousePos;
153
-
154
- const prevSize = isHorizontal ? prev.getBoundingClientRect().width : prev.getBoundingClientRect().height;
155
- const nextSize = isHorizontal ? next.getBoundingClientRect().width : next.getBoundingClientRect().height;
156
-
157
- const newPrevSize = prevSize + dragOffset;
158
- const newNextSize = nextSize - dragOffset;
159
-
160
- console.log(prevSize, newPrevSize);
139
+ const totalContainerSize = (isHorizontal ? parent.getBoundingClientRect().width : parent.getBoundingClientRect().height);
140
+ const totalFlexSpace = totalContainerSize - totalSplitterSize;
161
141
 
162
142
  let flexSum = 0;
163
143
  allPanels.forEach((panel, index) => {
@@ -170,16 +150,12 @@ class nxSplitter extends HTMLElement {
170
150
  newSize = initialSizes[index];
171
151
  }
172
152
 
173
- //console.log(newSize)
174
-
175
- // ⭐⭐ 새로운 FlexBasis 계산 ⭐⭐
176
153
  const newFlexBasis = newSize / totalFlexSpace;
177
154
  panel.style.flex = `${newFlexBasis} ${newFlexBasis} 0`;
178
155
  flexSum += newFlexBasis;
179
156
  });
180
157
 
181
- // ⭐⭐ 계산된 합계를 로그로 출력하여 확인 ⭐⭐
182
- console.log(`newTotalFlexSpace: ${totalFlexSpace}`);
158
+ console.log(`dragOffset: ${dragOffset}`);
183
159
  console.log(`Calculated FlexSum: ${flexSum}`);
184
160
  };
185
161