htmlstreamofficial / preline

Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.
https://preline.co
Other
4.9k stars 309 forks source link

HSOverlay.on not working #393

Closed pastc closed 5 months ago

pastc commented 5 months ago

Summary

The event listeners on the overlay is not working.

Using Vue3

Steps to Reproduce

import { HSOverlay } from 'preline'

onMounted(() => {
  const modalElement = document.querySelector('#hs-scan') as HTMLElement
  const modal = new HSOverlay(modalElement)

  console.log(modal)

  if (modal) {
    modal.on('open', () => {
      console.log('Modal opened')
      // modalIsOpen.value = true
      // console.log(modalIsOpen.value)
    })

    modal.on('close', () => {
      console.log('Modal closed')
      // modalIsOpen.value = false
      // console.log(modalIsOpen.value)
    })
  }
})

Expected Behavior

Should print the corresponding strings when opened and closed

Actual Behavior

Doesn't print anything

Screenshots

No response

pastc commented 5 months ago

I ended up using vueuse to check if its open. https://vueuse.org/core/useElementVisibility/

Fed3x commented 5 months ago

Can you share your solution?

pastc commented 5 months ago

@Fed3x

I ended up using vueuse to check if its open. https://vueuse.org/core/useElementVisibility/