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

XEOK-151 Fix label's text offset in an html2canvas capture #1736

Merged
merged 1 commit into from
Nov 14, 2024
Merged
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
9 changes: 9 additions & 0 deletions src/viewer/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,12 @@ class Viewer {
}
}

// Added to fix label's text offset in an html2canvas capture (See XEOK-151)
// based on https://github.com/niklasvh/html2canvas/issues/2775#issuecomment-1316356991
const style = document.createElement('style');
document.head.appendChild(style);
style.sheet?.insertRule('body > div:last-child img { display: inline-block; }');

for (let i = 0, len = pluginContainerElements.length; i < len; i++) {
const containerElement = pluginContainerElements[i];
await html2canvas(containerElement, {
Expand All @@ -503,6 +509,9 @@ class Viewer {
// (implemented to compensate XCD-153 issue)
snapshotCanvas.getContext("2d").resetTransform();
}

style.remove();

if (!params.includeGizmos) {
this.sendToPlugins("snapshotFinished");
}
Expand Down
Loading