/* ====================================================
Адаптивный цвет текста меню (светлый/тёмный фон)
==================================================== */
(function () {
var NAV_ID = 'rec1698923961';
var LIGHT_CLASS = 'nav-on-light';
var DARK_CLASS = 'nav-on-dark';
var CENTER_HOVER_CLASS = 'nav-center-hover';
// ========== НАСТРОЙКА: добавь сюда ID блоков со СВЕТЛЫМ фоном ==========
var LIGHT_SECTIONS = [
'#rec1699674581',
'#rec1710124231'
];
function normalizeRecId(value) {
if (!value) return '';
return String(value).replace(/^#/, '');
}
function makeLookup(list) {
var lookup = {};
for (var i = 0; i < list.length; i++) {
var id = normalizeRecId(list[i]);
if (id) lookup[id] = true;
}
return lookup;
}
var lightLookup = makeLookup(LIGHT_SECTIONS);
function getNavHeight(nav) {
var artboard = nav.querySelector('.t396__artboard');
if (artboard) {
var artRect = artboard.getBoundingClientRect();
if (artRect.height > 0) return artRect.height;
}
var rect = nav.getBoundingClientRect();
return rect.height > 0 ? rect.height : 0;
}
function getMenuBottom(nav) {
var selectors = [
'.nav-center',
'.nav-cta',
'.nav-logo',
'.nav-center .tn-atom',
'.nav-cta .tn-atom',
'.nav-logo .tn-atom'
];
var maxBottom = 0;
for (var i = 0; i < selectors.length; i++) {
var nodes = nav.querySelectorAll(selectors[i]);
for (var j = 0; j < nodes.length; j++) {
var rect = nodes[j].getBoundingClientRect();
if (rect.height <= 0) continue;
if (rect.bottom > maxBottom) maxBottom = rect.bottom;
}
}
if (maxBottom > 0) return maxBottom;
var h = getNavHeight(nav);
return h > 0 ? h : 0;
}
function closestRecId(element) {
var node = element;
while (node && node !== document.documentElement) {
if (node.id && node.id.indexOf('rec') === 0) return node.id;
node = node.parentElement;
}
return '';
}
function updateNavColor() {
var nav = document.getElementById(NAV_ID);
if (!nav) return;
var menuBottom = getMenuBottom(nav);
var x = Math.max(1, Math.min(window.innerWidth - 1, Math.round(window.innerWidth / 2)));
// строго "на границе": берём точку на 1px ниже низа меню
var y = Math.max(1, Math.min(window.innerHeight - 1, Math.round(menuBottom + 1)));
var el = null;
for (var attempt = 0; attempt < 5; attempt++) {
el = document.elementFromPoint(x, y);
if (!el) break;
if (!nav.contains(el)) break;
y = Math.min(window.innerHeight - 1, y + 15);
}
var recId = closestRecId(el);
var isLight = !!(recId && lightLookup[recId]);
if (isLight) {
nav.classList.add(LIGHT_CLASS);
nav.classList.remove(DARK_CLASS);
} else {
nav.classList.add(DARK_CLASS);
nav.classList.remove(LIGHT_CLASS);
}
}
function pointInRect(x, y, rect) {
if (!rect) return false;
return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
}
function rectForBestMatch(nav, selectors) {
var bestRect = null;
var bestArea = 0;
for (var i = 0; i < selectors.length; i++) {
var nodes = nav.querySelectorAll(selectors[i]);
for (var j = 0; j < nodes.length; j++) {
var rect = nodes[j].getBoundingClientRect();
if (rect.width <= 0 || rect.height <= 0) continue;
var area = rect.width * rect.height;
if (area > bestArea) {
bestArea = area;
bestRect = rect;
}
}
}
return bestRect;
}
var lastPointer = null;
var hoverRafPending = false;
function updateCenterHover() {
hoverRafPending = false;
var nav = document.getElementById(NAV_ID);
if (!nav) return;
if (!lastPointer) {
nav.classList.remove(CENTER_HOVER_CLASS);
return;
}
var centerRect = rectForBestMatch(nav, ['.nav-center .tn-atom', '.nav-center', '.nav-center.tn-atom']);
if (!centerRect) {
nav.classList.remove(CENTER_HOVER_CLASS);
return;
}
var logoRect = rectForBestMatch(nav, ['.nav-logo .tn-atom', '.nav-logo', '.nav-logo.tn-atom']);
var ctaRect = rectForBestMatch(nav, ['.nav-cta .tn-atom', '.nav-cta', '.nav-cta.tn-atom']);
var x = lastPointer.x;
var y = lastPointer.y;
var inCenter = pointInRect(x, y, centerRect);
var inLogo = pointInRect(x, y, logoRect);
var inCta = pointInRect(x, y, ctaRect);
nav.classList.toggle(CENTER_HOVER_CLASS, inCenter && !inLogo && !inCta);
}
function scheduleCenterHoverUpdate() {
if (hoverRafPending) return;
hoverRafPending = true;
window.requestAnimationFrame(updateCenterHover);
}
var rafPending = false;
function scheduleUpdate() {
if (rafPending) return;
rafPending = true;
window.requestAnimationFrame(function () {
rafPending = false;
updateNavColor();
});
}
window.addEventListener('scroll', scheduleUpdate, { passive: true });
window.addEventListener('resize', scheduleUpdate);
window.addEventListener('load', scheduleUpdate);
window.addEventListener('scroll', scheduleCenterHoverUpdate, { passive: true });
window.addEventListener('resize', scheduleCenterHoverUpdate);
window.addEventListener(
'pointermove',
function (e) {
lastPointer = { x: e.clientX, y: e.clientY };
scheduleCenterHoverUpdate();
},
{ passive: true }
);
if (document.readyState !== 'loading') {
scheduleUpdate();
scheduleCenterHoverUpdate();
} else {
document.addEventListener('DOMContentLoaded', function () {
scheduleUpdate();
scheduleCenterHoverUpdate();
});
}
})();
к каждой детали проекта
Бесконечное внимание
Сайты и лендинги на Tilda для экспертов и бизнеса
Заказать сайт
Какие сайты можно сделать на Тильде
Сайт для эксперта
Сайт услуг
Портфолио
Сайт для мероприятия
Корпоративный сайт
Сайт-визитка
Многостраничный сайт
Интернет-магазин
Лендинг
Why choose us?
We work hard every day to make life of our clients better and happier
High Quality
We are a leading firm in providing quality and value to our customers. Each member of our team has at least 5 years of legal experience.
Good Support
Our managers are always ready to answer your questions. You can call us at the weekends and at night. You can also visit our office for a personal consultation.
Individual Approach
Our company works according to the principle of individual approach to every client. This method allows us to achieve success in problems of all levels.