Некодим логотипНекодим
МодификацииПубликацииНекодИИмЦены
Некодим логотипНекодим

© 2020-2026 Некодим

Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.

Компания

  • Контакты
  • Публичная оферта
  • Политика конфиденциальности
  • Согласие на обработку данных
  • Лицензионное соглашение
  • Реферальная программа

Полезное

  • Модификации
  • Публикации
  • Каталог блоков Tilda
  • MCP для агентов
  • Журнал изменений
  • Доска почёта

Личный кабинет

  • Вход
  • Регистрация
  • Цены
Журнал измененийИстория GitФайлыTilda MCP
Каталог файлов

tilda-zero-tooltip-1.1.js

Код файла
Версия от 18.08.2026, 07:00:17 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
401		return 'hover';402	}403}404 405/**406 * Сихнронизирует позицию контента tooltip-a с анимациями, ресайза окна, скролла407 *408 * @param {HTMLElement} element - элемент tooltip-а .tn-elem409 * @param {*} tooltipButton - кнопка tooltip-а410 * @param {*} tooltipContent - контент tooltip-а411 * @returns {Function} cleanupPositionSync - функция, которая очищает все слушатели событий при удалении tooltip-а412
История файла и сравнение версий
  • 18.08.2026, 07:00:17 · 56c3b845
*/
413function t396_tooltip__setupPositionSync(element, tooltipButton, tooltipContent) {
414 const artboard = element.closest('.t396__artboard');
415 const artboardId = artboard.getAttribute('data-artboard-recid');
416 const zoom = !window.tn.isEditMode ? t396__getCurrentScaleFactor(artboardId) : 1;
417
418 const initialButtonRect = tooltipButton.getBoundingClientRect();
419 let lastAbsoluteX = initialButtonRect.left + window.pageXOffset;
420 let lastAbsoluteY = initialButtonRect.top + window.pageYOffset;
421
422 let container = element;
423 const scrollContainers = [window];
424 const scrollValues = ['auto', 'scroll'];
425
426 while (container && container !== document.body) {
427 const style = window.getComputedStyle(container);
428 if (scrollValues.includes(style.overflowX) || scrollValues.includes(style.overflowY)) {
429 scrollContainers.push(container);
430 }
431
432 container = container.parentElement;
433 }
434
435 let rafId = null;
436 let isActiveTracking = false;
437 let lastCheckTime = 0;
438 const CHECK_INTERVAL = 16;
439
440 function startContinuousTracking() {
441 if (isActiveTracking) return;
442 isActiveTracking = true;
443 checkPositionLoop();
444 }
445
446 function stopContinuousTracking() {
447 isActiveTracking = false;
448 if (rafId) {
449 cancelAnimationFrame(rafId);
450 rafId = null;
451 }
452 }
453
454 // Проверяет позицию кнопки tooltip-а и если она поменялась, то вызывает функцию updateTooltipPosition и обновляет timer
455 function checkPositionLoop() {
456 if (!isActiveTracking) return;
457
458 const now = performance.now();
459
460 if (now - lastCheckTime >= CHECK_INTERVAL) {
461 const currentRect = tooltipButton.getBoundingClientRect();
462 const currentAbsoluteX = currentRect.left + window.pageXOffset;
463 const currentAbsoluteY = currentRect.top + window.pageYOffset;
464
465 if (Math.abs(currentAbsoluteX - lastAbsoluteX) > 0.5 || Math.abs(currentAbsoluteY - lastAbsoluteY) > 0.5) {
466 updateTooltipPosition();
467 lastCheckTime = now;
468 resetInactivityTimer();
469 }
470 }
471
472 rafId = requestAnimationFrame(checkPositionLoop);
473 }
474
475 let inactivityTimerId = null;
476 const INACTIVITY_TIMEOUT = 2000;
477
478 // Сбрасывает таймер при перемещения кнопки tooltip-а или отключает флаг трэкинга, если позиция кнопки и контента сихнронизированы
479 function resetInactivityTimer() {
480 clearTimeout(inactivityTimerId);
481 inactivityTimerId = setTimeout(() => {
482 const currentRect = tooltipButton.getBoundingClientRect();
483 const currentAbsoluteX = currentRect.left + window.pageXOffset;
484 const currentAbsoluteY = currentRect.top + window.pageYOffset;
485 const hasInfiniteAnimation =
486 element.getAttribute('data-animate-prx') || element.getAttribute('data-animate-sbs-loop');
487
488 if (
489 Math.abs(currentAbsoluteX - lastAbsoluteX) < 0.5 &&
490 Math.abs(currentAbsoluteY - lastAbsoluteY) < 0.5 &&
491 !hasInfiniteAnimation
492 ) {
493 stopContinuousTracking();
494 } else {
495 resetInactivityTimer();
496 }
497 }, INACTIVITY_TIMEOUT);
498 }
499
500 const animationTargets = [];
Предыдущие 100 строкСледующие 100 строк