Skip to content

Commit aace789

Browse files
authored
fix(Envelope): guard update for hidden containers (#4167)
1 parent 295aa25 commit aace789

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/plugins/envelope.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,14 @@ class Polyline extends EventEmitter<{
259259

260260
update() {
261261
const { svg } = this
262-
const aspectRatioX = svg.viewBox.baseVal.width / svg.clientWidth
263-
const aspectRatioY = svg.viewBox.baseVal.height / svg.clientHeight
262+
// Skip the update if the container is hidden
263+
const { clientWidth, clientHeight } = svg
264+
if (!clientWidth || !clientHeight) {
265+
return
266+
}
267+
268+
const aspectRatioX = svg.viewBox.baseVal.width / clientWidth
269+
const aspectRatioY = svg.viewBox.baseVal.height / clientHeight
264270
const circles = svg.querySelectorAll('ellipse')
265271

266272
circles.forEach((circle) => {

0 commit comments

Comments
 (0)