Sha256: ea9302fcbe5b85b1c35ea43af7dd46cff31baacfb9745e10fc9bd692d315c64f
Contents?: true
Size: 947 Bytes
Versions: 5
Compression:
Stored size: 947 Bytes
Contents
(() => { const application = Stimulus.Application.start() application.register("infinite-scroll", class extends Stimulus.Controller { static get targets() { return ["link", "scrollContainer"] } connect() { this.element["infiniteScroll"] = this this.scrollElement.addEventListener("scroll", this.loadNextPage.bind(this)) this.loadNextPage() } disconnect() { this.scrollElement.removeEventListener("scroll", this.loadNextPage.bind(this)) } get scrollElement() { if (this.hasScrollContainerTarget) { return this.scrollContainerTarget } else { return window } } loadNextPage() { if (this.hasLinkTarget) { let top = this.linkTarget.getBoundingClientRect().top if (top < window.innerHeight + 500) { this.linkTarget.dataset.disableWith = "..." this.linkTarget.click() } } } }) })()
Version data entries
5 entries across 5 versions & 1 rubygems