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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-animation-2.0.js

Код файла
Версия от 04.12.2026, 04:03:53 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
2301		return Array.from(elements);2302	}2303 2304	const elementAnimationStyle = element.getAttribute('data-animate-style');2305	const isStyleAppropriate = animationStyles.includes(elementAnimationStyle);2306 2307	return isStyleAppropriate ? [element] : [];2308}2309 2310/**2311 * Prepare word by word animation to the right.2312 * Add animation delay for each word by increment
История файла и сравнение версий
  • 04.12.2026, 04:03:53 · 56c3b845
2313 * @param {HTMLElement|null} element - optional specific element to prepare, if null, prepares all elements with the specified animation styles
2314 */
2315function t_animate__prepareWordByWordAnimationToRight(element = null) {
2316 const wordDelayIncrement = 0.06;
2317 const animatedTextElements = t_animate__getAnimatedTextElements(
2318 ['word-fade-in-right', 'word-fade-in-up', 'word-fade-in-up-masked', 'word-fade-in-down'],
2319 element
2320 );
2321
2322 animatedTextElements.forEach(animatedTextElement => {
2323 const wordElements = animatedTextElement.querySelectorAll('.t-animate__word');
2324 const baseDelay = t_animate__getElementBaseDelay(animatedTextElement);
2325 let wordIndex = 0;
2326
2327 wordElements.forEach(wordElement => {
2328 t_animate__setTextParticleDelay(wordElement, baseDelay + wordIndex * wordDelayIncrement);
2329
2330 if (!t_animate__isWhitespaceParticle(wordElement)) {
2331 wordIndex++;
2332 }
2333 });
2334 });
2335}
2336
2337/**
2338 * Get the root element and tree path of inline parents for a given text node.
2339 * @param {Node} node - text node to process
2340 * @param {Node[]} path - array of inline parent nodes leading to the root
2341 * @returns {{ root: Node, path: Node[] }} - root element and path of inline parents
2342 */
2343function t_animate__getTreePath(node, path = []) {
2344 const parent = node.parentElement;
2345
2346 if (!parent || parent === node) {
2347 return {
2348 root: node,
2349 path,
2350 };
2351 }
2352
2353 const parentStyles = window.getComputedStyle(parent);
2354 const isParentInline = parentStyles.display.includes('inline');
2355
2356 return isParentInline
2357 ? t_animate__getTreePath(parent, [parent, ...path])
2358 : {
2359 root: parent,
2360 path,
2361 };
2362}
2363
2364/**
2365 * Get lines of words from element.
2366 * @param {HTMLElement} element - element to get lines from
2367 * @returns {HTMLElement[][]} - array of lines, each line is an array of word elements
2368 */
2369function t_animate__getElementLines(element) {
2370 const wordElements = element.querySelectorAll('.t-animate__word');
2371 const lines = Array.from(wordElements)
2372 .reduce((acc, wordElement) => {
2373 const { root } = t_animate__getTreePath(wordElement);
2374 const wordTop = Math.round(wordElement.offsetTop + (wordElement.offsetParent?.offsetTop ?? 0));
2375 const currentLine = acc.at(-1);
2376 const isWhitespace = wordElement.classList.contains('t-animate__word_whitespace');
2377
2378 if (currentLine && currentLine.root === root && Math.abs(wordTop - currentLine.top) < currentLine.height) {
2379 currentLine.words.push(wordElement);
2380
2381 if (currentLine.isTopUpdateNeeded && !isWhitespace) {
2382 currentLine.isTopUpdateNeeded = false;
2383 currentLine.top = wordTop;
2384 }
2385 } else {
2386 const lineHeight = window.getComputedStyle(wordElement).lineHeight;
2387 const lineHeightParsedValue = parseFloat(lineHeight);
2388 const lineHeightNumberValue = isNaN(lineHeightParsedValue)
2389 ? wordElement.getBoundingClientRect().height
2390 : lineHeightParsedValue;
2391
2392 acc.push({
2393 root,
2394 top: wordTop,
2395 height: lineHeightNumberValue,
2396 words: [wordElement],
2397 isTopUpdateNeeded: isWhitespace,
2398 });
2399 }
2400
Предыдущие 100 строкСледующие 100 строк