1import { Controller } from "@hotwired/stimulus" 2 3export default class extends Controller { 4 static targets = ["highlight", "image"] 5 6 connect() { 7 if (!this.hasHighlightTarget) return 8 9 if (this.hasImageTarget && !this.imageTarget.complete) { 10 this.imageTarget.addEventListener("load", () => this.scrollToHighlight(), { once: true }) 11 } else { 12 this.scrollToHighlight() 13 } 14 } 15 16 scrollToHighlight() { 17 const highlight = this.highlightTarget 18 const container = this.element 19 20 const highlightTop = highlight.offsetTop 21 const highlightHeight = highlight.offsetHeight 22 const containerHeight = container.clientHeight 23 24 container.scrollTop = highlightTop - (containerHeight / 2) + (highlightHeight / 2) 25 } 26}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.