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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-animation-ext-1.0.js

Код файла
Версия от 04.12.2026, 04:03:53 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
1401/**1402 * wrappint atom element to current classname div1403 *1404 * @param {HTMLElement} el - atom1405 * @param {string[]} classNameList1406 * @param {string} wrapperSelector1407 * @param {HTMLElement | null} scaleWrapper - for Opera/Firefox, in case of use autoscale1408 */1409function t_animationExt__wrapEl(el, classNameList, wrapperSelector, scaleWrapper) {1410	if (el.closest(wrapperSelector)) return;1411	var parentElement = el.closest('.tn-elem, .tn-group');1412
История файла и сравнение версий
  • 04.12.2026, 04:03:53 · 56c3b845
var div = document.createElement('div');
1413 classNameList.forEach(function (name) {
1414 div.classList.add(name);
1415 });
1416
1417 /**
1418 * display: inherit повторяет значение родителя: у элемента это table, поэтому tn-atom
1419 * остаётся table-cell, а у autolayout-группы это block, который в отличие от таблицы
1420 * не растягивается по контенту и сохраняет скролл при overflow: auto/scroll
1421 */
1422 div.style.display = 'inherit';
1423 div.style.width = 'inherit';
1424 div.style.height = 'inherit';
1425 div.style.borderRadius = 'inherit';
1426
1427 scaleWrapper ? div.appendChild(scaleWrapper) : div.appendChild(el);
1428 parentElement.appendChild(div);
1429 t_animationExt__updateStylesAfterWrapping(scaleWrapper || el, div, parentElement);
1430}
1431
1432/**
1433 *
1434 * @param {HTMLElement} animCore
1435 * @param {'sticky' | 'prx'} prefix
1436 * @return {string[]}
1437 */
1438function t_animationExt__generateWrapperClassList(animCore, prefix) {
1439 var isMolecule = animCore.classList.contains('tn-molecule');
1440 var template = '__' + prefix + '-wrapper';
1441 if (isMolecule) return ['tn-molecule' + template, 'tn-atom' + template];
1442 return ['tn-atom' + template];
1443}
1444
1445/**
1446 *
1447 * @param {HTMLElement} animCore
1448 * @param {'sticky' | 'prx'} prefix
1449 * @return {string}
1450 */
1451function t_animationExt__generateWrapperSelector(animCore, prefix) {
1452 var isMolecule = animCore.classList.contains('tn-molecule');
1453 var template = '__' + prefix + '-wrapper';
1454 if (isMolecule) return '.tn-molecule' + template;
1455 return '.tn-atom' + template + ':not(.tn-molecule' + template + ')';
1456}
1457
1458function t_animationExt__updateStylesAfterWrapping(atom, wrapper, parentElement) {
1459 // add border-radius property for animation wrapper, because we set filters for parentElem
1460 // getPropertyValue returns border-radius value in px. If it cannot setted, will return '0px'
1461 var elType = parentElement ? parentElement.getAttribute('data-elem-type') : '';
1462 var elBorderRadius = window.getComputedStyle(parentElement).getPropertyValue('border-radius');
1463 if ((elType === 'shape' || elType === 'widget') && parseInt(elBorderRadius, 10)) {
1464 wrapper.style.borderRadius = elBorderRadius;
1465 }
1466
1467 // find filters in parent element to set them to wrapper, and remove from current parent
1468 var filterList = ['filter', 'backdrop-filter'];
1469 filterList = filterList.map(function (filter) {
1470 var webkitFilter = '-webkit-' + filter;
1471 var parentFilterValue = window.getComputedStyle(parentElement).getPropertyValue(filter);
1472 if (parentFilterValue === 'none' || parentFilterValue === '')
1473 parentFilterValue = window.getComputedStyle(parentElement).getPropertyValue(webkitFilter);
1474 if (parentFilterValue !== 'none' && parentFilterValue !== '') {
1475 return { filter: filter, webkitFilter: webkitFilter, value: parentFilterValue };
1476 }
1477 });
1478
1479 // If filter couldn't find, Array.prototype.map returns undefined.
1480 // Should use Array.prototype.filter to remove negative values (undefined)
1481 filterList = filterList.filter(function (filter) {
1482 return filter;
1483 });
1484
1485 filterList.forEach(function (filterOpts) {
1486 if (navigator.userAgent.search('Firefox') !== -1) wrapper.style.backfaceVisibility = 'visible';
1487 wrapper.style[filterOpts.webkitFilter] = filterOpts.value;
1488 wrapper.style[filterOpts.filter] = filterOpts.value;
1489 parentElement.style[filterOpts.webkitFilter] = 'none';
1490 parentElement.style[filterOpts.filter] = 'none';
1491 if (window.getComputedStyle(atom).transform === 'none') atom.style.transform = 'translateZ(0)';
1492 });
1493
1494 var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
1495 if (isSafari && filterList.length && elType === 'image') {
1496 var backdropFilterImageEvent = document.createEvent('Event');
1497 backdropFilterImageEvent.initEvent('backdropFilterImgWrappered', true, true);
1498 parentElement.dispatchEvent(backdropFilterImageEvent);
1499 parentElement.classList.add('t396__elem--backdrop-filter-img-wrappered');
1500 }
Предыдущие 100 строкСледующие 100 строк