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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-animation-sbs-1.0.js

Код файла
Версия от 05.12.2026, 07:01:09 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
3401	const clips = lists['background-clip'];3402	if (clips[clips.length - 1] === 'text') insertLayers(clips.length, ['none'], 'border-box');3403 3404	const css = Object.keys(lists).reduce(3405		(declarations, cssProp) => `${declarations}${cssProp}:${lists[cssProp].join(', ')} !important;`,3406		''3407	);3408	// в Safari без clone градиент текста, перенесенного на несколько строк, рисуется одним куском на все строки3409	const decorationBreak = textImages.length3410		? '-webkit-box-decoration-break:clone !important;box-decoration-break:clone !important;'3411		: '';
История файла и сравнение версий
  • 05.12.2026, 07:01:09 · 56c3b845
3412 return css + decorationBreak;
3413}
3414
3415/**
3416 * Слои цвета шага для вставки в список слоев фона, см. t_animationSBS__getColorLayersCss
3417 *
3418 * @param {sbsColorTarget} target
3419 * @param {{isBgColorHidden: boolean}} layersInfo - исходные слои фона узла, см. t_animationSBS__getBackgroundLayers
3420 * @returns {{bgImages: string[], textImages: string[]}}
3421 */
3422function t_animationSBS__getStepLayerImages(target, layersInfo) {
3423 const paint = target.paint || {};
3424 const solidLayerColor = `var(${window.t_animationSBS__BG_LAYER_PROP}, transparent)`;
3425 let bgImages = [];
3426 if (paint.bgColor) {
3427 bgImages = t_animationSBS__getPaintLayerImages(paint.bgColor);
3428 } else if (target.hasBgLayer && layersInfo.isBgColorHidden) {
3429 // сплошной слой нужен, только пока исходный фон закрывает background-color, см. t_animationSBS__getBgLayerInfo
3430 bgImages = [`linear-gradient(${solidLayerColor}, ${solidLayerColor})`];
3431 }
3432 const textImages = paint.color ? t_animationSBS__getPaintLayerImages(paint.color) : [];
3433 return { bgImages, textImages };
3434}
3435
3436/**
3437 * Исходные значения списочных свойств фона, развернутые до числа слоев: список короче списка слоев
3438 * повторяется по кругу, и без разворота значения сдвинулись бы относительно слоев после вставки слоев шага
3439 *
3440 * @param {CSSStyleDeclaration} computedStyles
3441 * @param {{images: string[], clips: string[]}} layersInfo - см. t_animationSBS__getBackgroundLayers
3442 * @param {string[]} cssProps
3443 * @returns {Object<string, string[]>}
3444 */
3445function t_animationSBS__getBackgroundLists(computedStyles, layersInfo, cssProps) {
3446 const lists = {};
3447 cssProps.forEach(cssProp => {
3448 if (cssProp === 'background-image') {
3449 lists[cssProp] = layersInfo.images.slice();
3450 } else if (cssProp === 'background-clip' || cssProp === '-webkit-background-clip') {
3451 lists[cssProp] = layersInfo.clips.slice();
3452 } else {
3453 const computedLayers = t_animationSBS__splitBackgroundLayers(computedStyles.getPropertyValue(cssProp));
3454 if (!computedLayers.length) return;
3455 const count = layersInfo.images.length;
3456 lists[cssProp] = Array.from({ length: count }, (item, i) => computedLayers[i % computedLayers.length]);
3457 }
3458 });
3459 return lists;
3460}
3461
3462/**
3463 * Парсит цвет из колорпикера редактора (hex или rgba) или из вычисленных стилей
3464 *
3465 * @param {string | undefined} value
3466 * @returns {sbsRGBA | null}
3467 */
3468function t_animationSBS__parseColor(value) {
3469 if (typeof value !== 'string') return null;
3470 const colorStr = value.trim().toLowerCase();
3471 if (!colorStr) return null;
3472 if (colorStr === 'transparent') return [0, 0, 0, 0];
3473 // цвет глобального стиля из пикера: var(--uc-color-color-<id>,<fallback>), берется fallback
3474 const globalColor = colorStr.match(/^var\(\s*--[\w-]+\s*,(.+)\)$/);
3475 if (globalColor) return t_animationSBS__parseColor(globalColor[1]);
3476
3477 const hex = colorStr.match(/^#([0-9a-f]{3,8})$/);
3478 if (hex) {
3479 let digits = hex[1];
3480 // короткая запись #rgb/#rgba разворачивается до #rrggbb/#rrggbbaa
3481 if (digits.length === 3 || digits.length === 4) digits = digits.replace(/./g, digit => digit + digit);
3482 if (digits.length !== 6 && digits.length !== 8) return null;
3483 const hexColor = [0, 2, 4, 6].map(pos => parseInt(digits.slice(pos, pos + 2), 16));
3484 hexColor[3] = digits.length === 8 ? hexColor[3] / 255 : 1;
3485 return hexColor;
3486 }
3487
3488 const rgb = colorStr.match(/^rgba?\(([^)]+)\)$/);
3489 if (!rgb) return null;
3490 // поддерживается и старый синтаксис rgba(r, g, b, a), и новый rgb(r g b / a), каналы могут быть в процентах
3491 const parts = rgb[1].split(/[\s,/]+/).filter(Boolean);
3492 if (parts.length < 3) return null;
3493 const rgbColor = parts.slice(0, 4).map((part, i) => {
3494 const number = parseFloat(part);
3495 if (!part.includes('%')) return number;
3496 return i === 3 ? number / 100 : (number * 255) / 100;
3497 });
3498 if (rgbColor.length === 3) rgbColor.push(1);
3499 return rgbColor.every(number => !isNaN(number)) ? rgbColor : null;
3500}
Предыдущие 100 строкСледующие 100 строк