<!-- Samand.studio | autoscale страницы -->
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
//НАСТРОЙКИ
const x = 1400; // Установите нужное значение
const header_action = true; //Будет ли модификация работать в Header
const footer_action = true; //Будет ли модификация работать в Footer
const containers = document.querySelectorAll('.t-container, .t396, .t117_map, .t-feed'); // Селектор для обычных и Zero блоков
//добавляем класс контейнерам, соответствующим условию
containers.forEach(container => {
if (!header_action && container.closest('#t-header')) {
} else if (!footer_action && container.closest('#t-footer')) {
} else {
container.classList.add('modi_autoscale')
}
})
// Сохраняем оригинальные размеры
const originalSizes = new Map();
function initSizes() {
containers.forEach(container => {
originalSizes.set(container, {
width: container.offsetWidth,
height: container.offsetHeight
});
});
}
function updateScale() {
const viewportWidth = window.innerWidth;
containers.forEach(container => {
const original = originalSizes.get(container);
if (container.classList.contains('modi_autoscale')) {
if (viewportWidth > x && original ) {
const scale = viewportWidth / x;
container.style.transform = `scale(${scale})`;
container.style.marginBottom = `${(original.height * scale - original.height)}px`;
} else {
container.style.transform = 'scale(1)';
container.style.marginBottom = '0';
}
}
/*
if(viewportWidth > x && original ) {
const scale = viewportWidth / x;
container.style.transform = `scale(${scale})`;
container.style.marginBottom = `${(original.height * scale - original.height)}px`;
} else {
container.style.transform = 'scale(1)';
container.style.marginBottom = '0';
}*/
});
}
// Инициализация после полной загрузки
window.addEventListener('load', function() {
initSizes();
updateScale();
});
// Оптимизация ресайза
let resizeTimer;
window.addEventListener('resize', () => {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => {
initSizes();
updateScale();
}, 150);
});
// Дополнительный фикс для динамического контента
new MutationObserver(updateScale).observe(document.body, {
subtree: true,
childList: true,
attributes: true
});
});
</script>
<style>
.modi_autoscale {
transform-origin: top center;
transition: transform 0.3s ease;
overflow: hidden !important;
margin-left: auto !important;
margin-right: auto !important;
}
</style>