Commit 89a77939 authored by pierre.tremouilhac's avatar pierre.tremouilhac
Browse files

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

White background + proper preview size

See merge request ComPlat/chemotion_ELN!809
parents dbec748d ad45a258
......@@ -28,7 +28,12 @@ export default class PreviewFileZoomPan extends React.PureComponent {
const imgSelector = this.isSvg ? 'g > svg' : '#png-img-svg';
const imgEl = svgEl.querySelector(imgSelector);
const svgWidth = Math.floor(svgEl.getBoundingClientRect().width);
const imgWidth = Math.floor(imgEl.getBoundingClientRect().width);
const dummyImg = this.previewDiv.querySelector('#dummy-img');
dummyImg.style.display = 'block';
const imgWidth = window.getComputedStyle(dummyImg).getPropertyValue('width');
const imgHeight = window.getComputedStyle(dummyImg).getPropertyValue('height');
dummyImg.style.display = 'none';
if (svgWidth > imgWidth) {
const xOffset = `${(svgWidth - imgWidth) / 2}`;
......@@ -36,9 +41,8 @@ export default class PreviewFileZoomPan extends React.PureComponent {
} else {
imgEl.setAttribute('width', svgWidth);
}
const imgHeight = Math.floor(imgEl.getBoundingClientRect().height);
svgEl.style.height = `${Math.floor(imgHeight) + 5}px`;
imgEl.setAttribute('height', imgHeight);
svgEl.style.height = `${imgHeight}`;
}
render() {
......@@ -56,7 +60,12 @@ export default class PreviewFileZoomPan extends React.PureComponent {
}
return (
<div ref={this.setPreviewRef}>
<div ref={this.setPreviewRef} style={{ background: 'white' }}>
<img
id="dummy-img"
alt=""
src={this.isSvg ? '' : image}
/>
<SvgFileZoomPan svg={svg} duration={200} />
</div>
);
......@@ -64,9 +73,10 @@ export default class PreviewFileZoomPan extends React.PureComponent {
}
PreviewFileZoomPan.propTypes = {
image: PropTypes.string
image: PropTypes.string,
};
PreviewFileZoomPan.defaultProps = {
image: ''
image: '',
style: {}
};
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