Skip to content

Commit 36779fc

Browse files
Merge pull request #27 from salmans-teikametrics/main
Min Max issue
2 parents f98d5f0 + 0fbc59e commit 36779fc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/utils/calcModularScale.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ module.exports = (value, data) => {
1010
const sFtSMax = data.settings?.screenMax
1111
const unit = data.unit
1212
const sFtUnit = typeof unit === 'string' ? unit : 'rem';
13-
const ftMin = sFtMin * Math.pow(sFtRMin, value);
14-
const ftMax = sFtMax * Math.pow(sFtRMax, value);
13+
const minValue = sFtMin * Math.pow(sFtRMin, value);
14+
const maxValue = sFtMax * Math.pow(sFtRMax, value);
15+
const ftMin = Math.min(minValue, maxValue);
16+
const ftMax = Math.max(minValue, maxValue);
1517
return `clamp(${ftMin}${sFtUnit}, calc(${ftMin}${sFtUnit} + ((${ftMax} - ${ftMin}) * ((100vw - ${sFtSMin}${sFtUnit}) / (${sFtSMax} - ${sFtSMin})))), ${ftMax}${sFtUnit})`;
1618
}
1719
return value;

0 commit comments

Comments
 (0)