Commit bc0ac93a authored by pierre.tremouilhac's avatar pierre.tremouilhac
Browse files

Merge branch 'chemscanner-preview-update' into 'development'

SVG/PNG preview bug fixed

See merge request ComPlat/chemotion_ELN!812
parents 89a77939 45178566
...@@ -29,11 +29,18 @@ export default class PreviewFileZoomPan extends React.PureComponent { ...@@ -29,11 +29,18 @@ export default class PreviewFileZoomPan extends React.PureComponent {
const imgEl = svgEl.querySelector(imgSelector); const imgEl = svgEl.querySelector(imgSelector);
const svgWidth = Math.floor(svgEl.getBoundingClientRect().width); const svgWidth = Math.floor(svgEl.getBoundingClientRect().width);
const dummyImg = this.previewDiv.querySelector('#dummy-img'); let imgWidth;
dummyImg.style.display = 'block'; let imgHeight;
const imgWidth = window.getComputedStyle(dummyImg).getPropertyValue('width'); if (this.isSvg) {
const imgHeight = window.getComputedStyle(dummyImg).getPropertyValue('height'); imgWidth = Math.floor(imgEl.getBoundingClientRect().width);
dummyImg.style.display = 'none'; imgHeight = Math.floor(imgEl.getBoundingClientRect().height);
} else {
const dummyImg = this.previewDiv.querySelector('#dummy-img');
dummyImg.style.display = 'block';
imgWidth = window.getComputedStyle(dummyImg).getPropertyValue('width');
imgHeight = window.getComputedStyle(dummyImg).getPropertyValue('height');
dummyImg.style.display = 'none';
}
if (svgWidth > imgWidth) { if (svgWidth > imgWidth) {
const xOffset = `${(svgWidth - imgWidth) / 2}`; const xOffset = `${(svgWidth - imgWidth) / 2}`;
...@@ -41,8 +48,13 @@ export default class PreviewFileZoomPan extends React.PureComponent { ...@@ -41,8 +48,13 @@ export default class PreviewFileZoomPan extends React.PureComponent {
} else { } else {
imgEl.setAttribute('width', svgWidth); imgEl.setAttribute('width', svgWidth);
} }
imgEl.setAttribute('height', imgHeight);
svgEl.style.height = `${imgHeight}`; if (this.isSvg) {
svgEl.style.height = `${Math.floor(imgHeight) + 5}px`;
} else {
imgEl.setAttribute('height', imgHeight);
svgEl.style.height = `${imgHeight}`;
}
} }
render() { render() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment