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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-animation-2.0.js

Код файла
Версия от 04.12.2026, 04:03:53 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
3001	 * @param {Node} node - current node to process3002	 * @param {TextStyleOptions|null} parrentTextStyleOptions - inherited text style options from parent3003	 * @returns {Node} - document fragment with wrapped content3004	 */3005	function wrapNode(node, parrentTextStyleOptions) {3006		const fragment = document.createDocumentFragment();3007		const textStyleOptions = t_animate__getTextStyleOptions(node, parrentTextStyleOptions);3008 3009		Array.from(node.childNodes).forEach(function (childNode) {3010			if (childNode.nodeType === Node.TEXT_NODE) {3011				const wrappedTextNode = wrapTextNode(childNode, textStyleOptions);
История файла и сравнение версий
  • 04.12.2026, 04:03:53 · 56c3b845
3012 fragment.appendChild(wrappedTextNode);
3013 } else if (childNode.nodeType === Node.ELEMENT_NODE) {
3014 const wrappedElement = wrapElementNode(childNode, textStyleOptions);
3015 fragment.appendChild(wrappedElement);
3016 }
3017 });
3018
3019 return fragment;
3020 }
3021
3022 const wrappedContent = wrapNode(node, null);
3023
3024 node.innerHTML = '';
3025 node.appendChild(wrappedContent);
3026}
3027
3028/**
3029 * Unwrap each line of animated text element
3030 * @param {HTMLElement} element - specific element to unwrap
3031 */
3032function t_animate__unwrapAnimatedTextElementLines(element) {
3033 const lines = element.querySelectorAll('.t-animate__line');
3034
3035 lines.forEach(line => {
3036 line.replaceWith(...line.childNodes);
3037 });
3038}
3039
3040/**
3041 * Wrap each line of an animated text element with a span, processing its child nodes recursively.
3042 * @param {Node} node - node to process
3043 */
3044function t_animate__wrapAnimatedTextElementLines(node) {
3045 /**
3046 * Split an element into left and right parts based on the provided path of child nodes.
3047 * @param {Node} element - the element to split
3048 * @param {Node[]} path - array of child nodes leading to the target node to split on
3049 * @returns {{ leftPart: Node, rightPart: Node }} - object containing left and right parts
3050 */
3051 function splitElement(element, path) {
3052 if (!path.length) {
3053 return { leftPart: document.createDocumentFragment(), rightPart: element };
3054 }
3055
3056 const [childToSplitOn, ...restPath] = path;
3057 const elementChildList = Array.from(element.childNodes);
3058 const childToSplitOnIndex = elementChildList.findIndex(child => child === childToSplitOn);
3059
3060 if (childToSplitOnIndex < 0) {
3061 return { leftPart: element, rightPart: document.createDocumentFragment() };
3062 }
3063
3064 const leftPart = element.cloneNode(false);
3065 const rightPart = element.cloneNode(false);
3066 const leftPartChildList = childToSplitOnIndex > 0 ? elementChildList.slice(0, childToSplitOnIndex) : [];
3067 const rightPartChildList =
3068 childToSplitOnIndex < elementChildList.length - 1 ? elementChildList.slice(childToSplitOnIndex + 1) : [];
3069 const { leftPart: leftChildPart, rightPart: rightChildPart } = splitElement(childToSplitOn, restPath);
3070
3071 leftPart.append(...leftPartChildList, leftChildPart);
3072 rightPart.append(rightChildPart, ...rightPartChildList);
3073
3074 return { leftPart, rightPart };
3075 }
3076
3077 /**
3078 * Split inner elements of a node by lines. Splits two lined elements into separate elements for each line
3079 * by creating new elements and replacing the original ones in the DOM.
3080 * @param {Node} node - the parent node containing the elements
3081 * @param {Node[][]} lines - array of lines, each line is an array of nodes
3082 * @returns {{ root: Node, elements: Node[] }[]} - array of objects containing the root node and its elements for each line
3083 */
3084 function splitNodeInnerElementsByLines(node, lines) {
3085 const elementsLineInfoList = [];
3086
3087 for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
3088 const words = lines[lineIndex];
3089 const { elements: prevElements } = elementsLineInfoList.at(-1) ?? {};
3090 const elements = [];
3091 let root = null;
3092
3093 for (let wordIndex = 0; wordIndex < words.length; wordIndex++) {
3094 const word = words[wordIndex];
3095 const treePathInfo = t_animate__getTreePath(word);
3096 const path = treePathInfo.path;
3097 const [container = word, ...restPath] = path;
3098 const existedContainerIndex = prevElements?.findIndex(item => item === container);
3099 root = treePathInfo.root;
3100
Предыдущие 100 строкСледующие 100 строк