UNPKG

@stimulus-library/controllers

Version:

A library of useful controllers for Stimulus

26 lines (25 loc) 751 B
import { BaseController, getScrollParent, scrollAbsoluteBottom } from "@stimulus-library/utilities"; export class ScrollToBottomController extends BaseController { get _mode() { return this.hasModeValue ? this.modeValue : "document"; } get _scrollTarget() { let target; if (this._mode == "document") { target = window; } else { target = getScrollParent(this.el); } return target; } async scroll(event) { event === null || event === void 0 ? void 0 : event.preventDefault(); if (this._scrollTarget) { await scrollAbsoluteBottom(this._scrollTarget); } } } ScrollToBottomController.values = { mode: String, };