Skip to content

Commit 0eb5142

Browse files
authored
fix: avoid overriding defXY when parsing path (#1405)
* fix: avoid overriding defXY when parsing path #1404 * chore: commit changeset
1 parent 7199054 commit 0eb5142

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

.changeset/stupid-schools-bow.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@antv/g-plugin-zdog-canvas-renderer': patch
3+
'@antv/g-plugin-device-renderer': patch
4+
'@antv/g-plugin-webgpu-device': patch
5+
'@antv/g-plugin-webgl-device': patch
6+
'@antv/g-plugin-box2d': patch
7+
'@antv/g-plugin-physx': patch
8+
'@antv/g-webgpu': patch
9+
'@antv/g-lite': patch
10+
---
11+
12+
Avoid overriding defXY when parsing path

packages/g-lite/src/css/StyleValueRegistry.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,10 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
757757
object.parsedStyle.path = parsePath(
758758
// @ts-ignore
759759
attributes.path,
760-
object,
761760
);
761+
762+
object.parsedStyle.defX = object.parsedStyle.path.rect.x;
763+
object.parsedStyle.defY = object.parsedStyle.path.rect.y;
762764
}
763765
// Text
764766
if (attributes.textTransform) {

packages/g-lite/src/css/parser/path.ts

+2-13
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ import {
99
path2Curve,
1010
reverseCurve,
1111
} from '@antv/util';
12-
import type {
13-
DisplayObject,
14-
ParsedPathStyleProps,
15-
} from '../../display-objects';
12+
import type { ParsedPathStyleProps } from '../../display-objects';
1613
import type { IElement } from '../../dom';
1714
import { memoize } from '../../utils/memoize';
1815
import {
@@ -82,18 +79,10 @@ const memoizedParsePath = memoize(internalParsePath);
8279

8380
export function parsePath(
8481
path: string | PathArray,
85-
object?: DisplayObject,
8682
): ParsedPathStyleProps['path'] {
87-
const result = (
83+
return (
8884
isString(path) ? memoizedParsePath(path) : internalParsePath(path)
8985
) as ParsedPathStyleProps['path'];
90-
91-
if (object) {
92-
object.parsedStyle.defX = result.rect.x;
93-
object.parsedStyle.defY = result.rect.y;
94-
}
95-
96-
return result;
9786
}
9887

9988
export function mergePaths(

packages/g-lite/src/css/properties/CSSPropertyPath.ts

+3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ export class CSSPropertyPath
4848
* update local position
4949
*/
5050
postProcessor(object: DisplayObject, attributes: string[]) {
51+
object.parsedStyle.defX = object.parsedStyle.path.rect.x;
52+
object.parsedStyle.defY = object.parsedStyle.path.rect.y;
53+
5154
if (
5255
object.nodeName === Shape.PATH &&
5356
attributes.indexOf('transform') === -1

packages/g-plugin-device-renderer/src/meshes/Line.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,7 @@ export function updateBuffer(
484484
) {
485485
let path: ParsedPathStyleProps['path'];
486486
if (object.nodeName !== Shape.PATH) {
487-
path = parsePath(
488-
convertToPath(object, mat4.identity(mat4.create())),
489-
object,
490-
);
487+
path = parsePath(convertToPath(object, mat4.identity(mat4.create())));
491488
defX = path.rect.x;
492489
defY = path.rect.y;
493490

0 commit comments

Comments
 (0)