* Checks whether the drop list can receive the passed-in item. * @param item Item that is being dragged into the list. * @param x Position of the item along the X axis. * @param y Position of the item along the Y axis.
(item: DragRef, x: number, y: number)
| 695 | * @param y Position of the item along the Y axis. |
| 696 | */ |
| 697 | _canReceive(item: DragRef, x: number, y: number): boolean { |
| 698 | if ( |
| 699 | !this._domRect || |
| 700 | !isInsideClientRect(this._domRect, x, y) || |
| 701 | !this.enterPredicate(item, this) |
| 702 | ) { |
| 703 | return false; |
| 704 | } |
| 705 | |
| 706 | const elementFromPoint = this._getShadowRoot().elementFromPoint(x, y) as HTMLElement | null; |
| 707 | |
| 708 | // If there's no element at the pointer position, then |
| 709 | // the client rect is probably scrolled out of the view. |
| 710 | if (!elementFromPoint) { |
| 711 | return false; |
| 712 | } |
| 713 | |
| 714 | // The `DOMRect`, that we're using to find the container over which the user is |
| 715 | // hovering, doesn't give us any information on whether the element has been scrolled |
| 716 | // out of the view or whether it's overlapping with other containers. This means that |
| 717 | // we could end up transferring the item into a container that's invisible or is positioned |
| 718 | // below another one. We use the result from `elementFromPoint` to get the top-most element |
| 719 | // at the pointer position and to find whether it's one of the intersecting drop containers. |
| 720 | return elementFromPoint === this._container || this._container.contains(elementFromPoint); |
| 721 | } |
| 722 | |
| 723 | /** |
| 724 | * Called by one of the connected drop lists when a dragging sequence has started. |
no test coverage detected