material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[Dialog] autoDetectWindowHeight issue with images

Open frnk94 opened this issue 10 years ago • 2 comments

If there a big image inside the new Dialog a part of it will be rendered outside of the view port because he detecting height before the image load.

I solve this on my side by having this callback: window.dispatchEvent(new Event('resize')); on onLoad of <img />

frnk94 avatar Dec 14 '15 17:12 frnk94

The weird thing is that the image is not even load remotely its a props passed down. Look like <img src={'data:image/png;base64, ' + this.props.position.image} /> is async and causing the image getting rendered in a different loop

frnk94 avatar Dec 14 '15 17:12 frnk94

Ran into this issue, fixed by preloading the image first, before opening dialog and setting its contents:

const image = new Image();
image.onload = () => {
    this.setState({
        previewOpen: true,
        dialogContent: <img style={imgStyle} src={imgPath}/>
    });
};
image.src = imgPath;

anzorb avatar Jan 07 '17 18:01 anzorb