ninegrid2 6.753.0 → 6.755.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.
@@ -121166,34 +121166,51 @@ class nxSplitter extends HTMLElement {
121166
121166
  return allSplitters.at(-1) === this;
121167
121167
  };
121168
121168
 
121169
+ #getSiblingSizeSum = () => {
121170
+ const parent = this.parentElement;
121171
+ if (!parent) return 0;
121172
+
121173
+ const isHorizontal = this.#mode === "h";
121174
+
121175
+ return Array.from(parent.children).reduce((sum, el) => {
121176
+ const size = isHorizontal ? el.offsetWidth : el.offsetHeight;
121177
+ return sum + size;
121178
+ }, 0);
121179
+ };
121180
+
121181
+
121169
121182
  #prepareLayout = () => {
121170
121183
 
121171
121184
 
121172
121185
 
121173
121186
  const isHorizontal = this.#mode === "h";
121174
- const splitterSize = isHorizontal ? this.offsetWidth : this.offsetHeight;
121187
+ isHorizontal ? this.offsetWidth : this.offsetHeight;
121175
121188
  const prev = this.previousElementSibling;
121176
121189
  const next = this.nextElementSibling;
121177
121190
  const parent = this.parentElement;
121178
121191
  if (!prev || !next || !parent) return;
121179
121192
 
121180
- isHorizontal
121193
+ const currentTotal = this.#getSiblingSizeSum();
121194
+ console.log(siblingSize);
121195
+
121196
+ const parentSize = isHorizontal
121181
121197
  ? parent.getBoundingClientRect().width
121182
121198
  : parent.getBoundingClientRect().height;
121183
121199
 
121184
121200
  // 현재 패널 크기 측정
121185
121201
  const prevSize = isHorizontal ? prev.offsetWidth : prev.offsetHeight;
121186
121202
  const nextSize = isHorizontal ? next.offsetWidth : next.offsetHeight;
121187
- const totalPanelSize = prevSize + nextSize;
121203
+ //const totalPanelSize = siblingSize;
121188
121204
 
121189
121205
  // 현재 비율 계산
121190
- ///const prevRatio = totalPanelSize ? prevSize / totalPanelSize : 0.5;
121191
- const prevRatio = totalPanelSize ? prevSize / (totalPanelSize + splitterSize) : 0.5;
121206
+ const prevRatio = currentTotal ? prevSize / currentTotal : 0.5;
121207
+
121208
+ const newPrevSize = parentSize * prevRatio;
121209
+ const newNextSize = (prevSize + nextSize) - newPrevSize;
121210
+
121192
121211
 
121193
- const newPrevSize = (totalPanelSize + splitterSize) * prevRatio;
121194
- const newNextSize = totalPanelSize - newPrevSize;
121195
121212
 
121196
- console.log(newPrevSize, newNextSize);
121213
+ console.log(newPrevSize, newNextSize, prevRatio);
121197
121214
 
121198
121215
  if (isHorizontal) {
121199
121216
  prev.style.width = `${newPrevSize}px`;
@@ -121162,34 +121162,51 @@ class nxSplitter extends HTMLElement {
121162
121162
  return allSplitters.at(-1) === this;
121163
121163
  };
121164
121164
 
121165
+ #getSiblingSizeSum = () => {
121166
+ const parent = this.parentElement;
121167
+ if (!parent) return 0;
121168
+
121169
+ const isHorizontal = this.#mode === "h";
121170
+
121171
+ return Array.from(parent.children).reduce((sum, el) => {
121172
+ const size = isHorizontal ? el.offsetWidth : el.offsetHeight;
121173
+ return sum + size;
121174
+ }, 0);
121175
+ };
121176
+
121177
+
121165
121178
  #prepareLayout = () => {
121166
121179
 
121167
121180
 
121168
121181
 
121169
121182
  const isHorizontal = this.#mode === "h";
121170
- const splitterSize = isHorizontal ? this.offsetWidth : this.offsetHeight;
121183
+ isHorizontal ? this.offsetWidth : this.offsetHeight;
121171
121184
  const prev = this.previousElementSibling;
121172
121185
  const next = this.nextElementSibling;
121173
121186
  const parent = this.parentElement;
121174
121187
  if (!prev || !next || !parent) return;
121175
121188
 
121176
- isHorizontal
121189
+ const currentTotal = this.#getSiblingSizeSum();
121190
+ console.log(siblingSize);
121191
+
121192
+ const parentSize = isHorizontal
121177
121193
  ? parent.getBoundingClientRect().width
121178
121194
  : parent.getBoundingClientRect().height;
121179
121195
 
121180
121196
  // 현재 패널 크기 측정
121181
121197
  const prevSize = isHorizontal ? prev.offsetWidth : prev.offsetHeight;
121182
121198
  const nextSize = isHorizontal ? next.offsetWidth : next.offsetHeight;
121183
- const totalPanelSize = prevSize + nextSize;
121199
+ //const totalPanelSize = siblingSize;
121184
121200
 
121185
121201
  // 현재 비율 계산
121186
- ///const prevRatio = totalPanelSize ? prevSize / totalPanelSize : 0.5;
121187
- const prevRatio = totalPanelSize ? prevSize / (totalPanelSize + splitterSize) : 0.5;
121202
+ const prevRatio = currentTotal ? prevSize / currentTotal : 0.5;
121203
+
121204
+ const newPrevSize = parentSize * prevRatio;
121205
+ const newNextSize = (prevSize + nextSize) - newPrevSize;
121206
+
121188
121207
 
121189
- const newPrevSize = (totalPanelSize + splitterSize) * prevRatio;
121190
- const newNextSize = totalPanelSize - newPrevSize;
121191
121208
 
121192
- console.log(newPrevSize, newNextSize);
121209
+ console.log(newPrevSize, newNextSize, prevRatio);
121193
121210
 
121194
121211
  if (isHorizontal) {
121195
121212
  prev.style.width = `${newPrevSize}px`;
@@ -179,6 +179,19 @@ class nxSplitter extends HTMLElement {
179
179
  return allSplitters.at(-1) === this;
180
180
  };
181
181
 
182
+ #getSiblingSizeSum = () => {
183
+ const parent = this.parentElement;
184
+ if (!parent) return 0;
185
+
186
+ const isHorizontal = this.#mode === "h";
187
+
188
+ return Array.from(parent.children).reduce((sum, el) => {
189
+ const size = isHorizontal ? el.offsetWidth : el.offsetHeight;
190
+ return sum + size;
191
+ }, 0);
192
+ };
193
+
194
+
182
195
  #prepareLayout = () => {
183
196
 
184
197
 
@@ -190,6 +203,9 @@ class nxSplitter extends HTMLElement {
190
203
  const parent = this.parentElement;
191
204
  if (!prev || !next || !parent) return;
192
205
 
206
+ const currentTotal = this.#getSiblingSizeSum();
207
+ console.log(siblingSize);
208
+
193
209
  const parentSize = isHorizontal
194
210
  ? parent.getBoundingClientRect().width
195
211
  : parent.getBoundingClientRect().height;
@@ -197,20 +213,22 @@ class nxSplitter extends HTMLElement {
197
213
  // 현재 패널 크기 측정
198
214
  const prevSize = isHorizontal ? prev.offsetWidth : prev.offsetHeight;
199
215
  const nextSize = isHorizontal ? next.offsetWidth : next.offsetHeight;
200
- const totalPanelSize = prevSize + nextSize;
216
+ //const totalPanelSize = siblingSize;
201
217
 
202
218
  // 현재 비율 계산
203
- ///const prevRatio = totalPanelSize ? prevSize / totalPanelSize : 0.5;
204
- const prevRatio = totalPanelSize ? prevSize / (totalPanelSize + splitterSize) : 0.5;
205
- const nextRatio = 1 - prevRatio;
219
+ const prevRatio = currentTotal ? prevSize / currentTotal : 0.5;
220
+ //const prevRatio = parentSize ? prevSize / parentSize : 0.5;
221
+ //const nextRatio = 1 - prevRatio;
206
222
 
207
223
  // 새로운 available 크기
208
224
  const available = parentSize - splitterSize;
209
225
 
210
- const newPrevSize = (totalPanelSize + splitterSize) * prevRatio;
211
- const newNextSize = totalPanelSize - newPrevSize;
226
+ const newPrevSize = parentSize * prevRatio;
227
+ const newNextSize = (prevSize + nextSize) - newPrevSize;
228
+
229
+
212
230
 
213
- console.log(newPrevSize, newNextSize);
231
+ console.log(newPrevSize, newNextSize, prevRatio);
214
232
 
215
233
  if (isHorizontal) {
216
234
  prev.style.width = `${newPrevSize}px`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.753.0",
4
+ "version": "6.755.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -179,6 +179,19 @@ class nxSplitter extends HTMLElement {
179
179
  return allSplitters.at(-1) === this;
180
180
  };
181
181
 
182
+ #getSiblingSizeSum = () => {
183
+ const parent = this.parentElement;
184
+ if (!parent) return 0;
185
+
186
+ const isHorizontal = this.#mode === "h";
187
+
188
+ return Array.from(parent.children).reduce((sum, el) => {
189
+ const size = isHorizontal ? el.offsetWidth : el.offsetHeight;
190
+ return sum + size;
191
+ }, 0);
192
+ };
193
+
194
+
182
195
  #prepareLayout = () => {
183
196
 
184
197
 
@@ -190,6 +203,9 @@ class nxSplitter extends HTMLElement {
190
203
  const parent = this.parentElement;
191
204
  if (!prev || !next || !parent) return;
192
205
 
206
+ const currentTotal = this.#getSiblingSizeSum();
207
+ console.log(siblingSize);
208
+
193
209
  const parentSize = isHorizontal
194
210
  ? parent.getBoundingClientRect().width
195
211
  : parent.getBoundingClientRect().height;
@@ -197,20 +213,22 @@ class nxSplitter extends HTMLElement {
197
213
  // 현재 패널 크기 측정
198
214
  const prevSize = isHorizontal ? prev.offsetWidth : prev.offsetHeight;
199
215
  const nextSize = isHorizontal ? next.offsetWidth : next.offsetHeight;
200
- const totalPanelSize = prevSize + nextSize;
216
+ //const totalPanelSize = siblingSize;
201
217
 
202
218
  // 현재 비율 계산
203
- ///const prevRatio = totalPanelSize ? prevSize / totalPanelSize : 0.5;
204
- const prevRatio = totalPanelSize ? prevSize / (totalPanelSize + splitterSize) : 0.5;
205
- const nextRatio = 1 - prevRatio;
219
+ const prevRatio = currentTotal ? prevSize / currentTotal : 0.5;
220
+ //const prevRatio = parentSize ? prevSize / parentSize : 0.5;
221
+ //const nextRatio = 1 - prevRatio;
206
222
 
207
223
  // 새로운 available 크기
208
224
  const available = parentSize - splitterSize;
209
225
 
210
- const newPrevSize = (totalPanelSize + splitterSize) * prevRatio;
211
- const newNextSize = totalPanelSize - newPrevSize;
226
+ const newPrevSize = parentSize * prevRatio;
227
+ const newNextSize = (prevSize + nextSize) - newPrevSize;
228
+
229
+
212
230
 
213
- console.log(newPrevSize, newNextSize);
231
+ console.log(newPrevSize, newNextSize, prevRatio);
214
232
 
215
233
  if (isHorizontal) {
216
234
  prev.style.width = `${newPrevSize}px`;