mirror of
https://github.com/czhu12/canine.git
synced 2025-12-30 15:49:54 -06:00
19 lines
475 B
JavaScript
19 lines
475 B
JavaScript
import { Controller } from "@hotwired/stimulus"
|
|
|
|
export default class extends Controller {
|
|
static targets = ["container"]
|
|
|
|
connect() {
|
|
console.log("connected")
|
|
// Scroll to the bottom of the container
|
|
this.scrollToBottom();
|
|
|
|
// Add event listener for Turbo Frame load
|
|
document.addEventListener('turbo:frame-load', this.scrollToBottom.bind(this));
|
|
}
|
|
|
|
scrollToBottom() {
|
|
this.containerTarget.scrollTop = this.containerTarget.scrollHeight;
|
|
}
|
|
}
|