MCPcopy Create free account
hub / github.com/cryptii/cryptii / layout

Method layout

src/View/Pipe.js:474–505  ·  view source on GitHub ↗

* Layouts view and its subviews. * @return {View}

()

Source from the content-addressed store, hash-verified

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.

Callers 2

updateMethod · 0.95
windowDidResizeMethod · 0.45

Calls 1

scrollToMethod · 0.95

Tested by

no test coverage detected