Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kurmanov committed Aug 5, 2024
1 parent 0296410 commit 021e548
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/dragdrop/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export abstract class DragDropCore<T> implements IDragDropEngine {
event
);
this.onStartDrag(event);
const fromElement = this.draggedElement.parent;
this.onDragStart.fire(this, { fromElement: fromElement, draggedElement: this.draggedElement });
}

protected onStartDrag(event?: PointerEvent): void {
Expand Down Expand Up @@ -230,7 +232,6 @@ export abstract class DragDropCore<T> implements IDragDropEngine {
public drop(): void {
if (this.allowDropHere) {
const fromElement = this.draggedElement.parent;
this.onDragStart.fire(this, { fromElement: fromElement, draggedElement: this.draggedElement });
const newElement = this.doDrop();
this.onDragEnd.fire(this, { fromElement: fromElement, draggedElement: newElement, toElement: this.dropTarget });
}
Expand Down
6 changes: 4 additions & 2 deletions tests/dragdrophelpertests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,14 @@ QUnit.test("choices: onDragStart and onDragEnd events", function (assert) {
ddHelper.parentElement = question;
ddHelper.draggedElement = question.choices[2];

ddHelper["createDraggedElementShortcut"] = ()=>{};
ddHelper.dragInit(null, ddHelper.draggedElement, ddHelper.parentElement, document.createElement("div"));
assert.equal(beforeCount, 1);
ddHelper["allowDropHere"] = true;
ddHelper["domAdapter"]["draggedElementShortcut"] = document.body.appendChild(
document.createElement("div")
);
ddHelper["allowDropHere"] = true;
ddHelper["drop"]();
assert.equal(beforeCount, 1);
assert.equal(afterCount, 1);
assert.equal(draggedElementParent.name, "q");
});
Expand Down

0 comments on commit 021e548

Please sign in to comment.