tech-systems / panes

🎉📱 Create dynamic modals, cards, panes for your applications in few steps. One instance – Thousands solutions. Any framework and free.
https://panejs.com
MIT License
681 stars 40 forks source link

[BUG] calcFitHeight need some time to calc correctly #227

Closed bazuka5801 closed 10 months ago

bazuka5801 commented 10 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. init and open pane in vuejs on startup
  2. calcFitHeight not working properly until some time is reach
  3. see backdrop is shown but pane in 16px height

Expected behavior calcFitHeight calculate height automatically when selector is rendered or changed size

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context workaround

const pane = ref<CupertinoPane | null>(null)

function epochTime() {
  return Math.floor(Date.now() / 1000)
}

const loadTime = epochTime()
async function fitHeihtFix() {
  if (epochTime() - 5 > loadTime) return
  while (
    pane.value.getPaneHeight() < 100 ||
    Number.isNaN(pane.value.getPaneHeight())
  ) {
    await new Promise((resolve) => {
      setTimeout(resolve, 10)
    })
    pane.value.calcFitHeight()
  }
}

function showDialog() {
  pane.value.present(...)
  fitHeihtFix()
}
bazuka5801 commented 10 months ago

My mistake, I'm using defineAsyncComponent with ES import('my component.vue'), which causes a problem with calcFitHeight since the selector is not rendered yet.