Skip to content

Commit

Permalink
Merge pull request #9 from flash1293/lens/metric-scale-fixes
Browse files Browse the repository at this point in the history
Fix auto scaling edge cases
  • Loading branch information
chrisdavies authored Aug 14, 2019
2 parents 5065a14 + b11021b commit d7bf71b
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,17 @@ export class AutoScale extends React.Component<Props, State> {
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
position: 'relative',
maxWidth: '100%',
maxHeight: '100%',
}}
>
<div
className="autoscale-child"
ref={this.setChild}
style={{
transform: `scale(${scale})`,
position: 'relative',
}}
>
{children}
Expand All @@ -97,10 +98,8 @@ export function computeScale(
return 1;
}

const marginSize = 16;
const labelSize = 16;
const scaleX = (parent.clientWidth - marginSize) / child.clientWidth;
const scaleY = (parent.clientHeight - marginSize - labelSize) / child.clientHeight;
const scaleX = (parent.clientWidth) / child.clientWidth;
const scaleY = (parent.clientHeight) / child.clientHeight;

return Math.min(1, Math.min(scaleX, scaleY));
}

0 comments on commit d7bf71b

Please sign in to comment.