Некодим© 2020-2026 Некодим
Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.
Журнал изменений История Git Файлы Tilda MCP Каталог файловtilda-zero-tooltip-1.1.js Следить за файлом 501 let parent = element;502 503 while (parent && parent !== artboard) {504 animationTargets.push(parent);505 parent = parent.parentElement;506 }507 508 function handleAnimationStart() {509 startContinuousTracking();510 }511 512 // Обновляет позицию контента tooltip-а при окончании анимации, если она не сихнронизирована с позицией кнопкиИстория файла и сравнение версий function handleAnimationEnd() {
515 const currentRect = tooltipButton.getBoundingClientRect();516 const currentAbsoluteX = currentRect.left + window.pageXOffset;517 const currentAbsoluteY = currentRect.top + window.pageYOffset;519 if (Math.abs(currentAbsoluteX - lastAbsoluteX) > 0.5 || Math.abs(currentAbsoluteY - lastAbsoluteY) > 0.5) {520 updateTooltipPosition();525 animationTargets.forEach(target => {526 target.addEventListener('animationstart', handleAnimationStart);527 target.addEventListener('animationiteration', handleAnimationStart);528 target.addEventListener('animationend', handleAnimationEnd);529 target.addEventListener('transitionstart', handleAnimationStart);530 target.addEventListener('transitionend', handleAnimationEnd);533 const mutationObserver = new MutationObserver(mutations => {534 let shouldStartTracking;536 shouldStartTracking = mutations.some(538 mutation.type === 'attributes' &&539 (mutation.attributeName === 'style' || mutation.attributeName === 'class')542 if (shouldStartTracking) {543 startContinuousTracking();547 animationTargets.forEach(target => {548 mutationObserver.observe(target, {550 attributeFilter: ['style', 'class'],554 function updateTooltipPosition() {555 const currentRect = tooltipButton.getBoundingClientRect();556 const currentAbsoluteX = currentRect.left + window.pageXOffset;557 const currentAbsoluteY = currentRect.top + window.pageYOffset;559 const deltaX = (currentAbsoluteX - lastAbsoluteX) / zoom;560 const deltaY = (currentAbsoluteY - lastAbsoluteY) / zoom;562 if (deltaX !== 0 || deltaY !== 0) {563 const currentTransform = window.getComputedStyle(tooltipContent).transform;564 const matrix = new DOMMatrix(currentTransform);565 // getBoundingClientRect возвращает значения без учёта zoom в Safari до 26.4.566 // В Safari 26.4+ (window.t396__clientRectIncludesZoom) zoom уже учтён, поэтому567 // эту компенсацию надо отключить, чтобы не задваивать масштаб.568 const shouldFixSafariZoom = window.t396__isSafari && !window.t396__clientRectIncludesZoom;569 const actualDeltaX = shouldFixSafariZoom ? deltaX * zoom : deltaX;570 const actualDeltaY = shouldFixSafariZoom ? deltaY * zoom : deltaY;571 tooltipContent.style.transform = `572 translate(${matrix.e + actualDeltaX}px, ${matrix.f + actualDeltaY}px)575 lastAbsoluteX = currentAbsoluteX;576 lastAbsoluteY = currentAbsoluteY;580 function handleResize() {581 t396_tooltip__hide(element);582 t396_tooltip__show(element);585 const scrollListeners = scrollContainers.map(container => {586 const listener = () => {587 updateTooltipPosition();588 // При скролле также запускаем отслеживание,589 // т.к. могут быть анимации, привязанные к скроллу590 startContinuousTracking();591 t396_tooltip__hideOnScroll(element, 0, container);593 container.addEventListener('scroll', listener, { passive: true });594 return { container, listener };597 const image = tooltipContent.querySelector('.tn-atom__tip-img');598 // Проверка на natural width добалена для избежания зацикливания599 // т.к. в handleResize используется tooltip__show, который опять вызовет handleResize600 if (image && image.naturalWidth === 0) {