Skip to content

Commit 4a0a633

Browse files
committed
drag data
1 parent 9106a91 commit 4a0a633

4 files changed

Lines changed: 85 additions & 2 deletions

File tree

assets/css/main.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,12 @@ p, h3, h4, h5, img {
972972
.dataRow {
973973
display: flex;
974974
justify-content: center;
975+
padding: 4px;
976+
}
977+
978+
.dataRow:hover {
979+
border: solid 1px #424242;
980+
cursor:grab;
975981
}
976982

977983
.dataColumn {

assets/js/datasetStuff.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,14 @@ function fillSidePanel() {
3434

3535
}
3636

37+
const elements = document.querySelectorAll(".dataRow")
38+
39+
for (let i = 0; i <elements.length; i++) {
40+
41+
42+
dragElement2(elements[i])
43+
}
44+
45+
3746

3847
}

assets/js/dragStuff.js

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ function dragElement(elmnt) {
1111

1212
elmnt.onmousedown = dragMouseDown;
1313

14-
1514
function dragMouseDown(e) {
1615
e = e || window.event;
1716
e.preventDefault();
@@ -80,6 +79,73 @@ function dragElement(elmnt) {
8079
}
8180

8281

82+
function dragElement2(elmnt) {
83+
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
84+
85+
elmnt.onmousedown = dragMouseDown;
86+
87+
function dragMouseDown(e) {
88+
e = e || window.event;
89+
e.preventDefault();
90+
91+
console.log();
92+
const rect = elmnt.getBoundingClientRect();
93+
94+
offsetX = e.clientX - rect.left
95+
offsetY = e.clientY - rect.top;
96+
97+
// get the mouse cursor position at startup:
98+
pos3 = e.clientX;
99+
pos4 = e.clientY;
100+
document.onmouseup = closeDragElement;
101+
// call a function whenever the cursor moves:
102+
document.onmousemove = elementDrag;
103+
}
104+
105+
function elementDrag(e) {
106+
e = e || window.event;
107+
e.preventDefault();
108+
// calculate the new cursor position:
109+
pos1 = pos3 - e.clientX;
110+
pos2 = pos4 - e.clientY;
111+
pos3 = e.clientX;
112+
pos4 = e.clientY;
113+
114+
// set the element's new position:
115+
elmnt.style.position = "absolute";
116+
117+
let tcords = elmnt.parentElement.getBoundingClientRect();
118+
119+
elmnt.style.left =
120+
((e.pageX - offsetX) - tcords.x) + "px";
121+
122+
elmnt.style.top =
123+
((e.pageY - offsetY + 50) - 50) + "px";
124+
125+
// elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
126+
// elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
127+
128+
}
129+
130+
function closeDragElement(e) {
131+
// stop moving when mouse button is released:
132+
elmnt.style.position = "";
133+
elmnt.style.top = ""
134+
elmnt.style.left = ""
135+
document.onmouseup = null;
136+
document.onmousemove = null;
137+
dragging = false
138+
139+
140+
if (e.target.matches("#paletteDetails")) {
141+
142+
}
143+
144+
145+
}
146+
}
147+
148+
83149
function dropPalette(e, elmnt) {
84150

85151
if (e.target.matches("#paletteCont") || e.target.matches(".paletteMark") || e.target.matches(".paletteMarks")) {

index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ <h3 style="display: inline;font-weight:700;margin-left:10px;color: #eeeeee">Desc
227227
<p style="margin: 0;font-size:16pt;font-weight: 600;"> Dataset</p>
228228
<select id="availableData"> </select>
229229
<button onclick="">Import CSV</button>
230-
<div id="datasetInfo"> </div>
230+
<h5>Data Columns</h5>
231+
232+
<div id="datasetInfo" style="border-top: solid 1px #424242"> </div>
231233
</div>
232234

233235

0 commit comments

Comments
 (0)