ninegrid2 6.665.0 → 6.667.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,52 @@ 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
+ console.log(e);
121072
+
121073
+ const mode = this.#mode;
121074
+ const dragBar = document.createElement("div");
121075
+ dragBar.className = "nx-drag-bar";
121076
+ dragBar.style.position = "fixed";
121077
+ dragBar.style.zIndex = "9999";
121078
+ dragBar.style.pointerEvents = "none";
121079
+ dragBar.style.background = "#666";
121080
+ dragBar.style.opacity = "0.6";
121081
+
121082
+ // 방향별 초기 위치 설정
121083
+ if (mode === "h") {
121084
+ dragBar.style.top = "0";
121085
+ dragBar.style.width = "1px";
121086
+ dragBar.style.height = "100vh";
121087
+ dragBar.style.left = `${e.clientX}px`;
121088
+ } else {
121089
+ dragBar.style.left = "0";
121090
+ dragBar.style.width = "100vw";
121091
+ dragBar.style.height = "1px";
121092
+ dragBar.style.top = `${e.clientY}px`;
121093
+ }
121094
+
121095
+ document.body.appendChild(dragBar);
121096
+
121097
+ const onMove = e => {
121098
+ console.log(e);
121099
+ if (mode === "h") dragBar.style.left = `${e.clientX}px`;
121100
+ else dragBar.style.top = `${e.clientY}px`;
121101
+ };
121102
+
121103
+ const onUp = (e) => {
121104
+ console.log(e);
121105
+ window.removeEventListener("mousemove", onMove);
121106
+ window.removeEventListener("mouseup", onUp);
121107
+ dragBar.remove();
121108
+ };
121109
+
121110
+ window.addEventListener("mousemove", onMove);
121111
+ window.addEventListener("mouseup", onUp);
121112
+ };
121113
+
121069
121114
 
121070
121115
  #init = () => {
121071
121116
  this.#detectMode(this);
@@ -121088,6 +121133,11 @@ class nxSplitter extends HTMLElement {
121088
121133
  `;
121089
121134
 
121090
121135
  this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
121136
+
121137
+ // grip 이벤트 바인딩
121138
+ this.shadowRoot.querySelectorAll(".grid-h,.grid-v").forEach(grip => {
121139
+ grip.addEventListener("mousedown", e => this.#startDrag(e));
121140
+ });
121091
121141
  }
121092
121142
  }
121093
121143
 
@@ -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,52 @@ 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
+ console.log(e);
121068
+
121069
+ const mode = this.#mode;
121070
+ const dragBar = document.createElement("div");
121071
+ dragBar.className = "nx-drag-bar";
121072
+ dragBar.style.position = "fixed";
121073
+ dragBar.style.zIndex = "9999";
121074
+ dragBar.style.pointerEvents = "none";
121075
+ dragBar.style.background = "#666";
121076
+ dragBar.style.opacity = "0.6";
121077
+
121078
+ // 방향별 초기 위치 설정
121079
+ if (mode === "h") {
121080
+ dragBar.style.top = "0";
121081
+ dragBar.style.width = "1px";
121082
+ dragBar.style.height = "100vh";
121083
+ dragBar.style.left = `${e.clientX}px`;
121084
+ } else {
121085
+ dragBar.style.left = "0";
121086
+ dragBar.style.width = "100vw";
121087
+ dragBar.style.height = "1px";
121088
+ dragBar.style.top = `${e.clientY}px`;
121089
+ }
121090
+
121091
+ document.body.appendChild(dragBar);
121092
+
121093
+ const onMove = e => {
121094
+ console.log(e);
121095
+ if (mode === "h") dragBar.style.left = `${e.clientX}px`;
121096
+ else dragBar.style.top = `${e.clientY}px`;
121097
+ };
121098
+
121099
+ const onUp = (e) => {
121100
+ console.log(e);
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
+
121065
121110
 
121066
121111
  #init = () => {
121067
121112
  this.#detectMode(this);
@@ -121084,6 +121129,11 @@ class nxSplitter extends HTMLElement {
121084
121129
  `;
121085
121130
 
121086
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
+ });
121087
121137
  }
121088
121138
  }
121089
121139
 
@@ -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,57 @@ 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
+ console.log(e);
27
+
28
+ const mode = this.#mode;
29
+ const dragBar = document.createElement("div");
30
+ dragBar.className = "nx-drag-bar";
31
+ dragBar.style.position = "fixed";
32
+ dragBar.style.zIndex = "9999";
33
+ dragBar.style.pointerEvents = "none";
34
+ dragBar.style.background = "#666";
35
+ dragBar.style.opacity = "0.6";
36
+
37
+ // 방향별 초기 위치 설정
38
+ if (mode === "h") {
39
+ dragBar.style.top = "0";
40
+ dragBar.style.width = "1px";
41
+ dragBar.style.height = "100vh";
42
+ dragBar.style.left = `${e.clientX}px`;
43
+ } else {
44
+ dragBar.style.left = "0";
45
+ dragBar.style.width = "100vw";
46
+ dragBar.style.height = "1px";
47
+ dragBar.style.top = `${e.clientY}px`;
48
+ }
49
+
50
+ document.body.appendChild(dragBar);
51
+
52
+ const onMove = e => {
53
+ console.log(e);
54
+ if (mode === "h") dragBar.style.left = `${e.clientX}px`;
55
+ else dragBar.style.top = `${e.clientY}px`;
56
+ };
57
+
58
+ const onUp = (e) => {
59
+ console.log(e);
60
+ window.removeEventListener("mousemove", onMove);
61
+ window.removeEventListener("mouseup", onUp);
62
+ dragBar.remove();
63
+ };
64
+
65
+ window.addEventListener("mousemove", onMove);
66
+ window.addEventListener("mouseup", onUp);
67
+ };
68
+
24
69
 
25
70
  #init = () => {
26
71
  this.#detectMode(this);
27
72
 
28
- this.classList.add(this.#mode)
73
+ this.classList.add(this.#mode);
29
74
 
30
75
  const contents = this.innerHTML.trim();
31
76
  const gripClass = `grip-${this.#mode}`;
@@ -43,6 +88,11 @@ class nxSplitter extends HTMLElement {
43
88
  `;
44
89
 
45
90
  this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
91
+
92
+ // grip 이벤트 바인딩
93
+ this.shadowRoot.querySelectorAll(".grid-h,.grid-v").forEach(grip => {
94
+ grip.addEventListener("mousedown", e => this.#startDrag(e));
95
+ });
46
96
  }
47
97
  }
48
98
 
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.667.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,57 @@ 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
+ console.log(e);
27
+
28
+ const mode = this.#mode;
29
+ const dragBar = document.createElement("div");
30
+ dragBar.className = "nx-drag-bar";
31
+ dragBar.style.position = "fixed";
32
+ dragBar.style.zIndex = "9999";
33
+ dragBar.style.pointerEvents = "none";
34
+ dragBar.style.background = "#666";
35
+ dragBar.style.opacity = "0.6";
36
+
37
+ // 방향별 초기 위치 설정
38
+ if (mode === "h") {
39
+ dragBar.style.top = "0";
40
+ dragBar.style.width = "1px";
41
+ dragBar.style.height = "100vh";
42
+ dragBar.style.left = `${e.clientX}px`;
43
+ } else {
44
+ dragBar.style.left = "0";
45
+ dragBar.style.width = "100vw";
46
+ dragBar.style.height = "1px";
47
+ dragBar.style.top = `${e.clientY}px`;
48
+ }
49
+
50
+ document.body.appendChild(dragBar);
51
+
52
+ const onMove = e => {
53
+ console.log(e);
54
+ if (mode === "h") dragBar.style.left = `${e.clientX}px`;
55
+ else dragBar.style.top = `${e.clientY}px`;
56
+ };
57
+
58
+ const onUp = (e) => {
59
+ console.log(e);
60
+ window.removeEventListener("mousemove", onMove);
61
+ window.removeEventListener("mouseup", onUp);
62
+ dragBar.remove();
63
+ };
64
+
65
+ window.addEventListener("mousemove", onMove);
66
+ window.addEventListener("mouseup", onUp);
67
+ };
68
+
24
69
 
25
70
  #init = () => {
26
71
  this.#detectMode(this);
27
72
 
28
- this.classList.add(this.#mode)
73
+ this.classList.add(this.#mode);
29
74
 
30
75
  const contents = this.innerHTML.trim();
31
76
  const gripClass = `grip-${this.#mode}`;
@@ -43,6 +88,11 @@ class nxSplitter extends HTMLElement {
43
88
  `;
44
89
 
45
90
  this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
91
+
92
+ // grip 이벤트 바인딩
93
+ this.shadowRoot.querySelectorAll(".grid-h,.grid-v").forEach(grip => {
94
+ grip.addEventListener("mousedown", e => this.#startDrag(e));
95
+ });
46
96
  }
47
97
  }
48
98