Sha256: fa24753a59695bac07b2313103f41bfa504c205f34be7aac1ca43a331f3c616c
Contents?: true
Size: 797 Bytes
Versions: 4
Compression:
Stored size: 797 Bytes
Contents
import ApplicationController from './application_controller' export default class extends ApplicationController { static values = { url: String } initialize () { this.boundScrollToTop = this.scrollToTop.bind(this) } connect () { this.element.addEventListener('turbo:frame-load', this.boundScrollToTop) } scrollToTop (e) { const scrollTarget = this.element.closest('[data-scroll-target]') const boundingRect = scrollTarget.getBoundingClientRect() if (scrollTarget && boundingRect.top < 0) { scrollTarget.scrollIntoView() } } reload () { if (this.element.src) { this.element.reload() } else if (this.hasUrlValue) { this.element.src = this.urlValue } else { this.element.src = document.location.href } } }
Version data entries
4 entries across 4 versions & 1 rubygems