Skip to content

Commit

Permalink
Merge pull request #449 from zjffun/fix/add-over-container-property
Browse files Browse the repository at this point in the history
fix: add overContainer property to DragOutEvent
  • Loading branch information
Curtis Dulmage committed Oct 11, 2020
2 parents 74b4855 + 97b817c commit 5acbf88
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Draggable/Draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ export default class Draggable {
sourceContainer: container,
sensorEvent,
over: this.currentOver,
overContainer: this.currentOverContainer,
});

this.currentOver.classList.remove(...this.getClassNamesFor('draggable:over'));
Expand Down
25 changes: 25 additions & 0 deletions src/Draggable/tests/Draggable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -971,4 +971,29 @@ describe('Draggable', () => {
releaseMouse(newInstance.source);
});
});

describe('when `drag:out`', () => {
it('should trigger dragOutEvent', () => {
const newInstance = new Draggable(containers, {
draggable: 'li',
});
const draggableElement = sandbox.querySelector('li');
document.elementFromPoint = () => draggableElement;

newInstance.on('drag:out', (event) => {
expect(event.overContainer).toBe(containers[0]);
});

clickMouse(draggableElement);

waitForDragDelay();

document.elementFromPoint = () => draggableElement.nextElementSibling;
moveMouse(draggableElement.nextElementSibling);

waitForDragDelay();

releaseMouse(newInstance.source);
});
});
});

0 comments on commit 5acbf88

Please sign in to comment.