ninegrid2 6.851.0 → 6.853.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.
- package/dist/bundle.cjs.js +121 -147
- package/dist/bundle.esm.js +121 -147
- package/dist/nx/nxSplitter.js +121 -147
- package/package.json +1 -1
- package/src/nx/nxSplitter.js +121 -147
package/dist/bundle.cjs.js
CHANGED
|
@@ -121168,153 +121168,6 @@ class nxSplitter extends HTMLElement {
|
|
|
121168
121168
|
};
|
|
121169
121169
|
|
|
121170
121170
|
#startDrag_BAK = (e) => {
|
|
121171
|
-
|
|
121172
|
-
e.preventDefault(); // 기본 drag/select 동작 제거
|
|
121173
|
-
e.stopPropagation();
|
|
121174
|
-
|
|
121175
|
-
const splitterRect = this.getBoundingClientRect();
|
|
121176
|
-
const clickOffset = this.#mode === "h"
|
|
121177
|
-
? e.clientX - splitterRect.left
|
|
121178
|
-
: e.clientY - splitterRect.top;
|
|
121179
|
-
|
|
121180
|
-
//const mode = this.#mode;
|
|
121181
|
-
const dragBar = document.createElement("div");
|
|
121182
|
-
dragBar.className = `nx-splitter-drag-bar-${this.#mode}`;
|
|
121183
|
-
|
|
121184
|
-
// 스타일 지정
|
|
121185
|
-
Object.assign(dragBar.style, {
|
|
121186
|
-
position: "absolute",
|
|
121187
|
-
zIndex: "999",
|
|
121188
|
-
background: "#666",
|
|
121189
|
-
opacity: "0.6",
|
|
121190
|
-
pointerEvents: "none"
|
|
121191
|
-
});
|
|
121192
|
-
|
|
121193
|
-
const root = this.getRootNode({ composed: true });
|
|
121194
|
-
const parent = root instanceof ShadowRoot ? root.host : this.parentElement || document.body;
|
|
121195
|
-
|
|
121196
|
-
//const parent = this.getRootNode().host || this.parentElement;
|
|
121197
|
-
const prev = this.previousElementSibling;
|
|
121198
|
-
const next = this.nextElementSibling;
|
|
121199
|
-
|
|
121200
|
-
if (!parent || !prev || !next) return;
|
|
121201
|
-
|
|
121202
|
-
const parentRect = parent.getBoundingClientRect();
|
|
121203
|
-
const prevRect = prev.getBoundingClientRect();
|
|
121204
|
-
const nextRect = next.getBoundingClientRect();
|
|
121205
|
-
|
|
121206
|
-
const computedStyle = getComputedStyle(parent);
|
|
121207
|
-
parseFloat(computedStyle.paddingLeft) || 0;
|
|
121208
|
-
const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
|
|
121209
|
-
|
|
121210
|
-
|
|
121211
|
-
let el = parent;
|
|
121212
|
-
let totalPadding = 0;
|
|
121213
|
-
|
|
121214
|
-
while (el) {
|
|
121215
|
-
console.log(el, el.parentElement, el.host);
|
|
121216
|
-
if (el instanceof Element) {
|
|
121217
|
-
const style = getComputedStyle(el);
|
|
121218
|
-
totalPadding += parseFloat(style.paddingLeft) || 0;
|
|
121219
|
-
el = el.parentElement;
|
|
121220
|
-
} else if (el instanceof ShadowRoot) {
|
|
121221
|
-
el = el.host;
|
|
121222
|
-
} else {
|
|
121223
|
-
break;
|
|
121224
|
-
}
|
|
121225
|
-
}
|
|
121226
|
-
|
|
121227
|
-
|
|
121228
|
-
|
|
121229
|
-
|
|
121230
|
-
console.log(totalPadding, e.clientX, parentRect.left);
|
|
121231
|
-
|
|
121232
|
-
const left = e.clientX - parentRect.left + totalPadding;
|
|
121233
|
-
const top = e.clientY - parentRect.top + paddingTop;
|
|
121234
|
-
|
|
121235
|
-
console.log("1------", left, top);
|
|
121236
|
-
|
|
121237
|
-
// 방향별 위치 설정
|
|
121238
|
-
if (this.#mode === "h") {
|
|
121239
|
-
dragBar.style.top = "0";
|
|
121240
|
-
dragBar.style.left = `${left}px`;
|
|
121241
|
-
dragBar.style.width = "1px";
|
|
121242
|
-
dragBar.style.height = "100%";
|
|
121243
|
-
} else {
|
|
121244
|
-
dragBar.style.left = "0";
|
|
121245
|
-
dragBar.style.top = `${top}px`;
|
|
121246
|
-
dragBar.style.height = "1px";
|
|
121247
|
-
dragBar.style.width = "100%";
|
|
121248
|
-
}
|
|
121249
|
-
|
|
121250
|
-
// 👇 부모 노드 기준으로 삽입
|
|
121251
|
-
(parent.shadowRoot || parent).appendChild(dragBar);
|
|
121252
|
-
|
|
121253
|
-
const min = this.#mode === "h" ? prevRect.left : prevRect.top;
|
|
121254
|
-
const max = this.#mode === "h" ? nextRect.right : nextRect.bottom;
|
|
121255
|
-
|
|
121256
|
-
const onMove = e => {
|
|
121257
|
-
const clientPos = this.#mode === "h" ? e.clientX : e.clientY;
|
|
121258
|
-
const position = Math.max(min, Math.min(clientPos, max));
|
|
121259
|
-
|
|
121260
|
-
const relative = position - parent.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
121261
|
-
|
|
121262
|
-
if (this.#mode === "h") {
|
|
121263
|
-
dragBar.style.left = `${relative}px`;
|
|
121264
|
-
} else {
|
|
121265
|
-
dragBar.style.top = `${relative}px`;
|
|
121266
|
-
}
|
|
121267
|
-
};
|
|
121268
|
-
|
|
121269
|
-
|
|
121270
|
-
|
|
121271
|
-
const onUp = (e) => {
|
|
121272
|
-
|
|
121273
|
-
window.removeEventListener("mousemove", onMove);
|
|
121274
|
-
window.removeEventListener("mouseup", onUp);
|
|
121275
|
-
dragBar.remove();
|
|
121276
|
-
|
|
121277
|
-
|
|
121278
|
-
// 기준: prev + next 너비 합계
|
|
121279
|
-
const totalSize = this.#mode === "h"
|
|
121280
|
-
? prev.offsetWidth + next.offsetWidth
|
|
121281
|
-
: prev.offsetHeight + next.offsetHeight;
|
|
121282
|
-
|
|
121283
|
-
// prev 기준 상대 거리 (드래그 거리)
|
|
121284
|
-
|
|
121285
|
-
let delta = this.#mode === "h"
|
|
121286
|
-
? e.clientX - prev.getBoundingClientRect().left - clickOffset
|
|
121287
|
-
: e.clientY - prev.getBoundingClientRect().top - clickOffset;
|
|
121288
|
-
//let delta = dragStartPos - prev.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
121289
|
-
|
|
121290
|
-
const min = 1;
|
|
121291
|
-
const max = totalSize - 1;
|
|
121292
|
-
delta = Math.max(min, Math.min(delta, max));
|
|
121293
|
-
|
|
121294
|
-
|
|
121295
|
-
const prev1 = prev.style.flex;
|
|
121296
|
-
const prev2 = next.style.flex;
|
|
121297
|
-
prev.style.flex = "none";
|
|
121298
|
-
next.style.flex = "none";
|
|
121299
|
-
|
|
121300
|
-
// 📌 사이즈 적용
|
|
121301
|
-
if (this.#mode === "h") {
|
|
121302
|
-
prev.style.width = `${delta}px`;
|
|
121303
|
-
next.style.width = `${totalSize - delta}px`;
|
|
121304
|
-
} else {
|
|
121305
|
-
prev.style.height = `${delta}px`;
|
|
121306
|
-
next.style.height = `${totalSize - delta}px`;
|
|
121307
|
-
}
|
|
121308
|
-
|
|
121309
|
-
prev.style.flex = prev1;
|
|
121310
|
-
next.style.flex = prev2;
|
|
121311
|
-
};
|
|
121312
|
-
|
|
121313
|
-
window.addEventListener("mousemove", onMove);
|
|
121314
|
-
window.addEventListener("mouseup", onUp);
|
|
121315
|
-
};
|
|
121316
|
-
|
|
121317
|
-
#startDrag = (e) => {
|
|
121318
121171
|
e.preventDefault();
|
|
121319
121172
|
e.stopPropagation();
|
|
121320
121173
|
|
|
@@ -121453,6 +121306,127 @@ class nxSplitter extends HTMLElement {
|
|
|
121453
121306
|
window.addEventListener("mouseup", onUp);
|
|
121454
121307
|
};
|
|
121455
121308
|
|
|
121309
|
+
#startDrag = (e) => {
|
|
121310
|
+
|
|
121311
|
+
e.preventDefault(); // 기본 drag/select 동작 제거
|
|
121312
|
+
e.stopPropagation();
|
|
121313
|
+
|
|
121314
|
+
const splitterRect = this.getBoundingClientRect();
|
|
121315
|
+
const clickOffset = this.#mode === "h"
|
|
121316
|
+
? e.clientX - splitterRect.left
|
|
121317
|
+
: e.clientY - splitterRect.top;
|
|
121318
|
+
|
|
121319
|
+
//const mode = this.#mode;
|
|
121320
|
+
const dragBar = document.createElement("div");
|
|
121321
|
+
dragBar.className = `nx-splitter-drag-bar-${this.#mode}`;
|
|
121322
|
+
|
|
121323
|
+
// 스타일 지정
|
|
121324
|
+
Object.assign(dragBar.style, {
|
|
121325
|
+
position: "absolute",
|
|
121326
|
+
zIndex: "999",
|
|
121327
|
+
background: "#666",
|
|
121328
|
+
opacity: "0.6",
|
|
121329
|
+
pointerEvents: "none"
|
|
121330
|
+
});
|
|
121331
|
+
|
|
121332
|
+
const root = this.getRootNode({ composed: true });
|
|
121333
|
+
const parent = root instanceof ShadowRoot ? root.host : this.parentElement || document.body;
|
|
121334
|
+
|
|
121335
|
+
//const parent = this.getRootNode().host || this.parentElement;
|
|
121336
|
+
const prev = this.previousElementSibling;
|
|
121337
|
+
const next = this.nextElementSibling;
|
|
121338
|
+
|
|
121339
|
+
if (!parent || !prev || !next) return;
|
|
121340
|
+
|
|
121341
|
+
const parentRect = parent.getBoundingClientRect();
|
|
121342
|
+
const prevRect = prev.getBoundingClientRect();
|
|
121343
|
+
const nextRect = next.getBoundingClientRect();
|
|
121344
|
+
|
|
121345
|
+
const left = e.clientX - (parent.offsetLeft + parent.clientLeft);
|
|
121346
|
+
const top = e.clientY - (parent.offsetTop + parentRect.top);
|
|
121347
|
+
|
|
121348
|
+
console.log(left, top);
|
|
121349
|
+
|
|
121350
|
+
// 방향별 위치 설정
|
|
121351
|
+
if (this.#mode === "h") {
|
|
121352
|
+
dragBar.style.top = "0";
|
|
121353
|
+
dragBar.style.left = `${left}px`;
|
|
121354
|
+
dragBar.style.width = "1px";
|
|
121355
|
+
dragBar.style.height = "100%";
|
|
121356
|
+
} else {
|
|
121357
|
+
dragBar.style.left = "0";
|
|
121358
|
+
dragBar.style.top = `${top}px`;
|
|
121359
|
+
dragBar.style.height = "1px";
|
|
121360
|
+
dragBar.style.width = "100%";
|
|
121361
|
+
}
|
|
121362
|
+
|
|
121363
|
+
// 👇 부모 노드 기준으로 삽입
|
|
121364
|
+
(parent.shadowRoot || parent).appendChild(dragBar);
|
|
121365
|
+
|
|
121366
|
+
const min = this.#mode === "h" ? prevRect.left : prevRect.top;
|
|
121367
|
+
const max = this.#mode === "h" ? nextRect.right : nextRect.bottom;
|
|
121368
|
+
|
|
121369
|
+
const onMove = e => {
|
|
121370
|
+
const clientPos = this.#mode === "h" ? e.clientX : e.clientY;
|
|
121371
|
+
const position = Math.max(min, Math.min(clientPos, max));
|
|
121372
|
+
|
|
121373
|
+
const relative = position - parent.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
121374
|
+
|
|
121375
|
+
if (this.#mode === "h") {
|
|
121376
|
+
dragBar.style.left = `${relative}px`;
|
|
121377
|
+
} else {
|
|
121378
|
+
dragBar.style.top = `${relative}px`;
|
|
121379
|
+
}
|
|
121380
|
+
};
|
|
121381
|
+
|
|
121382
|
+
|
|
121383
|
+
|
|
121384
|
+
const onUp = (e) => {
|
|
121385
|
+
|
|
121386
|
+
window.removeEventListener("mousemove", onMove);
|
|
121387
|
+
window.removeEventListener("mouseup", onUp);
|
|
121388
|
+
dragBar.remove();
|
|
121389
|
+
|
|
121390
|
+
|
|
121391
|
+
// 기준: prev + next 너비 합계
|
|
121392
|
+
const totalSize = this.#mode === "h"
|
|
121393
|
+
? prev.offsetWidth + next.offsetWidth
|
|
121394
|
+
: prev.offsetHeight + next.offsetHeight;
|
|
121395
|
+
|
|
121396
|
+
// prev 기준 상대 거리 (드래그 거리)
|
|
121397
|
+
|
|
121398
|
+
let delta = this.#mode === "h"
|
|
121399
|
+
? e.clientX - prev.getBoundingClientRect().left - clickOffset
|
|
121400
|
+
: e.clientY - prev.getBoundingClientRect().top - clickOffset;
|
|
121401
|
+
//let delta = dragStartPos - prev.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
121402
|
+
|
|
121403
|
+
const min = 1;
|
|
121404
|
+
const max = totalSize - 1;
|
|
121405
|
+
delta = Math.max(min, Math.min(delta, max));
|
|
121406
|
+
|
|
121407
|
+
|
|
121408
|
+
const prev1 = prev.style.flex;
|
|
121409
|
+
const prev2 = next.style.flex;
|
|
121410
|
+
prev.style.flex = "none";
|
|
121411
|
+
next.style.flex = "none";
|
|
121412
|
+
|
|
121413
|
+
// 📌 사이즈 적용
|
|
121414
|
+
if (this.#mode === "h") {
|
|
121415
|
+
prev.style.width = `${delta}px`;
|
|
121416
|
+
next.style.width = `${totalSize - delta}px`;
|
|
121417
|
+
} else {
|
|
121418
|
+
prev.style.height = `${delta}px`;
|
|
121419
|
+
next.style.height = `${totalSize - delta}px`;
|
|
121420
|
+
}
|
|
121421
|
+
|
|
121422
|
+
prev.style.flex = prev1;
|
|
121423
|
+
next.style.flex = prev2;
|
|
121424
|
+
};
|
|
121425
|
+
|
|
121426
|
+
window.addEventListener("mousemove", onMove);
|
|
121427
|
+
window.addEventListener("mouseup", onUp);
|
|
121428
|
+
};
|
|
121429
|
+
|
|
121456
121430
|
|
|
121457
121431
|
#init = () => {
|
|
121458
121432
|
this.#detectMode(this);
|
package/dist/bundle.esm.js
CHANGED
|
@@ -121164,153 +121164,6 @@ class nxSplitter extends HTMLElement {
|
|
|
121164
121164
|
};
|
|
121165
121165
|
|
|
121166
121166
|
#startDrag_BAK = (e) => {
|
|
121167
|
-
|
|
121168
|
-
e.preventDefault(); // 기본 drag/select 동작 제거
|
|
121169
|
-
e.stopPropagation();
|
|
121170
|
-
|
|
121171
|
-
const splitterRect = this.getBoundingClientRect();
|
|
121172
|
-
const clickOffset = this.#mode === "h"
|
|
121173
|
-
? e.clientX - splitterRect.left
|
|
121174
|
-
: e.clientY - splitterRect.top;
|
|
121175
|
-
|
|
121176
|
-
//const mode = this.#mode;
|
|
121177
|
-
const dragBar = document.createElement("div");
|
|
121178
|
-
dragBar.className = `nx-splitter-drag-bar-${this.#mode}`;
|
|
121179
|
-
|
|
121180
|
-
// 스타일 지정
|
|
121181
|
-
Object.assign(dragBar.style, {
|
|
121182
|
-
position: "absolute",
|
|
121183
|
-
zIndex: "999",
|
|
121184
|
-
background: "#666",
|
|
121185
|
-
opacity: "0.6",
|
|
121186
|
-
pointerEvents: "none"
|
|
121187
|
-
});
|
|
121188
|
-
|
|
121189
|
-
const root = this.getRootNode({ composed: true });
|
|
121190
|
-
const parent = root instanceof ShadowRoot ? root.host : this.parentElement || document.body;
|
|
121191
|
-
|
|
121192
|
-
//const parent = this.getRootNode().host || this.parentElement;
|
|
121193
|
-
const prev = this.previousElementSibling;
|
|
121194
|
-
const next = this.nextElementSibling;
|
|
121195
|
-
|
|
121196
|
-
if (!parent || !prev || !next) return;
|
|
121197
|
-
|
|
121198
|
-
const parentRect = parent.getBoundingClientRect();
|
|
121199
|
-
const prevRect = prev.getBoundingClientRect();
|
|
121200
|
-
const nextRect = next.getBoundingClientRect();
|
|
121201
|
-
|
|
121202
|
-
const computedStyle = getComputedStyle(parent);
|
|
121203
|
-
parseFloat(computedStyle.paddingLeft) || 0;
|
|
121204
|
-
const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
|
|
121205
|
-
|
|
121206
|
-
|
|
121207
|
-
let el = parent;
|
|
121208
|
-
let totalPadding = 0;
|
|
121209
|
-
|
|
121210
|
-
while (el) {
|
|
121211
|
-
console.log(el, el.parentElement, el.host);
|
|
121212
|
-
if (el instanceof Element) {
|
|
121213
|
-
const style = getComputedStyle(el);
|
|
121214
|
-
totalPadding += parseFloat(style.paddingLeft) || 0;
|
|
121215
|
-
el = el.parentElement;
|
|
121216
|
-
} else if (el instanceof ShadowRoot) {
|
|
121217
|
-
el = el.host;
|
|
121218
|
-
} else {
|
|
121219
|
-
break;
|
|
121220
|
-
}
|
|
121221
|
-
}
|
|
121222
|
-
|
|
121223
|
-
|
|
121224
|
-
|
|
121225
|
-
|
|
121226
|
-
console.log(totalPadding, e.clientX, parentRect.left);
|
|
121227
|
-
|
|
121228
|
-
const left = e.clientX - parentRect.left + totalPadding;
|
|
121229
|
-
const top = e.clientY - parentRect.top + paddingTop;
|
|
121230
|
-
|
|
121231
|
-
console.log("1------", left, top);
|
|
121232
|
-
|
|
121233
|
-
// 방향별 위치 설정
|
|
121234
|
-
if (this.#mode === "h") {
|
|
121235
|
-
dragBar.style.top = "0";
|
|
121236
|
-
dragBar.style.left = `${left}px`;
|
|
121237
|
-
dragBar.style.width = "1px";
|
|
121238
|
-
dragBar.style.height = "100%";
|
|
121239
|
-
} else {
|
|
121240
|
-
dragBar.style.left = "0";
|
|
121241
|
-
dragBar.style.top = `${top}px`;
|
|
121242
|
-
dragBar.style.height = "1px";
|
|
121243
|
-
dragBar.style.width = "100%";
|
|
121244
|
-
}
|
|
121245
|
-
|
|
121246
|
-
// 👇 부모 노드 기준으로 삽입
|
|
121247
|
-
(parent.shadowRoot || parent).appendChild(dragBar);
|
|
121248
|
-
|
|
121249
|
-
const min = this.#mode === "h" ? prevRect.left : prevRect.top;
|
|
121250
|
-
const max = this.#mode === "h" ? nextRect.right : nextRect.bottom;
|
|
121251
|
-
|
|
121252
|
-
const onMove = e => {
|
|
121253
|
-
const clientPos = this.#mode === "h" ? e.clientX : e.clientY;
|
|
121254
|
-
const position = Math.max(min, Math.min(clientPos, max));
|
|
121255
|
-
|
|
121256
|
-
const relative = position - parent.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
121257
|
-
|
|
121258
|
-
if (this.#mode === "h") {
|
|
121259
|
-
dragBar.style.left = `${relative}px`;
|
|
121260
|
-
} else {
|
|
121261
|
-
dragBar.style.top = `${relative}px`;
|
|
121262
|
-
}
|
|
121263
|
-
};
|
|
121264
|
-
|
|
121265
|
-
|
|
121266
|
-
|
|
121267
|
-
const onUp = (e) => {
|
|
121268
|
-
|
|
121269
|
-
window.removeEventListener("mousemove", onMove);
|
|
121270
|
-
window.removeEventListener("mouseup", onUp);
|
|
121271
|
-
dragBar.remove();
|
|
121272
|
-
|
|
121273
|
-
|
|
121274
|
-
// 기준: prev + next 너비 합계
|
|
121275
|
-
const totalSize = this.#mode === "h"
|
|
121276
|
-
? prev.offsetWidth + next.offsetWidth
|
|
121277
|
-
: prev.offsetHeight + next.offsetHeight;
|
|
121278
|
-
|
|
121279
|
-
// prev 기준 상대 거리 (드래그 거리)
|
|
121280
|
-
|
|
121281
|
-
let delta = this.#mode === "h"
|
|
121282
|
-
? e.clientX - prev.getBoundingClientRect().left - clickOffset
|
|
121283
|
-
: e.clientY - prev.getBoundingClientRect().top - clickOffset;
|
|
121284
|
-
//let delta = dragStartPos - prev.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
121285
|
-
|
|
121286
|
-
const min = 1;
|
|
121287
|
-
const max = totalSize - 1;
|
|
121288
|
-
delta = Math.max(min, Math.min(delta, max));
|
|
121289
|
-
|
|
121290
|
-
|
|
121291
|
-
const prev1 = prev.style.flex;
|
|
121292
|
-
const prev2 = next.style.flex;
|
|
121293
|
-
prev.style.flex = "none";
|
|
121294
|
-
next.style.flex = "none";
|
|
121295
|
-
|
|
121296
|
-
// 📌 사이즈 적용
|
|
121297
|
-
if (this.#mode === "h") {
|
|
121298
|
-
prev.style.width = `${delta}px`;
|
|
121299
|
-
next.style.width = `${totalSize - delta}px`;
|
|
121300
|
-
} else {
|
|
121301
|
-
prev.style.height = `${delta}px`;
|
|
121302
|
-
next.style.height = `${totalSize - delta}px`;
|
|
121303
|
-
}
|
|
121304
|
-
|
|
121305
|
-
prev.style.flex = prev1;
|
|
121306
|
-
next.style.flex = prev2;
|
|
121307
|
-
};
|
|
121308
|
-
|
|
121309
|
-
window.addEventListener("mousemove", onMove);
|
|
121310
|
-
window.addEventListener("mouseup", onUp);
|
|
121311
|
-
};
|
|
121312
|
-
|
|
121313
|
-
#startDrag = (e) => {
|
|
121314
121167
|
e.preventDefault();
|
|
121315
121168
|
e.stopPropagation();
|
|
121316
121169
|
|
|
@@ -121449,6 +121302,127 @@ class nxSplitter extends HTMLElement {
|
|
|
121449
121302
|
window.addEventListener("mouseup", onUp);
|
|
121450
121303
|
};
|
|
121451
121304
|
|
|
121305
|
+
#startDrag = (e) => {
|
|
121306
|
+
|
|
121307
|
+
e.preventDefault(); // 기본 drag/select 동작 제거
|
|
121308
|
+
e.stopPropagation();
|
|
121309
|
+
|
|
121310
|
+
const splitterRect = this.getBoundingClientRect();
|
|
121311
|
+
const clickOffset = this.#mode === "h"
|
|
121312
|
+
? e.clientX - splitterRect.left
|
|
121313
|
+
: e.clientY - splitterRect.top;
|
|
121314
|
+
|
|
121315
|
+
//const mode = this.#mode;
|
|
121316
|
+
const dragBar = document.createElement("div");
|
|
121317
|
+
dragBar.className = `nx-splitter-drag-bar-${this.#mode}`;
|
|
121318
|
+
|
|
121319
|
+
// 스타일 지정
|
|
121320
|
+
Object.assign(dragBar.style, {
|
|
121321
|
+
position: "absolute",
|
|
121322
|
+
zIndex: "999",
|
|
121323
|
+
background: "#666",
|
|
121324
|
+
opacity: "0.6",
|
|
121325
|
+
pointerEvents: "none"
|
|
121326
|
+
});
|
|
121327
|
+
|
|
121328
|
+
const root = this.getRootNode({ composed: true });
|
|
121329
|
+
const parent = root instanceof ShadowRoot ? root.host : this.parentElement || document.body;
|
|
121330
|
+
|
|
121331
|
+
//const parent = this.getRootNode().host || this.parentElement;
|
|
121332
|
+
const prev = this.previousElementSibling;
|
|
121333
|
+
const next = this.nextElementSibling;
|
|
121334
|
+
|
|
121335
|
+
if (!parent || !prev || !next) return;
|
|
121336
|
+
|
|
121337
|
+
const parentRect = parent.getBoundingClientRect();
|
|
121338
|
+
const prevRect = prev.getBoundingClientRect();
|
|
121339
|
+
const nextRect = next.getBoundingClientRect();
|
|
121340
|
+
|
|
121341
|
+
const left = e.clientX - (parent.offsetLeft + parent.clientLeft);
|
|
121342
|
+
const top = e.clientY - (parent.offsetTop + parentRect.top);
|
|
121343
|
+
|
|
121344
|
+
console.log(left, top);
|
|
121345
|
+
|
|
121346
|
+
// 방향별 위치 설정
|
|
121347
|
+
if (this.#mode === "h") {
|
|
121348
|
+
dragBar.style.top = "0";
|
|
121349
|
+
dragBar.style.left = `${left}px`;
|
|
121350
|
+
dragBar.style.width = "1px";
|
|
121351
|
+
dragBar.style.height = "100%";
|
|
121352
|
+
} else {
|
|
121353
|
+
dragBar.style.left = "0";
|
|
121354
|
+
dragBar.style.top = `${top}px`;
|
|
121355
|
+
dragBar.style.height = "1px";
|
|
121356
|
+
dragBar.style.width = "100%";
|
|
121357
|
+
}
|
|
121358
|
+
|
|
121359
|
+
// 👇 부모 노드 기준으로 삽입
|
|
121360
|
+
(parent.shadowRoot || parent).appendChild(dragBar);
|
|
121361
|
+
|
|
121362
|
+
const min = this.#mode === "h" ? prevRect.left : prevRect.top;
|
|
121363
|
+
const max = this.#mode === "h" ? nextRect.right : nextRect.bottom;
|
|
121364
|
+
|
|
121365
|
+
const onMove = e => {
|
|
121366
|
+
const clientPos = this.#mode === "h" ? e.clientX : e.clientY;
|
|
121367
|
+
const position = Math.max(min, Math.min(clientPos, max));
|
|
121368
|
+
|
|
121369
|
+
const relative = position - parent.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
121370
|
+
|
|
121371
|
+
if (this.#mode === "h") {
|
|
121372
|
+
dragBar.style.left = `${relative}px`;
|
|
121373
|
+
} else {
|
|
121374
|
+
dragBar.style.top = `${relative}px`;
|
|
121375
|
+
}
|
|
121376
|
+
};
|
|
121377
|
+
|
|
121378
|
+
|
|
121379
|
+
|
|
121380
|
+
const onUp = (e) => {
|
|
121381
|
+
|
|
121382
|
+
window.removeEventListener("mousemove", onMove);
|
|
121383
|
+
window.removeEventListener("mouseup", onUp);
|
|
121384
|
+
dragBar.remove();
|
|
121385
|
+
|
|
121386
|
+
|
|
121387
|
+
// 기준: prev + next 너비 합계
|
|
121388
|
+
const totalSize = this.#mode === "h"
|
|
121389
|
+
? prev.offsetWidth + next.offsetWidth
|
|
121390
|
+
: prev.offsetHeight + next.offsetHeight;
|
|
121391
|
+
|
|
121392
|
+
// prev 기준 상대 거리 (드래그 거리)
|
|
121393
|
+
|
|
121394
|
+
let delta = this.#mode === "h"
|
|
121395
|
+
? e.clientX - prev.getBoundingClientRect().left - clickOffset
|
|
121396
|
+
: e.clientY - prev.getBoundingClientRect().top - clickOffset;
|
|
121397
|
+
//let delta = dragStartPos - prev.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
121398
|
+
|
|
121399
|
+
const min = 1;
|
|
121400
|
+
const max = totalSize - 1;
|
|
121401
|
+
delta = Math.max(min, Math.min(delta, max));
|
|
121402
|
+
|
|
121403
|
+
|
|
121404
|
+
const prev1 = prev.style.flex;
|
|
121405
|
+
const prev2 = next.style.flex;
|
|
121406
|
+
prev.style.flex = "none";
|
|
121407
|
+
next.style.flex = "none";
|
|
121408
|
+
|
|
121409
|
+
// 📌 사이즈 적용
|
|
121410
|
+
if (this.#mode === "h") {
|
|
121411
|
+
prev.style.width = `${delta}px`;
|
|
121412
|
+
next.style.width = `${totalSize - delta}px`;
|
|
121413
|
+
} else {
|
|
121414
|
+
prev.style.height = `${delta}px`;
|
|
121415
|
+
next.style.height = `${totalSize - delta}px`;
|
|
121416
|
+
}
|
|
121417
|
+
|
|
121418
|
+
prev.style.flex = prev1;
|
|
121419
|
+
next.style.flex = prev2;
|
|
121420
|
+
};
|
|
121421
|
+
|
|
121422
|
+
window.addEventListener("mousemove", onMove);
|
|
121423
|
+
window.addEventListener("mouseup", onUp);
|
|
121424
|
+
};
|
|
121425
|
+
|
|
121452
121426
|
|
|
121453
121427
|
#init = () => {
|
|
121454
121428
|
this.#detectMode(this);
|
package/dist/nx/nxSplitter.js
CHANGED
|
@@ -23,153 +23,6 @@ class nxSplitter extends HTMLElement {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
#startDrag_BAK = (e) => {
|
|
26
|
-
|
|
27
|
-
e.preventDefault(); // 기본 drag/select 동작 제거
|
|
28
|
-
e.stopPropagation();
|
|
29
|
-
|
|
30
|
-
const splitterRect = this.getBoundingClientRect();
|
|
31
|
-
const clickOffset = this.#mode === "h"
|
|
32
|
-
? e.clientX - splitterRect.left
|
|
33
|
-
: e.clientY - splitterRect.top;
|
|
34
|
-
|
|
35
|
-
//const mode = this.#mode;
|
|
36
|
-
const dragBar = document.createElement("div");
|
|
37
|
-
dragBar.className = `nx-splitter-drag-bar-${this.#mode}`;
|
|
38
|
-
|
|
39
|
-
// 스타일 지정
|
|
40
|
-
Object.assign(dragBar.style, {
|
|
41
|
-
position: "absolute",
|
|
42
|
-
zIndex: "999",
|
|
43
|
-
background: "#666",
|
|
44
|
-
opacity: "0.6",
|
|
45
|
-
pointerEvents: "none"
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const root = this.getRootNode({ composed: true });
|
|
49
|
-
const parent = root instanceof ShadowRoot ? root.host : this.parentElement || document.body;
|
|
50
|
-
|
|
51
|
-
//const parent = this.getRootNode().host || this.parentElement;
|
|
52
|
-
const prev = this.previousElementSibling;
|
|
53
|
-
const next = this.nextElementSibling;
|
|
54
|
-
|
|
55
|
-
if (!parent || !prev || !next) return;
|
|
56
|
-
|
|
57
|
-
const parentRect = parent.getBoundingClientRect();
|
|
58
|
-
const prevRect = prev.getBoundingClientRect();
|
|
59
|
-
const nextRect = next.getBoundingClientRect();
|
|
60
|
-
|
|
61
|
-
const computedStyle = getComputedStyle(parent);
|
|
62
|
-
const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0;
|
|
63
|
-
const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
let el = parent;
|
|
67
|
-
let totalPadding = 0;
|
|
68
|
-
|
|
69
|
-
while (el) {
|
|
70
|
-
console.log(el, el.parentElement, el.host)
|
|
71
|
-
if (el instanceof Element) {
|
|
72
|
-
const style = getComputedStyle(el);
|
|
73
|
-
totalPadding += parseFloat(style.paddingLeft) || 0;
|
|
74
|
-
el = el.parentElement;
|
|
75
|
-
} else if (el instanceof ShadowRoot) {
|
|
76
|
-
el = el.host;
|
|
77
|
-
} else {
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
console.log(totalPadding, e.clientX, parentRect.left);
|
|
86
|
-
|
|
87
|
-
const left = e.clientX - parentRect.left + totalPadding;
|
|
88
|
-
const top = e.clientY - parentRect.top + paddingTop;
|
|
89
|
-
|
|
90
|
-
console.log("1------", left, top);
|
|
91
|
-
|
|
92
|
-
// 방향별 위치 설정
|
|
93
|
-
if (this.#mode === "h") {
|
|
94
|
-
dragBar.style.top = "0";
|
|
95
|
-
dragBar.style.left = `${left}px`;
|
|
96
|
-
dragBar.style.width = "1px";
|
|
97
|
-
dragBar.style.height = "100%";
|
|
98
|
-
} else {
|
|
99
|
-
dragBar.style.left = "0";
|
|
100
|
-
dragBar.style.top = `${top}px`;
|
|
101
|
-
dragBar.style.height = "1px";
|
|
102
|
-
dragBar.style.width = "100%";
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// 👇 부모 노드 기준으로 삽입
|
|
106
|
-
(parent.shadowRoot || parent).appendChild(dragBar);
|
|
107
|
-
|
|
108
|
-
const min = this.#mode === "h" ? prevRect.left : prevRect.top;
|
|
109
|
-
const max = this.#mode === "h" ? nextRect.right : nextRect.bottom;
|
|
110
|
-
|
|
111
|
-
const onMove = e => {
|
|
112
|
-
const clientPos = this.#mode === "h" ? e.clientX : e.clientY;
|
|
113
|
-
const position = Math.max(min, Math.min(clientPos, max));
|
|
114
|
-
|
|
115
|
-
const relative = position - parent.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
116
|
-
|
|
117
|
-
if (this.#mode === "h") {
|
|
118
|
-
dragBar.style.left = `${relative}px`;
|
|
119
|
-
} else {
|
|
120
|
-
dragBar.style.top = `${relative}px`;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const onUp = (e) => {
|
|
127
|
-
|
|
128
|
-
window.removeEventListener("mousemove", onMove);
|
|
129
|
-
window.removeEventListener("mouseup", onUp);
|
|
130
|
-
dragBar.remove();
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// 기준: prev + next 너비 합계
|
|
134
|
-
const totalSize = this.#mode === "h"
|
|
135
|
-
? prev.offsetWidth + next.offsetWidth
|
|
136
|
-
: prev.offsetHeight + next.offsetHeight;
|
|
137
|
-
|
|
138
|
-
// prev 기준 상대 거리 (드래그 거리)
|
|
139
|
-
|
|
140
|
-
let delta = this.#mode === "h"
|
|
141
|
-
? e.clientX - prev.getBoundingClientRect().left - clickOffset
|
|
142
|
-
: e.clientY - prev.getBoundingClientRect().top - clickOffset;
|
|
143
|
-
//let delta = dragStartPos - prev.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
144
|
-
|
|
145
|
-
const min = 1;
|
|
146
|
-
const max = totalSize - 1;
|
|
147
|
-
delta = Math.max(min, Math.min(delta, max));
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const prev1 = prev.style.flex;
|
|
151
|
-
const prev2 = next.style.flex;
|
|
152
|
-
prev.style.flex = "none";
|
|
153
|
-
next.style.flex = "none";
|
|
154
|
-
|
|
155
|
-
// 📌 사이즈 적용
|
|
156
|
-
if (this.#mode === "h") {
|
|
157
|
-
prev.style.width = `${delta}px`;
|
|
158
|
-
next.style.width = `${totalSize - delta}px`;
|
|
159
|
-
} else {
|
|
160
|
-
prev.style.height = `${delta}px`;
|
|
161
|
-
next.style.height = `${totalSize - delta}px`;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
prev.style.flex = prev1;
|
|
165
|
-
next.style.flex = prev2;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
window.addEventListener("mousemove", onMove);
|
|
169
|
-
window.addEventListener("mouseup", onUp);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
#startDrag = (e) => {
|
|
173
26
|
e.preventDefault();
|
|
174
27
|
e.stopPropagation();
|
|
175
28
|
|
|
@@ -308,6 +161,127 @@ class nxSplitter extends HTMLElement {
|
|
|
308
161
|
window.addEventListener("mouseup", onUp);
|
|
309
162
|
};
|
|
310
163
|
|
|
164
|
+
#startDrag = (e) => {
|
|
165
|
+
|
|
166
|
+
e.preventDefault(); // 기본 drag/select 동작 제거
|
|
167
|
+
e.stopPropagation();
|
|
168
|
+
|
|
169
|
+
const splitterRect = this.getBoundingClientRect();
|
|
170
|
+
const clickOffset = this.#mode === "h"
|
|
171
|
+
? e.clientX - splitterRect.left
|
|
172
|
+
: e.clientY - splitterRect.top;
|
|
173
|
+
|
|
174
|
+
//const mode = this.#mode;
|
|
175
|
+
const dragBar = document.createElement("div");
|
|
176
|
+
dragBar.className = `nx-splitter-drag-bar-${this.#mode}`;
|
|
177
|
+
|
|
178
|
+
// 스타일 지정
|
|
179
|
+
Object.assign(dragBar.style, {
|
|
180
|
+
position: "absolute",
|
|
181
|
+
zIndex: "999",
|
|
182
|
+
background: "#666",
|
|
183
|
+
opacity: "0.6",
|
|
184
|
+
pointerEvents: "none"
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const root = this.getRootNode({ composed: true });
|
|
188
|
+
const parent = root instanceof ShadowRoot ? root.host : this.parentElement || document.body;
|
|
189
|
+
|
|
190
|
+
//const parent = this.getRootNode().host || this.parentElement;
|
|
191
|
+
const prev = this.previousElementSibling;
|
|
192
|
+
const next = this.nextElementSibling;
|
|
193
|
+
|
|
194
|
+
if (!parent || !prev || !next) return;
|
|
195
|
+
|
|
196
|
+
const parentRect = parent.getBoundingClientRect();
|
|
197
|
+
const prevRect = prev.getBoundingClientRect();
|
|
198
|
+
const nextRect = next.getBoundingClientRect();
|
|
199
|
+
|
|
200
|
+
const left = e.clientX - (parent.offsetLeft + parent.clientLeft);
|
|
201
|
+
const top = e.clientY - (parent.offsetTop + parentRect.top);
|
|
202
|
+
|
|
203
|
+
console.log(left, top);
|
|
204
|
+
|
|
205
|
+
// 방향별 위치 설정
|
|
206
|
+
if (this.#mode === "h") {
|
|
207
|
+
dragBar.style.top = "0";
|
|
208
|
+
dragBar.style.left = `${left}px`;
|
|
209
|
+
dragBar.style.width = "1px";
|
|
210
|
+
dragBar.style.height = "100%";
|
|
211
|
+
} else {
|
|
212
|
+
dragBar.style.left = "0";
|
|
213
|
+
dragBar.style.top = `${top}px`;
|
|
214
|
+
dragBar.style.height = "1px";
|
|
215
|
+
dragBar.style.width = "100%";
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// 👇 부모 노드 기준으로 삽입
|
|
219
|
+
(parent.shadowRoot || parent).appendChild(dragBar);
|
|
220
|
+
|
|
221
|
+
const min = this.#mode === "h" ? prevRect.left : prevRect.top;
|
|
222
|
+
const max = this.#mode === "h" ? nextRect.right : nextRect.bottom;
|
|
223
|
+
|
|
224
|
+
const onMove = e => {
|
|
225
|
+
const clientPos = this.#mode === "h" ? e.clientX : e.clientY;
|
|
226
|
+
const position = Math.max(min, Math.min(clientPos, max));
|
|
227
|
+
|
|
228
|
+
const relative = position - parent.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
229
|
+
|
|
230
|
+
if (this.#mode === "h") {
|
|
231
|
+
dragBar.style.left = `${relative}px`;
|
|
232
|
+
} else {
|
|
233
|
+
dragBar.style.top = `${relative}px`;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
const onUp = (e) => {
|
|
240
|
+
|
|
241
|
+
window.removeEventListener("mousemove", onMove);
|
|
242
|
+
window.removeEventListener("mouseup", onUp);
|
|
243
|
+
dragBar.remove();
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
// 기준: prev + next 너비 합계
|
|
247
|
+
const totalSize = this.#mode === "h"
|
|
248
|
+
? prev.offsetWidth + next.offsetWidth
|
|
249
|
+
: prev.offsetHeight + next.offsetHeight;
|
|
250
|
+
|
|
251
|
+
// prev 기준 상대 거리 (드래그 거리)
|
|
252
|
+
|
|
253
|
+
let delta = this.#mode === "h"
|
|
254
|
+
? e.clientX - prev.getBoundingClientRect().left - clickOffset
|
|
255
|
+
: e.clientY - prev.getBoundingClientRect().top - clickOffset;
|
|
256
|
+
//let delta = dragStartPos - prev.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
257
|
+
|
|
258
|
+
const min = 1;
|
|
259
|
+
const max = totalSize - 1;
|
|
260
|
+
delta = Math.max(min, Math.min(delta, max));
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
const prev1 = prev.style.flex;
|
|
264
|
+
const prev2 = next.style.flex;
|
|
265
|
+
prev.style.flex = "none";
|
|
266
|
+
next.style.flex = "none";
|
|
267
|
+
|
|
268
|
+
// 📌 사이즈 적용
|
|
269
|
+
if (this.#mode === "h") {
|
|
270
|
+
prev.style.width = `${delta}px`;
|
|
271
|
+
next.style.width = `${totalSize - delta}px`;
|
|
272
|
+
} else {
|
|
273
|
+
prev.style.height = `${delta}px`;
|
|
274
|
+
next.style.height = `${totalSize - delta}px`;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
prev.style.flex = prev1;
|
|
278
|
+
next.style.flex = prev2;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
window.addEventListener("mousemove", onMove);
|
|
282
|
+
window.addEventListener("mouseup", onUp);
|
|
283
|
+
};
|
|
284
|
+
|
|
311
285
|
|
|
312
286
|
#init = () => {
|
|
313
287
|
this.#detectMode(this);
|
package/package.json
CHANGED
package/src/nx/nxSplitter.js
CHANGED
|
@@ -23,153 +23,6 @@ class nxSplitter extends HTMLElement {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
#startDrag_BAK = (e) => {
|
|
26
|
-
|
|
27
|
-
e.preventDefault(); // 기본 drag/select 동작 제거
|
|
28
|
-
e.stopPropagation();
|
|
29
|
-
|
|
30
|
-
const splitterRect = this.getBoundingClientRect();
|
|
31
|
-
const clickOffset = this.#mode === "h"
|
|
32
|
-
? e.clientX - splitterRect.left
|
|
33
|
-
: e.clientY - splitterRect.top;
|
|
34
|
-
|
|
35
|
-
//const mode = this.#mode;
|
|
36
|
-
const dragBar = document.createElement("div");
|
|
37
|
-
dragBar.className = `nx-splitter-drag-bar-${this.#mode}`;
|
|
38
|
-
|
|
39
|
-
// 스타일 지정
|
|
40
|
-
Object.assign(dragBar.style, {
|
|
41
|
-
position: "absolute",
|
|
42
|
-
zIndex: "999",
|
|
43
|
-
background: "#666",
|
|
44
|
-
opacity: "0.6",
|
|
45
|
-
pointerEvents: "none"
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const root = this.getRootNode({ composed: true });
|
|
49
|
-
const parent = root instanceof ShadowRoot ? root.host : this.parentElement || document.body;
|
|
50
|
-
|
|
51
|
-
//const parent = this.getRootNode().host || this.parentElement;
|
|
52
|
-
const prev = this.previousElementSibling;
|
|
53
|
-
const next = this.nextElementSibling;
|
|
54
|
-
|
|
55
|
-
if (!parent || !prev || !next) return;
|
|
56
|
-
|
|
57
|
-
const parentRect = parent.getBoundingClientRect();
|
|
58
|
-
const prevRect = prev.getBoundingClientRect();
|
|
59
|
-
const nextRect = next.getBoundingClientRect();
|
|
60
|
-
|
|
61
|
-
const computedStyle = getComputedStyle(parent);
|
|
62
|
-
const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0;
|
|
63
|
-
const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
let el = parent;
|
|
67
|
-
let totalPadding = 0;
|
|
68
|
-
|
|
69
|
-
while (el) {
|
|
70
|
-
console.log(el, el.parentElement, el.host)
|
|
71
|
-
if (el instanceof Element) {
|
|
72
|
-
const style = getComputedStyle(el);
|
|
73
|
-
totalPadding += parseFloat(style.paddingLeft) || 0;
|
|
74
|
-
el = el.parentElement;
|
|
75
|
-
} else if (el instanceof ShadowRoot) {
|
|
76
|
-
el = el.host;
|
|
77
|
-
} else {
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
console.log(totalPadding, e.clientX, parentRect.left);
|
|
86
|
-
|
|
87
|
-
const left = e.clientX - parentRect.left + totalPadding;
|
|
88
|
-
const top = e.clientY - parentRect.top + paddingTop;
|
|
89
|
-
|
|
90
|
-
console.log("1------", left, top);
|
|
91
|
-
|
|
92
|
-
// 방향별 위치 설정
|
|
93
|
-
if (this.#mode === "h") {
|
|
94
|
-
dragBar.style.top = "0";
|
|
95
|
-
dragBar.style.left = `${left}px`;
|
|
96
|
-
dragBar.style.width = "1px";
|
|
97
|
-
dragBar.style.height = "100%";
|
|
98
|
-
} else {
|
|
99
|
-
dragBar.style.left = "0";
|
|
100
|
-
dragBar.style.top = `${top}px`;
|
|
101
|
-
dragBar.style.height = "1px";
|
|
102
|
-
dragBar.style.width = "100%";
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// 👇 부모 노드 기준으로 삽입
|
|
106
|
-
(parent.shadowRoot || parent).appendChild(dragBar);
|
|
107
|
-
|
|
108
|
-
const min = this.#mode === "h" ? prevRect.left : prevRect.top;
|
|
109
|
-
const max = this.#mode === "h" ? nextRect.right : nextRect.bottom;
|
|
110
|
-
|
|
111
|
-
const onMove = e => {
|
|
112
|
-
const clientPos = this.#mode === "h" ? e.clientX : e.clientY;
|
|
113
|
-
const position = Math.max(min, Math.min(clientPos, max));
|
|
114
|
-
|
|
115
|
-
const relative = position - parent.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
116
|
-
|
|
117
|
-
if (this.#mode === "h") {
|
|
118
|
-
dragBar.style.left = `${relative}px`;
|
|
119
|
-
} else {
|
|
120
|
-
dragBar.style.top = `${relative}px`;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const onUp = (e) => {
|
|
127
|
-
|
|
128
|
-
window.removeEventListener("mousemove", onMove);
|
|
129
|
-
window.removeEventListener("mouseup", onUp);
|
|
130
|
-
dragBar.remove();
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// 기준: prev + next 너비 합계
|
|
134
|
-
const totalSize = this.#mode === "h"
|
|
135
|
-
? prev.offsetWidth + next.offsetWidth
|
|
136
|
-
: prev.offsetHeight + next.offsetHeight;
|
|
137
|
-
|
|
138
|
-
// prev 기준 상대 거리 (드래그 거리)
|
|
139
|
-
|
|
140
|
-
let delta = this.#mode === "h"
|
|
141
|
-
? e.clientX - prev.getBoundingClientRect().left - clickOffset
|
|
142
|
-
: e.clientY - prev.getBoundingClientRect().top - clickOffset;
|
|
143
|
-
//let delta = dragStartPos - prev.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
144
|
-
|
|
145
|
-
const min = 1;
|
|
146
|
-
const max = totalSize - 1;
|
|
147
|
-
delta = Math.max(min, Math.min(delta, max));
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const prev1 = prev.style.flex;
|
|
151
|
-
const prev2 = next.style.flex;
|
|
152
|
-
prev.style.flex = "none";
|
|
153
|
-
next.style.flex = "none";
|
|
154
|
-
|
|
155
|
-
// 📌 사이즈 적용
|
|
156
|
-
if (this.#mode === "h") {
|
|
157
|
-
prev.style.width = `${delta}px`;
|
|
158
|
-
next.style.width = `${totalSize - delta}px`;
|
|
159
|
-
} else {
|
|
160
|
-
prev.style.height = `${delta}px`;
|
|
161
|
-
next.style.height = `${totalSize - delta}px`;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
prev.style.flex = prev1;
|
|
165
|
-
next.style.flex = prev2;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
window.addEventListener("mousemove", onMove);
|
|
169
|
-
window.addEventListener("mouseup", onUp);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
#startDrag = (e) => {
|
|
173
26
|
e.preventDefault();
|
|
174
27
|
e.stopPropagation();
|
|
175
28
|
|
|
@@ -308,6 +161,127 @@ class nxSplitter extends HTMLElement {
|
|
|
308
161
|
window.addEventListener("mouseup", onUp);
|
|
309
162
|
};
|
|
310
163
|
|
|
164
|
+
#startDrag = (e) => {
|
|
165
|
+
|
|
166
|
+
e.preventDefault(); // 기본 drag/select 동작 제거
|
|
167
|
+
e.stopPropagation();
|
|
168
|
+
|
|
169
|
+
const splitterRect = this.getBoundingClientRect();
|
|
170
|
+
const clickOffset = this.#mode === "h"
|
|
171
|
+
? e.clientX - splitterRect.left
|
|
172
|
+
: e.clientY - splitterRect.top;
|
|
173
|
+
|
|
174
|
+
//const mode = this.#mode;
|
|
175
|
+
const dragBar = document.createElement("div");
|
|
176
|
+
dragBar.className = `nx-splitter-drag-bar-${this.#mode}`;
|
|
177
|
+
|
|
178
|
+
// 스타일 지정
|
|
179
|
+
Object.assign(dragBar.style, {
|
|
180
|
+
position: "absolute",
|
|
181
|
+
zIndex: "999",
|
|
182
|
+
background: "#666",
|
|
183
|
+
opacity: "0.6",
|
|
184
|
+
pointerEvents: "none"
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const root = this.getRootNode({ composed: true });
|
|
188
|
+
const parent = root instanceof ShadowRoot ? root.host : this.parentElement || document.body;
|
|
189
|
+
|
|
190
|
+
//const parent = this.getRootNode().host || this.parentElement;
|
|
191
|
+
const prev = this.previousElementSibling;
|
|
192
|
+
const next = this.nextElementSibling;
|
|
193
|
+
|
|
194
|
+
if (!parent || !prev || !next) return;
|
|
195
|
+
|
|
196
|
+
const parentRect = parent.getBoundingClientRect();
|
|
197
|
+
const prevRect = prev.getBoundingClientRect();
|
|
198
|
+
const nextRect = next.getBoundingClientRect();
|
|
199
|
+
|
|
200
|
+
const left = e.clientX - (parent.offsetLeft + parent.clientLeft);
|
|
201
|
+
const top = e.clientY - (parent.offsetTop + parentRect.top);
|
|
202
|
+
|
|
203
|
+
console.log(left, top);
|
|
204
|
+
|
|
205
|
+
// 방향별 위치 설정
|
|
206
|
+
if (this.#mode === "h") {
|
|
207
|
+
dragBar.style.top = "0";
|
|
208
|
+
dragBar.style.left = `${left}px`;
|
|
209
|
+
dragBar.style.width = "1px";
|
|
210
|
+
dragBar.style.height = "100%";
|
|
211
|
+
} else {
|
|
212
|
+
dragBar.style.left = "0";
|
|
213
|
+
dragBar.style.top = `${top}px`;
|
|
214
|
+
dragBar.style.height = "1px";
|
|
215
|
+
dragBar.style.width = "100%";
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// 👇 부모 노드 기준으로 삽입
|
|
219
|
+
(parent.shadowRoot || parent).appendChild(dragBar);
|
|
220
|
+
|
|
221
|
+
const min = this.#mode === "h" ? prevRect.left : prevRect.top;
|
|
222
|
+
const max = this.#mode === "h" ? nextRect.right : nextRect.bottom;
|
|
223
|
+
|
|
224
|
+
const onMove = e => {
|
|
225
|
+
const clientPos = this.#mode === "h" ? e.clientX : e.clientY;
|
|
226
|
+
const position = Math.max(min, Math.min(clientPos, max));
|
|
227
|
+
|
|
228
|
+
const relative = position - parent.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
229
|
+
|
|
230
|
+
if (this.#mode === "h") {
|
|
231
|
+
dragBar.style.left = `${relative}px`;
|
|
232
|
+
} else {
|
|
233
|
+
dragBar.style.top = `${relative}px`;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
const onUp = (e) => {
|
|
240
|
+
|
|
241
|
+
window.removeEventListener("mousemove", onMove);
|
|
242
|
+
window.removeEventListener("mouseup", onUp);
|
|
243
|
+
dragBar.remove();
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
// 기준: prev + next 너비 합계
|
|
247
|
+
const totalSize = this.#mode === "h"
|
|
248
|
+
? prev.offsetWidth + next.offsetWidth
|
|
249
|
+
: prev.offsetHeight + next.offsetHeight;
|
|
250
|
+
|
|
251
|
+
// prev 기준 상대 거리 (드래그 거리)
|
|
252
|
+
|
|
253
|
+
let delta = this.#mode === "h"
|
|
254
|
+
? e.clientX - prev.getBoundingClientRect().left - clickOffset
|
|
255
|
+
: e.clientY - prev.getBoundingClientRect().top - clickOffset;
|
|
256
|
+
//let delta = dragStartPos - prev.getBoundingClientRect()[this.#mode === "h" ? "left" : "top"];
|
|
257
|
+
|
|
258
|
+
const min = 1;
|
|
259
|
+
const max = totalSize - 1;
|
|
260
|
+
delta = Math.max(min, Math.min(delta, max));
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
const prev1 = prev.style.flex;
|
|
264
|
+
const prev2 = next.style.flex;
|
|
265
|
+
prev.style.flex = "none";
|
|
266
|
+
next.style.flex = "none";
|
|
267
|
+
|
|
268
|
+
// 📌 사이즈 적용
|
|
269
|
+
if (this.#mode === "h") {
|
|
270
|
+
prev.style.width = `${delta}px`;
|
|
271
|
+
next.style.width = `${totalSize - delta}px`;
|
|
272
|
+
} else {
|
|
273
|
+
prev.style.height = `${delta}px`;
|
|
274
|
+
next.style.height = `${totalSize - delta}px`;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
prev.style.flex = prev1;
|
|
278
|
+
next.style.flex = prev2;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
window.addEventListener("mousemove", onMove);
|
|
282
|
+
window.addEventListener("mouseup", onUp);
|
|
283
|
+
};
|
|
284
|
+
|
|
311
285
|
|
|
312
286
|
#init = () => {
|
|
313
287
|
this.#detectMode(this);
|