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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-animation-2.0.js

Код файла
Версия от 04.12.2026, 04:03:53 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
2801}2802 2803/**2804 * Create letter span for letter animation2805 * @param {string} text - text content for the span2806 * @returns {HTMLSpanElement}2807 */2808function t_animate__createLetter(text) {2809	const span = document.createElement('span');2810	span.className = 't-animate__letter';2811	span.textContent = text;2812 
История файла и сравнение версий
  • 04.12.2026, 04:03:53 · 56c3b845
2813
return span;
2814}
2815
2816/**
2817 * Get shared grapheme segmenter, it is created once on first call
2818 * @returns {Intl.Segmenter|null} - segmenter or null if Intl.Segmenter is not supported
2819 */
2820function t_animate__getGraphemeSegmenter() {
2821 if (t_animate__getGraphemeSegmenter.segmenter === undefined) {
2822 const isSegmenterSupported = typeof Intl !== 'undefined' && typeof Intl.Segmenter === 'function';
2823
2824 t_animate__getGraphemeSegmenter.segmenter = isSegmenterSupported
2825 ? new Intl.Segmenter(undefined, { granularity: 'grapheme' })
2826 : null;
2827 }
2828
2829 return t_animate__getGraphemeSegmenter.segmenter;
2830}
2831
2832/**
2833 * Split text into letters (grapheme clusters).
2834 * Text of connected and complex shaped scripts (Arabic, Syriac, Mongolian, Indic, etc.) is not split,
2835 * because browser does not shape text across inline-block boundaries and letters lose their joining forms and ligatures.
2836 * Without Intl.Segmenter text with surrogate pairs, joiners, variation selectors or combining marks
2837 * is not split, because splitting by code points breaks emoji and accented letters.
2838 * @param {string} text - text to split
2839 * @returns {string[]} - array of letters
2840 */
2841function t_animate__getTextLetters(text) {
2842 const connectedScriptRegex =
2843 /[\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u07C0-\u07FF\u0840-\u085F\u08A0-\u08FF\u0900-\u0DFF\u1800-\u18AF\uFB50-\uFDFF\uFE70-\uFEFF]/;
2844
2845 if (connectedScriptRegex.test(text)) {
2846 return [text];
2847 }
2848
2849 const segmenter = t_animate__getGraphemeSegmenter();
2850
2851 if (segmenter) {
2852 return Array.from(segmenter.segment(text), segment => segment.segment);
2853 }
2854
2855 const complexCharRegex =
2856 /[\uD800-\uDFFF\u200C\u200D\uFE00-\uFE0F\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF]/;
2857
2858 return complexCharRegex.test(text) ? [text] : text.split('');
2859}
2860
2861/**
2862 * Split text into letters and wrap each one by span
2863 * @param {string} text - text to process
2864 * @returns {Node} - document fragment with wrapped letters
2865 */
2866function t_animate__splitTextIntoLetters(text) {
2867 const fragment = document.createDocumentFragment();
2868
2869 t_animate__getTextLetters(text).forEach(letter => {
2870 fragment.appendChild(t_animate__createLetter(letter));
2871 });
2872
2873 return fragment;
2874}
2875
2876/**
2877 * Create line span for line animation
2878 * @returns {HTMLSpanElement}
2879 */
2880function t_animate__createLine() {
2881 const line = document.createElement('span');
2882 line.className = 't-animate__line';
2883
2884 return line;
2885}
2886
2887/**
2888 * Split text into words and wrap each one by span, preserving whitespace and text decoration
2889 * @param {string} text - text to process
2890 * @param {TextDecoration|null} textDecoration - inherited text decoration from parent
2891 * @param {boolean} isMasked - whether the words should be wrapped in a mask wrapper
2892 * @returns {Node} - document fragment with wrapped words
2893 */
2894function t_animate__splitTextIntoWords(text, textDecoration, isMasked = false) {
2895 const whitespaceRegex = /(\s+)/;
2896 const fragment = document.createDocumentFragment();
2897 const parts = text.split(whitespaceRegex).filter(Boolean); // Filter out empty strings
2898
2899 parts.forEach(function (part) {
2900 const isWord = part.trim().length > 0;
Предыдущие 100 строкСледующие 100 строк