Preserve aspect ratio in debug thumbnails.

This commit is contained in:
Bill Thiede 2020-02-26 09:21:07 -08:00
parent 669a129f21
commit 49695dd393
2 changed files with 14 additions and 9 deletions

View File

@ -3,7 +3,7 @@ body, html, #root {
} }
#ui { #ui {
background-color: white; background-color: rgba(255, 255, 255, 0.5);
bottom: 0; bottom: 0;
line-height: 3em; line-height: 3em;
position: 'absolute'; position: 'absolute';

View File

@ -173,37 +173,42 @@ class Album extends React.Component<AlbumProps, AlbumState> {
backgroundSize: 'cover', backgroundSize: 'cover',
}; };
let prefetchStyle: React.CSSProperties = { let prefetchStyle: React.CSSProperties = {
backgroundColor: 'rgba(127, 127, 127, 0.5)',
backgroundPosition: 'center center',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
bottom: 0,
height: '25%',
position: 'absolute', position: 'absolute',
width: '25%', width: '25%',
height: '25%',
bottom: 0,
}; };
let leftPrefetchStyle: React.CSSProperties = { let leftPrefetchStyle: React.CSSProperties = {
left: 0, left: 0,
backgroundImage: `url(/api/image/${prevImage.id}?w=${w}&h=${h})`,
...prefetchStyle ...prefetchStyle
}; };
let rightPrefetchStyle: React.CSSProperties = { let rightPrefetchStyle: React.CSSProperties = {
right: 0, right: 0,
backgroundImage: `url(/api/image/${nextImage.id}?w=${w}&h=${h})`,
...prefetchStyle ...prefetchStyle
}; };
let ui; let ui;
if (showUI) { if (showUI) {
// TODO(wathiede): set image as background of the div in the style.
ui = <div id="ui"> ui = <div id="ui">
<img <div
style={leftPrefetchStyle} style={leftPrefetchStyle}
onClick={(e)=>{ onClick={(e)=>{
e.stopPropagation(); e.stopPropagation();
this.setState({idx: prevIdx}) this.setState({idx: prevIdx})
}} }}></div>
src={`/api/image/${prevImage.id}?w=${w}&h=${h}`} alt="prefetch prev" />
<div className="meta">{image.filename}</div> <div className="meta">{image.filename}</div>
<img <div
style={rightPrefetchStyle} style={rightPrefetchStyle}
onClick={(e)=>{ onClick={(e)=>{
e.stopPropagation(); e.stopPropagation();
this.setState({idx: nextIdx}) this.setState({idx: nextIdx})
}} }}></div>
src={`/api/image/${nextImage.id}?w=${w}&h=${h}`} alt="prefetch next" />
</div>; </div>;
} }
return <div style={style} onClick={(e)=>{ return <div style={style} onClick={(e)=>{