Resets drag item to end of boundary element.
()
| 588 | |
| 589 | /** Resets drag item to end of boundary element. */ |
| 590 | resetToBoundary(): void { |
| 591 | if ( |
| 592 | // can be null if the drag item was never dragged. |
| 593 | this._boundaryElement && |
| 594 | this._rootElement && |
| 595 | // check if we are overflowing off our boundary element |
| 596 | isOverflowingParent( |
| 597 | this._boundaryElement.getBoundingClientRect(), |
| 598 | this._rootElement.getBoundingClientRect(), |
| 599 | ) |
| 600 | ) { |
| 601 | const parentRect = this._boundaryElement.getBoundingClientRect(); |
| 602 | const childRect = this._rootElement.getBoundingClientRect(); |
| 603 | |
| 604 | let offsetX = 0; |
| 605 | let offsetY = 0; |
| 606 | |
| 607 | // check if we are overflowing from left or right |
| 608 | if (childRect.left < parentRect.left) { |
| 609 | offsetX = parentRect.left - childRect.left; |
| 610 | } else if (childRect.right > parentRect.right) { |
| 611 | offsetX = parentRect.right - childRect.right; |
| 612 | } |
| 613 | |
| 614 | // check if we are overflowing from top or bottom |
| 615 | if (childRect.top < parentRect.top) { |
| 616 | offsetY = parentRect.top - childRect.top; |
| 617 | } else if (childRect.bottom > parentRect.bottom) { |
| 618 | offsetY = parentRect.bottom - childRect.bottom; |
| 619 | } |
| 620 | |
| 621 | const currentLeft = this._activeTransform.x; |
| 622 | const currentTop = this._activeTransform.y; |
| 623 | |
| 624 | let x = currentLeft + offsetX, |
| 625 | y = currentTop + offsetY; |
| 626 | |
| 627 | this._rootElement.style.transform = getTransform(x, y); |
| 628 | this._activeTransform = {x, y}; |
| 629 | this._passiveTransform = {x, y}; |
| 630 | } |
| 631 | } |
| 632 | |
| 633 | /** |
| 634 | * Sets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging. |
nothing calls this directly
no test coverage detected