You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Viewer.js (specifically with <img> tags pointing to .svg files), SVGs are displayed with an incorrect initial width (often 300px) in Chrome and Firefox, while Safari renders them correctly, filling the viewport (contain behavior). This occurs despite the <img> tag having width and height attributes.
Problem:
When an SVG is loaded via an <img> tag and opened in Viewer.js, Chrome and Firefox seem to default to a smaller width (e.g., 300px) for the SVG within the Viewer's canvas. Safari, however, correctly scales the SVG to fit the available space, respecting a "contain" like behavior. This leads to an inconsistent user experience across browsers.
Open the page in Chrome or Firefox. Click on the SVG image to open it in Viewer.js. The SVG appears small (e.g., 300px wide) within the viewer.
Open the page in Safari. Click on the SVG image. The SVG scales correctly to fill the viewer, maintaining its aspect ratio.
Expected Behavior:
SVGs should scale to fit the Viewer.js canvas, respecting the initialCoverage option and behaving consistently across all modern browsers (Chrome, Firefox, Safari), similar to how Safari currently handles it.
Environment:
Viewer.js Version: v1.11.7
Operating System: macOS, Windows 11
Possible Cause / Suggestion:
It seems Viewer.js might not be correctly interpreting or applying the intrinsic dimensions of SVGs (or the viewBox attribute) when creating the <img> element within its canvas, leading to browser-specific default sizing in Chrome/Firefox. Perhaps a more robust handling of SVG dimensions or a default "contain" behavior for SVGs within the Viewer's internal <img> element could resolve this.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
When using Viewer.js (specifically with
<img>
tags pointing to.svg
files), SVGs are displayed with an incorrect initial width (often 300px) in Chrome and Firefox, while Safari renders them correctly, filling the viewport (contain behavior). This occurs despite the<img>
tag havingwidth
andheight
attributes.Problem:
When an SVG is loaded via an
<img>
tag and opened in Viewer.js, Chrome and Firefox seem to default to a smaller width (e.g., 300px) for the SVG within the Viewer's canvas. Safari, however, correctly scales the SVG to fit the available space, respecting a "contain" like behavior. This leads to an inconsistent user experience across browsers.Steps to Reproduce:
HTML Structure:
JavaScript (Viewer.js Initialization):
Observe:
Expected Behavior:
SVGs should scale to fit the Viewer.js canvas, respecting the
initialCoverage
option and behaving consistently across all modern browsers (Chrome, Firefox, Safari), similar to how Safari currently handles it.Environment:
Possible Cause / Suggestion:
It seems Viewer.js might not be correctly interpreting or applying the intrinsic dimensions of SVGs (or the
viewBox
attribute) when creating the<img>
element within its canvas, leading to browser-specific default sizing in Chrome/Firefox. Perhaps a more robust handling of SVG dimensions or a default "contain" behavior for SVGs within the Viewer's internal<img>
element could resolve this.Beta Was this translation helpful? Give feedback.
All reactions