I have a div with the width 794px and a range input with max 250 and min 0. I am scaling the div with the css transform: scale(1), where 1 is when the div is actually shown at 794px.
However, when the width of the browser window is greater than that I want to be able to scale up even more so that when the window is at 1588px, the div should have the value scale(2). And when the browser window is smaller than 794px the maximum value (250) should represent the width of the window.
I have tried several different solutions for this, I will only post the last one so I won't confuse anyone.
Javascript:
const baseWidth = 794;
const maxWidth = (baseWidth * 2) + 50;
const workspace = document.getElementById('workspace');
const oWidth = workspace.offsetWidth;
const rangeValue = zoomElement.target.value;
const rangeStepSizeByPixels = (oWidth - 0) / 250;
const rangeStepSizeByPercent = (rangeStepSizeByPixels / oWidth) * 100;
const trueZoom = rangeValue * this.state.rangeStepSize;
this.setState({
...this.state,
actualZoom: trueZoom,
height: (700 * trueZoom) / 100,
width: (550 * trueZoom) / 100,
});
HTML:
<section id="infobar" class="inner-margin">
<input type="range" step="0.4" min="0" max="250" class="zoomslider" value="250">
</section>
<section id="workspace" class="scrollable tender-edit orange-midnight-them">
<div class="doccontainer" style="width: 794px; height: 1123px;">
<section class="init-scale" style="transform: scale(1);">
<div class="doc-header">
...
</div>
<div class="doc-inner">
...
</div>
<div class="doc-footer">
...
</div>
</section>
</div>
</section>
This resulted in a situation where the range value 250 was the same as setting scale(1), which is not what I am going for.