yue1123 / vue3-baidu-map-gl

🎉百度地图 GL版 Vue3 组件库,baidu map gl components libary based on Vue3.0
https://yue1123.github.io/vue3-baidu-map-gl/
MIT License
375 stars 44 forks source link

useTrackAnimation hooks 若 options.delay > 0 则导致 status 更新失败 #55

Closed Hi-Alan closed 11 months ago

Hi-Alan commented 11 months ago

代码

const { setPath, start, cancel, stop, proceed, status } = useTrackAnimation(map, {
  duration: 30000,
  delay: 300, // >0 
  tilt: 55,
  overallView: true,
  zoom: 14,
})

watch(status, (newVal, oldVal) => {
  // 不会调用
  console.log(oldVal ,'->', newVal)
})

错误提示

useTrackAnimation.js:40 Uncaught TypeError: Cannot read properties of undefined (reading 'addEventListener')
    at useTrackAnimation.js:40:35

原因 instance.start() 之后, 会延迟 options.delay 之后初始化 instance._viewAni

yue1123 commented 11 months ago

确实存在这个问题,下个patch版本修复