* Layouts view and its subviews. * @return {View}
()
| 472 | * @return {View} |
| 473 | */ |
| 474 | layout () { |
| 475 | super.layout() |
| 476 | |
| 477 | // Measure scroll max |
| 478 | this._scrollMax = this._$content.offsetWidth - this._$scrollable.offsetWidth |
| 479 | |
| 480 | // Reset scroll position to respect new bounds |
| 481 | this.scrollTo(this._scrollPosition) |
| 482 | |
| 483 | // Update scroll handles |
| 484 | if (this._scrollPosition === 0) { |
| 485 | this._$scrollHandleLeft.classList.add(scrollHandleDisabledClass) |
| 486 | } else { |
| 487 | this._$scrollHandleLeft.classList.remove(scrollHandleDisabledClass) |
| 488 | } |
| 489 | |
| 490 | if (this._scrollPosition === this._scrollMax) { |
| 491 | this._$scrollHandleRight.classList.add(scrollHandleDisabledClass) |
| 492 | } else { |
| 493 | this._$scrollHandleRight.classList.remove(scrollHandleDisabledClass) |
| 494 | } |
| 495 | |
| 496 | // Track pipe part positions to prepare for dragging events |
| 497 | const scrollY = window.scrollY |
| 498 | this._pipePartPositions = this._$pipeParts.map($pipePart => { |
| 499 | const rect = $pipePart.getBoundingClientRect() |
| 500 | return { |
| 501 | x: rect.left + rect.width * 0.5 + this._scrollPosition, |
| 502 | y: rect.top + rect.height * 0.5 + scrollY |
| 503 | } |
| 504 | }) |
| 505 | } |
| 506 | |
| 507 | /** |
| 508 | * Scrolls to given position. Respects scroll bounds. |
no test coverage detected