Sha256: 3923777e533acac5b1a350bd594df76223dc0793153f23c12f6e3d760a975b61
Contents?: true
Size: 815 Bytes
Versions: 6
Compression:
Stored size: 815 Bytes
Contents
import {controllerFactory} from '@utils/createController' import {disableBodyScroll, enableBodyScroll} from 'body-scroll-lock' export default class DialogController extends controllerFactory()({ targets: {dialog: HTMLDialogElement}, }) { close() { this.dialogTarget.close() // reset any child forms // for (const form of this.dialogTarget.querySelectorAll('form') ?? []) { // form.reset() // } enableBodyScroll(this.dialogTarget) } disconnect() { this.close() } open() { this.dialogTarget.showModal() disableBodyScroll(this.dialogTarget, {reserveScrollBarGap: true}) } triggerClick() { if (this.dialogTarget.open) this.close() else this.open() } windowClick(e: MouseEvent) { if (e.target === this.dialogTarget) { this.close() } } }
Version data entries
6 entries across 6 versions & 1 rubygems