LvHuaiSheng / leafer-x-ruler

leafer-ui的标尺线插件
http://leafer-x-ruler.sourcenet.cc/
MIT License
11 stars 5 forks source link

窗口尺寸变化的时候,标尺的宽高并未跟随 #1

Closed devie2020 closed 7 months ago

devie2020 commented 8 months ago

image

LvHuaiSheng commented 7 months ago

image

需要触发一下leafer-ui的resize事件,如果是在vue项目中参考下面的使用方式:

// 窗口监听
const viewport = ref<HTMLElement>() // 画布view
useResizeObserver(viewport, entries => {
  const [ entry ] = entries
  const { width, height } = entry.contentRect
  console.log('窗口变化前', leaferUi.app.width, leaferUi.app.height)
  leaferUi.app.resize({ width, height })
  setTimeout(()=>{
    // 重新渲染标尺
    ruler.forceRender()
  },0)
  console.log('窗口变化后', leaferUi.app.width, leaferUi.app.height)
})