Skip to content

BUG: 图形调用方法setPosition后,图形style中的x和y没有被同步更新 #2077

@zhe-he

Description

@zhe-he

因为 #2064 的原因 ,我只能手写导出导出方法,我发现了调用setPosition的问题。示例代码如下:

import { DisplayObject } from "@antv/g";
DisplayObject.prototype.toJSON = function () {
    const { x, y } = this.style;
    console.log(x, y);
};
const rect = new Rect({
            style: {
                x: 10,
                y: 10,
                width: 300,
                height: 200,
                fill: "#1890FF",
                stroke: "#F04864",
                lineWidth: 4,
                radius: 8,
            }
 });
rect.style.x = 1;
rect.setPosition(111, 222);
rect.style.y = 3;
console.log(rect.style.x); // 应该打印 111,此处打印的是 1
console.log(rect.style.y); // 打印为 3,无错误
// rect.toJSON();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions