* @internal Function used to scroll the page. * * @param event `MouseEvent` that triggers the resize * @param el `HTMLElement` that's being resized * @param distance Distance from the V edges to start scrolling
(event: MouseEvent, el: HTMLElement, distance: number)
| 588 | * @param distance Distance from the V edges to start scrolling |
| 589 | */ |
| 590 | static updateScrollResize(event: MouseEvent, el: HTMLElement, distance: number): void { |
| 591 | const scrollEl = Utils.getScrollElement(el); |
| 592 | const height = scrollEl.clientHeight; |
| 593 | // #1727 event.clientY is relative to viewport, so must compare this against position of scrollEl getBoundingClientRect().top |
| 594 | // #1745 Special situation if scrollEl is document 'html': here browser spec states that |
| 595 | // clientHeight is height of viewport, but getBoundingClientRect() is rectangle of html element; |
| 596 | // this discrepancy arises because in reality scrollbar is attached to viewport, not html element itself. |
| 597 | const offsetTop = (scrollEl === Utils.getScrollElement()) ? 0 : scrollEl.getBoundingClientRect().top; |
| 598 | const pointerPosY = event.clientY - offsetTop; |
| 599 | const top = pointerPosY < distance; |
| 600 | const bottom = pointerPosY > height - distance; |
| 601 | |
| 602 | if (top) { |
| 603 | // This also can be done with a timeout to keep scrolling while the mouse is |
| 604 | // in the scrolling zone. (will have smoother behavior) |
| 605 | scrollEl.scrollBy({ behavior: 'smooth', top: pointerPosY - distance}); |
| 606 | } else if (bottom) { |
| 607 | scrollEl.scrollBy({ behavior: 'smooth', top: distance - (height - pointerPosY)}); |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | /** single level clone, returning a new object with same top fields. This will share sub objects and arrays */ |
| 612 | static clone<T>(obj: T): T { |
no test coverage detected