Sha256: c65f4225a0c0b641c35e7d688cbab2ab3102aedc98e5910751796382654d654a
Contents?: true
Size: 717 Bytes
Versions: 26
Compression:
Stored size: 717 Bytes
Contents
import {controllerFactory} from '@utils/createController' import {disableBodyScroll, enableBodyScroll} from 'body-scroll-lock' export default class DialogController extends controllerFactory()({ targets: {dialog: HTMLDialogElement}, }) { close() { if (!this.dialogTarget.open) return this.dialogTarget.close() 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
26 entries across 26 versions & 1 rubygems