Некодим© 2020-2026 Некодим
Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.
Журнал изменений История Git Файлы Tilda MCP Каталог файловtilda-menusub-1.0.js Следить за файлом 2001 var wrapper = column.closest('.t-menusub__innermenu-wrapper');2002 var calculatedMaxHeight;2003 if (wrapper) {2004 var overflow = rect.bottom - winHeight + bottomPadding;2005 var currentTop = parseFloat(wrapper.style.top) || 0;2006 var newTop = currentTop - overflow;2007 2008 // Не поднимать выше 02009 if (newTop < 0) {2010 // Если не можем поднять достаточно — добавляем скролл2011 wrapper.style.top = '0px';2012 История файла и сравнение версий var wrapperRect = wrapper.getBoundingClientRect();
2013 calculatedMaxHeight = winHeight - wrapperRect.top - bottomPadding;2014 if (calculatedMaxHeight > 0) {2015 column.style.maxHeight = calculatedMaxHeight + 'px';2016 column.style.overflowY = 'auto';2019 wrapper.style.top = newTop + 'px';2022 // Для content (2-й уровень) — только скролл2023 calculatedMaxHeight = winHeight - rect.top - bottomPadding;2024 if (calculatedMaxHeight > MENU_MIN_SCROLL_HEIGHT) {2025 column.style.maxHeight = calculatedMaxHeight + 'px';2026 column.style.overflowY = 'auto';2033 * Проверка, находится ли элемент внутри "зоны меню"2034 * @param {HTMLElement} element - проверяемый элемент2035 * @param {Object} ctx - контекст2036 * @returns {boolean} - true если элемент внутри зоны меню2038 function t_menusub__isInsideMenuZone(element, ctx) {2039 if (!element) return false;2042 ctx.content.contains(element) ||2043 (ctx.innerMenu && ctx.innerMenu.contains(element)) ||2044 Array.prototype.slice.call(ctx.innermenuWrappers).some(function (w) {2045 return w.contains(element);2047 (ctx.menuWrapper && ctx.menuWrapper.contains(element)) ||2048 (element.nodeName === 'HTML' && ctx.innermenuWrappers.length > 0)2052 // shouldIgnoreMouseout и shouldIgnoreInnermenuLeave удалены - используем isInsideMenuZone напрямую2055 * Универсальные обработчики событий для обоих режимов (десктоп/мобайл)2056 * @param {Object} ctx - контекст с необходимыми переменными2058 function t_menusub__initUniversalHandlers(ctx) {2059 var showTimer = null;2060 var hideTimer = null;2061 var mouseEnterEvent = new Event('submenu:mouseenter');2063 ctx.content.addEventListener('mouseover', function (e) {2064 if (!t_menusub__isDesktopMode) return;2066 var link = e.target.closest(MENU_SELECTORS.LINK);2069 var linkParentList = link.closest(MENU_SELECTORS.LIST);2070 var contentList = ctx.content.querySelector(MENU_SELECTORS.CONTENT_LIST);2071 if (linkParentList !== contentList) return;2073 var hook = link.getAttribute('data-menu-submenu-hook');2075 clearTimeout(showTimer);2076 clearTimeout(hideTimer);2077 ctx.rootSubmenu.dispatchEvent(mouseEnterEvent);2079 var parentLi = link.closest(MENU_SELECTORS.LIST_ITEM);2080 t_menusub__clearHoverlinks(ctx.rootSubmenu, parentLi);2081 if (parentLi) parentLi.classList.add(MENU_CLASSES.HOVERLINK);2084 hideTimer = setTimeout(function () {2085 t_menusub__hideChildMenu(ctx);2090 showTimer = setTimeout(function () {2091 t_menusub__showInnermenuOnHover(ctx, link, parentLi);2095 ctx.content.addEventListener('mouseout', function (e) {2096 if (!t_menusub__isDesktopMode) return;2098 var toElement = e.relatedTarget;2099 clearTimeout(showTimer);