Skip to content

fix: 补充 shape destroy 逻辑 - #338

Closed
huaxiabuluo wants to merge 1 commit into
antvis:masterfrom
huaxiabuluo:fix-basic-shape-update
Closed

fix: 补充 shape destroy 逻辑#338
huaxiabuluo wants to merge 1 commit into
antvis:masterfrom
huaxiabuluo:fix-basic-shape-update

Conversation

@huaxiabuluo

Copy link
Copy Markdown
Contributor

Canvas 的实例调用 render 方法完成首次渲染后,再次执行 update 方法更新画布,如果使用了 line | circle | rect | ... 等基础图形标签,会导致上一屏的基础图形不会被正确擦除。

对于下面测试用例:

const context = createContext();
const { props } = (
  <Canvas context={context}>
    <rect
      style={{
        width: 36,
        height: 36,
        fill: 'red',
      }}
    />
  </Canvas>
);

const canvas = new Canvas(props);
await canvas.render();

const { props: nextProps } = (
  <Canvas context={context}>
    <circle
      style={{
        cx: 80,
        cy: 30,
        r: 20,
        lineWidth: 2,
        stroke: '#e45649',
        fill: 'blue',
      }}
    />
  </Canvas>
);
await delay(500);
await canvas.update(nextProps);

await delay(200);
expect(context).toMatchImageSnapshot();
  • Before (update 渲染异常, rect 没有销毁擦除)
vnode-update-test-tsx-vnode-更新-基础图形更新-1-snap
  • After (update 渲染正常, rect 被销毁擦除)
vnode-update-test-tsx-vnode-更新-基础图形更新-1-snap

@huaxiabuluo huaxiabuluo changed the title fix: 补充 shape destroy 逻辑 [WIP] fix: 补充 shape destroy 逻辑 Aug 4, 2025
@huaxiabuluo
huaxiabuluo force-pushed the fix-basic-shape-update branch 2 times, most recently from 7a76e0b to 34b73df Compare August 8, 2025 08:04
@huaxiabuluo
huaxiabuluo force-pushed the fix-basic-shape-update branch from 34b73df to 4a5d262 Compare August 8, 2025 08:06
@huaxiabuluo huaxiabuluo changed the title [WIP] fix: 补充 shape destroy 逻辑 fix: 补充 shape destroy 逻辑 Aug 8, 2025
@tangying1027

Copy link
Copy Markdown
Contributor

直接 FEngine 仓库里提

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants