Scale option
This commit is contained in:
+28
@@ -1094,11 +1094,13 @@
|
||||
this.currentMER = 0;
|
||||
this.isImperial = false;
|
||||
this.theme = this.getThemeFromURL() || 'system';
|
||||
this.scale = this.getScaleFromURL() || 1.0;
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
this.applyTheme();
|
||||
this.applyScale();
|
||||
this.bindEvents();
|
||||
this.updateUnitLabels();
|
||||
this.setupIframeResize();
|
||||
@@ -1114,12 +1116,38 @@
|
||||
return ['light', 'dark', 'system'].includes(theme) ? theme : null;
|
||||
}
|
||||
|
||||
getScaleFromURL() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const scale = parseFloat(urlParams.get('scale'));
|
||||
return (!isNaN(scale) && scale >= 0.5 && scale <= 2.0) ? scale : null;
|
||||
}
|
||||
|
||||
applyTheme() {
|
||||
const container = document.getElementById('dogCalculator');
|
||||
container.classList.remove('theme-light', 'theme-dark', 'theme-system');
|
||||
container.classList.add('theme-' + this.theme);
|
||||
}
|
||||
|
||||
applyScale() {
|
||||
const container = document.getElementById('dogCalculator');
|
||||
if (!container) return;
|
||||
|
||||
// Clamp scale between 0.5 and 2.0 for usability
|
||||
const clampedScale = Math.max(0.5, Math.min(2.0, this.scale));
|
||||
|
||||
if (clampedScale !== 1.0) {
|
||||
container.style.transform = `scale(${clampedScale})`;
|
||||
container.style.transformOrigin = 'top center';
|
||||
|
||||
// Adjust container to account for scaling
|
||||
setTimeout(() => {
|
||||
const actualHeight = container.offsetHeight * clampedScale;
|
||||
container.style.marginBottom = `${(clampedScale - 1) * container.offsetHeight}px`;
|
||||
this.sendHeightToParent();
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
bindEvents() {
|
||||
const weightInput = document.getElementById('weight');
|
||||
const dogTypeSelect = document.getElementById('dogType');
|
||||
|
||||
Reference in New Issue
Block a user