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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-tooltip-1.0.js

Код файла
Версия от 18.08.2026, 07:00:16 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
1001							}1002 1003							proxy.dimension.height = areaGreatestY - areaSmallestY;1004							proxy.dimension.width = areaGreatestX - areaSmallestX;1005							proxy.offset.top = mapOffsetTop + areaSmallestY;1006							proxy.offset.left = mapOffsetLeft + areaSmallestX;1007						} else {1008							proxy.dimension.height = map.offsetHeight;1009							proxy.dimension.width = map.offsetWidth;1010							proxy.offset.top = mapOffsetTop;1011							proxy.offset.left = mapOffsetLeft;1012
История файла и сравнение версий
  • 18.08.2026, 07:00:16 · 56c3b845
}
1013 }
1014
1015 // our function and global vars for positioning our tooltip
1016 var currentLeft = 0;
1017 var currentLeftMirror = 0;
1018 var currentTop = 0;
1019 var offsetY = parseInt(self.options.offsetY);
1020 var offsetX = parseInt(self.options.offsetX);
1021
1022 // this is the arrow position that will eventually be used. It may differ from the position option if the tooltip cannot be displayed in this position
1023 practicalPosition = self.options.position;
1024
1025 /**
1026 * A function to detect if the tooltip is going off the screen horizontally. If so, reposition it!
1027 */
1028 function dontGoOffScreenX() {
1029 var windowLeft = (window.pageXOffset || body.scrollLeft) - (body.clientLeft || 0);
1030
1031 // if the tooltip goes off the left side of the screen, line it up with the left side of the window
1032 if (currentLeft - windowLeft < 0) {
1033 arrowReposition = currentLeft - windowLeft;
1034 currentLeft = windowLeft;
1035 }
1036
1037 // if the tooltip goes off the right of the screen, line it up with the right side of the window
1038 if (currentLeft + tooltipWidth - windowLeft > windowWidth) {
1039 arrowReposition = currentLeft - (windowWidth + windowLeft - tooltipWidth);
1040 currentLeft = windowWidth + windowLeft - tooltipWidth;
1041 }
1042 }
1043
1044 /**
1045 * A function to detect if the tooltip is going off the screen vertically. If so, switch to the opposite!
1046 *
1047 * @param {string} switchTo - switch to position
1048 * @param {string} switchFrom - switch from position
1049 */
1050 function dontGoOffScreenY(switchTo, switchFrom) {
1051 var windowScrollTop = window.pageYOffset;
1052 // if it goes off the top off the page
1053 if (
1054 proxy.offset.top - windowScrollTop - tooltipHeight - offsetY - 12 < 0 &&
1055 switchFrom.indexOf('top') > -1
1056 ) {
1057 practicalPosition = switchTo;
1058 }
1059
1060 // if it goes off the bottom of the page but fits at the top
1061 if (
1062 proxy.offset.top + proxy.dimension.height + tooltipHeight + 12 + offsetY >
1063 windowScrollTop + window.innerHeight &&
1064 switchFrom.indexOf('bottom') > -1 &&
1065 proxy.offset.top - tooltipHeight - offsetY - 12 > 0
1066 ) {
1067 practicalPosition = switchTo;
1068 currentTop = proxy.offset.top - tooltipHeight - offsetY - 12;
1069 }
1070 }
1071
1072 if (practicalPosition === 'top') {
1073 var leftDifference =
1074 proxy.offset.left + tooltipWidth - (proxy.offset.left + proxy.dimension.width);
1075 currentLeft = proxy.offset.left + offsetX - leftDifference / 2;
1076 currentTop = proxy.offset.top - tooltipHeight - offsetY - 12;
1077 dontGoOffScreenX();
1078 dontGoOffScreenY('bottom', 'top');
1079 }
1080
1081 if (practicalPosition === 'top-left') {
1082 currentLeft = proxy.offset.left + offsetX;
1083 currentTop = proxy.offset.top - tooltipHeight - offsetY - 12;
1084 dontGoOffScreenX();
1085 dontGoOffScreenY('bottom-left', 'top-left');
1086 }
1087
1088 if (practicalPosition === 'top-right') {
1089 currentLeft = proxy.offset.left + proxy.dimension.width + offsetX - tooltipWidth;
1090 currentTop = proxy.offset.top - tooltipHeight - offsetY - 12;
1091 dontGoOffScreenX();
1092 dontGoOffScreenY('bottom-right', 'top-right');
1093 }
1094
1095 if (practicalPosition === 'bottom') {
1096 var leftDifference =
1097 proxy.offset.left + tooltipWidth - (proxy.offset.left + proxy.dimension.width);
1098 currentLeft = proxy.offset.left - leftDifference / 2 + offsetX;
1099 currentTop = proxy.offset.top + proxy.dimension.height + offsetY + 12;
1100 dontGoOffScreenX();
Предыдущие 100 строкСледующие 100 строк