Skip to content

Commit

Permalink
cleaning dragging preview
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoVgr committed Feb 2, 2024
1 parent e106d6e commit 51961fd
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions hide/comp/cdb/Table.hx
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,7 @@ class Table extends Component {
e.preventDefault();
}

// Update preview of where the line while be dropped
var pickedEl = js.Browser.document.elementFromPoint(e.clientX, e.clientY);
var pickedLine = null;
var parentEl = pickedEl;
while (parentEl != null) {
if (lines.filter((otherLine) -> otherLine.element.get()[0] == parentEl).length > 0) {
pickedLine = lines.filter((otherLine) -> otherLine.element.get()[0] == parentEl)[0];
break;
}
parentEl = parentEl.parentElement;
}
var pickedLine = getPickedLine(e);
if (pickedLine != null) {
var lineEl = editor.getLine(line.table.sheet, pickedLine.index).element;
previewDrop.css("top",'${pickedLine.index > line.index ? lineEl.position().top + lineEl.height() : lineEl.position().top}px');
Expand All @@ -218,16 +208,7 @@ class Table extends Component {
ide.unregisterUpdate(updateDrag);
previewDrop.hide();
if (e.dataTransfer.dropEffect == "none") return false;
var pickedEl = js.Browser.document.elementFromPoint(e.clientX, e.clientY);
var pickedLine = null;
var parentEl = pickedEl;
while (parentEl != null) {
if (lines.filter((otherLine) -> otherLine.element.get()[0] == parentEl).length > 0) {
pickedLine = lines.filter((otherLine) -> otherLine.element.get()[0] == parentEl)[0];
break;
}
parentEl = parentEl.parentElement;
}
var pickedLine = getPickedLine(e);
if (pickedLine != null) {
editor.moveLine(line, pickedLine.index - line.index, true);
return true;
Expand Down Expand Up @@ -335,6 +316,21 @@ class Table extends Component {
#end
}

function getPickedLine(e : js.html.DragEvent) {
var pickedEl = js.Browser.document.elementFromPoint(e.clientX, e.clientY);
var pickedLine = null;
var parentEl = pickedEl;
while (parentEl != null) {
if (lines.filter((otherLine) -> otherLine.element.get()[0] == parentEl).length > 0) {
pickedLine = lines.filter((otherLine) -> otherLine.element.get()[0] == parentEl)[0];
break;
}
parentEl = parentEl.parentElement;
}

return pickedLine;
}

function makeSeparatorTree( ?root ) {
var curLevel = 0;
var cur : SepTree = { sep : null, index : -1, subs : [], parent : null };
Expand Down

0 comments on commit 51961fd

Please sign in to comment.