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

Version Path
ariadne_view_components-0.0.92 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.91 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.90 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.89.1 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.89 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.88 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.87 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.86.9 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.86.8 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.86.7 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.86.6 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.86.5 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.86.4 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.86.3 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.86.2 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.86.1 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.86 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.85 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.84 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.83.3 app/components/ariadne/ui/dialog/component.ts