Skip to content

Commit

Permalink
fix: avoid overriding defXY when parsing path #1404
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoiver committed Jul 6, 2023
1 parent 7199054 commit adf9b3a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
4 changes: 3 additions & 1 deletion packages/g-lite/src/css/StyleValueRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,10 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
object.parsedStyle.path = parsePath(
// @ts-ignore
attributes.path,
object,
);

object.parsedStyle.defX = object.parsedStyle.path.rect.x;
object.parsedStyle.defY = object.parsedStyle.path.rect.y;
}
// Text
if (attributes.textTransform) {
Expand Down
15 changes: 2 additions & 13 deletions packages/g-lite/src/css/parser/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import {
path2Curve,
reverseCurve,
} from '@antv/util';
import type {
DisplayObject,
ParsedPathStyleProps,
} from '../../display-objects';
import type { ParsedPathStyleProps } from '../../display-objects';
import type { IElement } from '../../dom';
import { memoize } from '../../utils/memoize';
import {
Expand Down Expand Up @@ -82,18 +79,10 @@ const memoizedParsePath = memoize(internalParsePath);

export function parsePath(
path: string | PathArray,
object?: DisplayObject,
): ParsedPathStyleProps['path'] {
const result = (
return (
isString(path) ? memoizedParsePath(path) : internalParsePath(path)
) as ParsedPathStyleProps['path'];

if (object) {
object.parsedStyle.defX = result.rect.x;
object.parsedStyle.defY = result.rect.y;
}

return result;
}

export function mergePaths(
Expand Down
3 changes: 3 additions & 0 deletions packages/g-lite/src/css/properties/CSSPropertyPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export class CSSPropertyPath
* update local position
*/
postProcessor(object: DisplayObject, attributes: string[]) {
object.parsedStyle.defX = object.parsedStyle.path.rect.x;
object.parsedStyle.defY = object.parsedStyle.path.rect.y;

if (
object.nodeName === Shape.PATH &&
attributes.indexOf('transform') === -1
Expand Down
5 changes: 1 addition & 4 deletions packages/g-plugin-device-renderer/src/meshes/Line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,7 @@ export function updateBuffer(
) {
let path: ParsedPathStyleProps['path'];
if (object.nodeName !== Shape.PATH) {
path = parsePath(
convertToPath(object, mat4.identity(mat4.create())),
object,
);
path = parsePath(convertToPath(object, mat4.identity(mat4.create())));
defX = path.rect.x;
defY = path.rect.y;

Expand Down

0 comments on commit adf9b3a

Please sign in to comment.