Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: HTML canvas does not match the canvas range after the camera is applied (#1702) #1752

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-tigers-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@antv/g-plugin-html-renderer': patch
---

fix: HTML canvas does not match the canvas range after the camera is applied (#1702)
20 changes: 15 additions & 5 deletions packages/g-plugin-html-renderer/src/HTMLRenderingPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@ export class HTMLRenderingPlugin implements RenderingPlugin {
'#' + cameraId,
);
if (!$existedCamera) {
// fix @see https://github.com/antvis/G/issues/1702
const $cameraContainer = (doc || document).createElement('div');
// HTML elements should not overflow with canvas @see https://github.com/antvis/G/issues/1163
$cameraContainer.style.overflow = 'hidden';
$cameraContainer.style.pointerEvents = 'none';
$cameraContainer.style.position = 'absolute';
$cameraContainer.style.left = `0px`;
$cameraContainer.style.top = `0px`;
$cameraContainer.style.width = `${width || 0}px`;
$cameraContainer.style.height = `${height || 0}px`;

const $camera = (doc || document).createElement('div');
$existedCamera = $camera;
$camera.id = cameraId;
Expand All @@ -188,13 +199,12 @@ export class HTMLRenderingPlugin implements RenderingPlugin {
$camera.style.transform = this.joinTransformMatrix(
camera.getOrthoMatrix(),
);
// HTML elements should not overflow with canvas @see https://github.com/antvis/G/issues/1163
$camera.style.overflow = 'hidden';
$camera.style.pointerEvents = 'none';
$camera.style.width = `${width || 0}px`;
$camera.style.height = `${height || 0}px`;
$camera.style.width = `100%`;
$camera.style.height = `100%`;

$container.appendChild($camera);
$cameraContainer.appendChild($camera);
$container.appendChild($cameraContainer);
}

return $existedCamera;
Expand Down
Loading