Skip to content

Commit

Permalink
fix(components): 🐛 the ref method of the vc-zoom-control component …
Browse files Browse the repository at this point in the history
…exposed errors
  • Loading branch information
zouyaoji committed May 13, 2024
1 parent 1d7137d commit 7a861ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/components/controls/zoom-control/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ export default defineComponent({
}

Object.assign(instance.proxy, {
zoomIn: () => zoomControlState.zoomIn,
zoomOut: () => zoomControlState.zoomOut,
zoomReset: () => zoomControlState.zoomReset
zoomIn: (e?: MouseEvent) => zoomControlState.zoomIn(e),
zoomOut: (e?: MouseEvent) => zoomControlState.zoomOut(e),
zoomReset: (e?: MouseEvent) => zoomControlState.zoomReset(e)
})

return () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/components/controls/zoom-control/use-zoom-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export default function (props, { emit }, vcInstance: VcComponentInternalInstanc
const zoomOutTooltipRef = ref<VcTooltipRef>(null)
const resetTooltipRef = ref<VcTooltipRef>(null)

const zoomIn = e => {
const zoomIn = (e?: MouseEvent) => {
zoom(1 / props.zoomAmount, e)
}

const zoomOut = e => {
const zoomOut = (e?: MouseEvent) => {
zoom(props.zoomAmount, e)
}

const zoom = (relativeAmount, e) => {
const zoom = (relativeAmount, e?: MouseEvent) => {
$(zoomInTooltipRef)?.hide()
$(zoomOutTooltipRef)?.hide()

Expand Down Expand Up @@ -129,7 +129,7 @@ export default function (props, { emit }, vcInstance: VcComponentInternalInstanc
}
}

const zoomReset = e => {
const zoomReset = (e?: MouseEvent) => {
$(resetTooltipRef)?.hide()
const { viewer } = $services
const scene = viewer.scene
Expand All @@ -145,7 +145,7 @@ export default function (props, { emit }, vcInstance: VcComponentInternalInstanc
viewer.trackedEntity = trackedEntity
} else {
const listener = getInstanceListener(vcInstance, 'zoomEvt')
const target = e.currentTarget
const target = e?.currentTarget
const level = heightToLevel(viewer.camera.positionCartographic.height).toFixed(0)
// reset to a default position or view defined in the options
listener &&
Expand Down

0 comments on commit 7a861ab

Please sign in to comment.