From 91128308403a601e55efb2553a819f582f19760c Mon Sep 17 00:00:00 2001 From: zhouxinyu Date: Mon, 21 Oct 2024 11:36:57 +0800 Subject: [PATCH] fix: fix the accuracy issue of number matching, closed #1488 --- .../fix-subview-check_2024-10-21-03-36.json | 10 ++++++++++ packages/vrender-core/src/core/window.ts | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 common/changes/@visactor/vrender-core/fix-subview-check_2024-10-21-03-36.json diff --git a/common/changes/@visactor/vrender-core/fix-subview-check_2024-10-21-03-36.json b/common/changes/@visactor/vrender-core/fix-subview-check_2024-10-21-03-36.json new file mode 100644 index 000000000..cc67be1e3 --- /dev/null +++ b/common/changes/@visactor/vrender-core/fix-subview-check_2024-10-21-03-36.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@visactor/vrender-core", + "comment": "fix: fix the accuracy issue of number matching, closed #1488", + "type": "none" + } + ], + "packageName": "@visactor/vrender-core" +} \ No newline at end of file diff --git a/packages/vrender-core/src/core/window.ts b/packages/vrender-core/src/core/window.ts index 75b8fe166..ab44691cb 100644 --- a/packages/vrender-core/src/core/window.ts +++ b/packages/vrender-core/src/core/window.ts @@ -1,6 +1,6 @@ import { inject, injectable } from '../common/inversify-lite'; import type { IPointLike } from '@visactor/vutils'; -import { Matrix, type IBoundsLike, type IMatrix, IBounds, Point } from '@visactor/vutils'; +import { Matrix, type IBoundsLike, type IMatrix, IBounds, Point, isEqual, isNumberClose } from '@visactor/vutils'; import { Generator } from '../common/generator'; import type { ICanvas, @@ -234,8 +234,8 @@ export class DefaultWindow implements IWindow { return !( viewBox.x1 === 0 && viewBox.y1 === 0 && - this.width === viewBox.width() && - this.height === viewBox.height() + isNumberClose(this.width, viewBox.width()) && + isNumberClose(this.height, viewBox.height()) ); }