From 5dfc52e374b9f9f32e004002eb2d18b44a462a3d Mon Sep 17 00:00:00 2001 From: xiaoiver Date: Thu, 9 May 2024 11:32:08 +0800 Subject: [PATCH] fix: make sure offset widht & height existed (#1684) * fix: make sure offset widht & height existed #1683 * chore: commit changeset --- .changeset/breezy-tables-build.md | 5 +++++ packages/g-lite/src/services/EventService.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/breezy-tables-build.md diff --git a/.changeset/breezy-tables-build.md b/.changeset/breezy-tables-build.md new file mode 100644 index 000000000..4fc16861f --- /dev/null +++ b/.changeset/breezy-tables-build.md @@ -0,0 +1,5 @@ +--- +'@antv/g-lite': patch +--- + +Make sure offset widht & height existed. diff --git a/packages/g-lite/src/services/EventService.ts b/packages/g-lite/src/services/EventService.ts index e0b3cc6ba..a003ddadb 100644 --- a/packages/g-lite/src/services/EventService.ts +++ b/packages/g-lite/src/services/EventService.ts @@ -102,8 +102,10 @@ export class EventService { this.context.contextService.getDomElement() as HTMLCanvasElement; if ($el && bbox) { const { offsetWidth, offsetHeight } = $el; - scaleX = bbox.width / offsetWidth; - scaleY = bbox.height / offsetHeight; + if (offsetWidth && offsetHeight) { + scaleX = bbox.width / offsetWidth; + scaleY = bbox.height / offsetHeight; + } } return { scaleX,