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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-animation-2.0.js

Код файла
Версия от 04.12.2026, 04:03:53 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
2901		let wordSpan;2902 2903		if (isWord) {2904			wordSpan = t_animate__createWord(part, textDecoration, isMasked);2905		} else {2906			wordSpan = t_animate__createWhitespaceWord(part);2907		}2908 2909		fragment.appendChild(wordSpan);2910	});2911 2912	return fragment;2913
История файла и сравнение версий
  • 04.12.2026, 04:03:53 · 56c3b845
}
2914
2915/**
2916 * Split text into strict words with trailing whitespaces and wrap each one by span.
2917 * @param {string} text - text to process
2918 * @returns {Node} - document fragment with wrapped words
2919 */
2920function t_animate__splitTextIntoStrictWords(text) {
2921 const whitespaceRegex = /(\s+)/;
2922 const fragment = document.createDocumentFragment();
2923 const parts = text
2924 .split(whitespaceRegex)
2925 .reduce((acc, part) => {
2926 const isWhitespace = part.trim().length === 0;
2927
2928 if (isWhitespace && acc.length > 0) {
2929 acc[acc.length - 1] += part;
2930 } else {
2931 acc.push(part);
2932 }
2933
2934 return acc;
2935 }, []) // Combine trailing whitespace with the previous word
2936 .filter(Boolean); // Filter out empty strings
2937
2938 parts.forEach(function (part) {
2939 const isWord = part.trim().length > 0;
2940 let wordSpan;
2941
2942 if (isWord) {
2943 wordSpan = t_animate__createStrictWord(part);
2944 } else {
2945 wordSpan = t_animate__createWhitespaceWord(part);
2946 }
2947
2948 fragment.appendChild(wordSpan);
2949 });
2950
2951 return fragment;
2952}
2953
2954/**
2955 * Wrap inner words of an animated text element with a span, processing its child nodes recursively.
2956 * @param {Node} node - node to process
2957 * @param {boolean} isMasked - whether the words should be wrapped in a mask wrapper
2958 * @returns {Node} - document fragment with wrapped content
2959 */
2960function t_animate__wrapAnimatedTextElementContentWords(node, isMasked = false) {
2961 /**
2962 * Wrap inner words of a text node
2963 * @param {Text} textNode - text node to process
2964 * @param {TextStyleOptions|null} textStyleOptions - inherited text style options from parent
2965 * @returns {Node} - document fragment with wrapped words
2966 */
2967 function wrapTextNode(textNode, textStyleOptions) {
2968 const { verticalAlign = null, textDecoration = null } = textStyleOptions ?? {};
2969 const hasStyleConflict = Boolean(verticalAlign && textDecoration);
2970 const text = textNode.textContent;
2971
2972 const wrappedText = hasStyleConflict
2973 ? t_animate__splitTextIntoStrictWords(text)
2974 : t_animate__splitTextIntoWords(text, textDecoration, isMasked);
2975
2976 return wrappedText;
2977 }
2978
2979 /**
2980 * Wrap inner words of an element node
2981 * @param {Element} elementNode - element node to process
2982 * @param {TextStyleOptions|null} textStyleOptions - inherited text style options from parent
2983 * @returns {Node} - cloned element with wrapped children
2984 */
2985 function wrapElementNode(elementNode, textStyleOptions) {
2986 // Clone element preserving all attributes (Quill formatting, classes, etc.)
2987 const clone = elementNode.cloneNode(false);
2988
2989 // Process children if they exist
2990 if (elementNode.childNodes.length > 0) {
2991 const wrappedChildren = wrapNode(elementNode, textStyleOptions);
2992
2993 clone.appendChild(wrappedChildren);
2994 }
2995
2996 return clone;
2997 }
2998
2999 /**
3000 * Wrap inner words of a node recursively, preserving text decoration and vertical alignment.
Предыдущие 100 строкСледующие 100 строк