ninegrid2 6.665.0 → 6.666.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.
@@ -121057,7 +121057,7 @@ class nxSplitter extends HTMLElement {
121057
121057
  this.#init();
121058
121058
  }
121059
121059
 
121060
- #detectMode(el) {
121060
+ #detectMode = (el) => {
121061
121061
  const prev = el.previousElementSibling;
121062
121062
  const next = el.nextElementSibling;
121063
121063
 
@@ -121065,7 +121065,48 @@ class nxSplitter extends HTMLElement {
121065
121065
  const nextRect = next?.getBoundingClientRect();
121066
121066
 
121067
121067
  this.#mode = (!prevRect || !nextRect) || (Math.abs(prevRect.top - nextRect.top) < 5) ? "h" : "v";
121068
- }
121068
+ };
121069
+
121070
+ #startDrag = (e) => {
121071
+ const mode = this.#mode;
121072
+ const dragBar = document.createElement("div");
121073
+ dragBar.className = "nx-drag-bar";
121074
+ dragBar.style.position = "fixed";
121075
+ dragBar.style.zIndex = "9999";
121076
+ dragBar.style.pointerEvents = "none";
121077
+ dragBar.style.background = "#666";
121078
+ dragBar.style.opacity = "0.6";
121079
+
121080
+ // 방향별 초기 위치 설정
121081
+ if (mode === "h") {
121082
+ dragBar.style.top = "0";
121083
+ dragBar.style.width = "1px";
121084
+ dragBar.style.height = "100vh";
121085
+ dragBar.style.left = `${e.clientX}px`;
121086
+ } else {
121087
+ dragBar.style.left = "0";
121088
+ dragBar.style.width = "100vw";
121089
+ dragBar.style.height = "1px";
121090
+ dragBar.style.top = `${e.clientY}px`;
121091
+ }
121092
+
121093
+ document.body.appendChild(dragBar);
121094
+
121095
+ const onMove = e => {
121096
+ if (mode === "h") dragBar.style.left = `${e.clientX}px`;
121097
+ else dragBar.style.top = `${e.clientY}px`;
121098
+ };
121099
+
121100
+ const onUp = () => {
121101
+ window.removeEventListener("mousemove", onMove);
121102
+ window.removeEventListener("mouseup", onUp);
121103
+ dragBar.remove();
121104
+ };
121105
+
121106
+ window.addEventListener("mousemove", onMove);
121107
+ window.addEventListener("mouseup", onUp);
121108
+ };
121109
+
121069
121110
 
121070
121111
  #init = () => {
121071
121112
  this.#detectMode(this);
@@ -121088,6 +121129,11 @@ class nxSplitter extends HTMLElement {
121088
121129
  `;
121089
121130
 
121090
121131
  this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
121132
+
121133
+ // grip 이벤트 바인딩
121134
+ this.shadowRoot.querySelectorAll("grid-h,grid-v").forEach(grip => {
121135
+ grip.addEventListener("mousedown", e => this.#startDrag(e));
121136
+ });
121091
121137
  }
121092
121138
  }
121093
121139
 
@@ -121053,7 +121053,7 @@ class nxSplitter extends HTMLElement {
121053
121053
  this.#init();
121054
121054
  }
121055
121055
 
121056
- #detectMode(el) {
121056
+ #detectMode = (el) => {
121057
121057
  const prev = el.previousElementSibling;
121058
121058
  const next = el.nextElementSibling;
121059
121059
 
@@ -121061,7 +121061,48 @@ class nxSplitter extends HTMLElement {
121061
121061
  const nextRect = next?.getBoundingClientRect();
121062
121062
 
121063
121063
  this.#mode = (!prevRect || !nextRect) || (Math.abs(prevRect.top - nextRect.top) < 5) ? "h" : "v";
121064
- }
121064
+ };
121065
+
121066
+ #startDrag = (e) => {
121067
+ const mode = this.#mode;
121068
+ const dragBar = document.createElement("div");
121069
+ dragBar.className = "nx-drag-bar";
121070
+ dragBar.style.position = "fixed";
121071
+ dragBar.style.zIndex = "9999";
121072
+ dragBar.style.pointerEvents = "none";
121073
+ dragBar.style.background = "#666";
121074
+ dragBar.style.opacity = "0.6";
121075
+
121076
+ // 방향별 초기 위치 설정
121077
+ if (mode === "h") {
121078
+ dragBar.style.top = "0";
121079
+ dragBar.style.width = "1px";
121080
+ dragBar.style.height = "100vh";
121081
+ dragBar.style.left = `${e.clientX}px`;
121082
+ } else {
121083
+ dragBar.style.left = "0";
121084
+ dragBar.style.width = "100vw";
121085
+ dragBar.style.height = "1px";
121086
+ dragBar.style.top = `${e.clientY}px`;
121087
+ }
121088
+
121089
+ document.body.appendChild(dragBar);
121090
+
121091
+ const onMove = e => {
121092
+ if (mode === "h") dragBar.style.left = `${e.clientX}px`;
121093
+ else dragBar.style.top = `${e.clientY}px`;
121094
+ };
121095
+
121096
+ const onUp = () => {
121097
+ window.removeEventListener("mousemove", onMove);
121098
+ window.removeEventListener("mouseup", onUp);
121099
+ dragBar.remove();
121100
+ };
121101
+
121102
+ window.addEventListener("mousemove", onMove);
121103
+ window.addEventListener("mouseup", onUp);
121104
+ };
121105
+
121065
121106
 
121066
121107
  #init = () => {
121067
121108
  this.#detectMode(this);
@@ -121084,6 +121125,11 @@ class nxSplitter extends HTMLElement {
121084
121125
  `;
121085
121126
 
121086
121127
  this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
121128
+
121129
+ // grip 이벤트 바인딩
121130
+ this.shadowRoot.querySelectorAll("grid-h,grid-v").forEach(grip => {
121131
+ grip.addEventListener("mousedown", e => this.#startDrag(e));
121132
+ });
121087
121133
  }
121088
121134
  }
121089
121135
 
@@ -12,7 +12,7 @@ class nxSplitter extends HTMLElement {
12
12
  this.#init();
13
13
  }
14
14
 
15
- #detectMode(el) {
15
+ #detectMode = (el) => {
16
16
  const prev = el.previousElementSibling;
17
17
  const next = el.nextElementSibling;
18
18
 
@@ -20,12 +20,53 @@ class nxSplitter extends HTMLElement {
20
20
  const nextRect = next?.getBoundingClientRect();
21
21
 
22
22
  this.#mode = (!prevRect || !nextRect) || (Math.abs(prevRect.top - nextRect.top) < 5) ? "h" : "v";
23
- }
23
+ };
24
+
25
+ #startDrag = (e) => {
26
+ const mode = this.#mode;
27
+ const dragBar = document.createElement("div");
28
+ dragBar.className = "nx-drag-bar";
29
+ dragBar.style.position = "fixed";
30
+ dragBar.style.zIndex = "9999";
31
+ dragBar.style.pointerEvents = "none";
32
+ dragBar.style.background = "#666";
33
+ dragBar.style.opacity = "0.6";
34
+
35
+ // 방향별 초기 위치 설정
36
+ if (mode === "h") {
37
+ dragBar.style.top = "0";
38
+ dragBar.style.width = "1px";
39
+ dragBar.style.height = "100vh";
40
+ dragBar.style.left = `${e.clientX}px`;
41
+ } else {
42
+ dragBar.style.left = "0";
43
+ dragBar.style.width = "100vw";
44
+ dragBar.style.height = "1px";
45
+ dragBar.style.top = `${e.clientY}px`;
46
+ }
47
+
48
+ document.body.appendChild(dragBar);
49
+
50
+ const onMove = e => {
51
+ if (mode === "h") dragBar.style.left = `${e.clientX}px`;
52
+ else dragBar.style.top = `${e.clientY}px`;
53
+ };
54
+
55
+ const onUp = () => {
56
+ window.removeEventListener("mousemove", onMove);
57
+ window.removeEventListener("mouseup", onUp);
58
+ dragBar.remove();
59
+ };
60
+
61
+ window.addEventListener("mousemove", onMove);
62
+ window.addEventListener("mouseup", onUp);
63
+ };
64
+
24
65
 
25
66
  #init = () => {
26
67
  this.#detectMode(this);
27
68
 
28
- this.classList.add(this.#mode)
69
+ this.classList.add(this.#mode);
29
70
 
30
71
  const contents = this.innerHTML.trim();
31
72
  const gripClass = `grip-${this.#mode}`;
@@ -43,6 +84,11 @@ class nxSplitter extends HTMLElement {
43
84
  `;
44
85
 
45
86
  this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
87
+
88
+ // grip 이벤트 바인딩
89
+ this.shadowRoot.querySelectorAll("grid-h,grid-v").forEach(grip => {
90
+ grip.addEventListener("mousedown", e => this.#startDrag(e));
91
+ });
46
92
  }
47
93
  }
48
94
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.665.0",
4
+ "version": "6.666.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -12,7 +12,7 @@ class nxSplitter extends HTMLElement {
12
12
  this.#init();
13
13
  }
14
14
 
15
- #detectMode(el) {
15
+ #detectMode = (el) => {
16
16
  const prev = el.previousElementSibling;
17
17
  const next = el.nextElementSibling;
18
18
 
@@ -20,12 +20,53 @@ class nxSplitter extends HTMLElement {
20
20
  const nextRect = next?.getBoundingClientRect();
21
21
 
22
22
  this.#mode = (!prevRect || !nextRect) || (Math.abs(prevRect.top - nextRect.top) < 5) ? "h" : "v";
23
- }
23
+ };
24
+
25
+ #startDrag = (e) => {
26
+ const mode = this.#mode;
27
+ const dragBar = document.createElement("div");
28
+ dragBar.className = "nx-drag-bar";
29
+ dragBar.style.position = "fixed";
30
+ dragBar.style.zIndex = "9999";
31
+ dragBar.style.pointerEvents = "none";
32
+ dragBar.style.background = "#666";
33
+ dragBar.style.opacity = "0.6";
34
+
35
+ // 방향별 초기 위치 설정
36
+ if (mode === "h") {
37
+ dragBar.style.top = "0";
38
+ dragBar.style.width = "1px";
39
+ dragBar.style.height = "100vh";
40
+ dragBar.style.left = `${e.clientX}px`;
41
+ } else {
42
+ dragBar.style.left = "0";
43
+ dragBar.style.width = "100vw";
44
+ dragBar.style.height = "1px";
45
+ dragBar.style.top = `${e.clientY}px`;
46
+ }
47
+
48
+ document.body.appendChild(dragBar);
49
+
50
+ const onMove = e => {
51
+ if (mode === "h") dragBar.style.left = `${e.clientX}px`;
52
+ else dragBar.style.top = `${e.clientY}px`;
53
+ };
54
+
55
+ const onUp = () => {
56
+ window.removeEventListener("mousemove", onMove);
57
+ window.removeEventListener("mouseup", onUp);
58
+ dragBar.remove();
59
+ };
60
+
61
+ window.addEventListener("mousemove", onMove);
62
+ window.addEventListener("mouseup", onUp);
63
+ };
64
+
24
65
 
25
66
  #init = () => {
26
67
  this.#detectMode(this);
27
68
 
28
- this.classList.add(this.#mode)
69
+ this.classList.add(this.#mode);
29
70
 
30
71
  const contents = this.innerHTML.trim();
31
72
  const gripClass = `grip-${this.#mode}`;
@@ -43,6 +84,11 @@ class nxSplitter extends HTMLElement {
43
84
  `;
44
85
 
45
86
  this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
87
+
88
+ // grip 이벤트 바인딩
89
+ this.shadowRoot.querySelectorAll("grid-h,grid-v").forEach(grip => {
90
+ grip.addEventListener("mousedown", e => this.#startDrag(e));
91
+ });
46
92
  }
47
93
  }
48
94