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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-animation-sbs-1.0.js

Код файла
Версия от 05.12.2026, 07:01:09 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
1601 * @param {{ease: '' | '0' | 'easeIn' | 'easeOut' | 'easeInOut' | 'bounceFin' | string | undefined}} keyframe - объект keyframe1602 * @returns {string} - декларация animation-timing-function или пустая строка1603 */1604function t_animationSBS__generateKeyframes__getEaseChanges(keyframe) {1605	if (typeof keyframe.ease === 'undefined') return '';1606	const presets = {1607		easeIn: 'ease-in',1608		easeOut: 'ease-out',1609		easeInOut: 'ease-in-out',1610		bounceFin: 'cubic-bezier(0.34,1.61,0.7,1)',1611	};
История файла и сравнение версий
  • 05.12.2026, 07:01:09 · 56c3b845
1612
const ease = String(keyframe.ease).trim();
1613 // linear в редакторе - пустая строка, при публикации пустое значение сохраняется как '0'
1614 const isLinear = ease === '' || ease === '0';
1615 return `animation-timing-function:${isLinear ? 'linear' : presets[ease] || ease};`;
1616}
1617
1618/**
1619 * Собирает css-декларации цветов цели для одного keyframe
1620 *
1621 * @param {sbsColorTarget} target
1622 * @param {{styles: stepStyles}} keyframe - объект keyframe
1623 * @returns {string} - css-декларации
1624 */
1625function t_animationSBS__generateKeyframes__getColorChanges(target, keyframe) {
1626 return target.props.reduce((changes, prop) => {
1627 if (!(prop in keyframe.styles)) return changes;
1628 const value = t_animationSBS__getTargetStepValue(target, keyframe.styles, prop);
1629 return changes + t_animationSBS__generateKeyframes__getColorDeclarations(target, prop, value);
1630 }, '');
1631}
1632
1633/**
1634 * @param {sbsColorTarget} target
1635 * @param {'color' | 'bgColor' | 'fill' | 'stroke'} prop
1636 * @param {sbsRGBA | sbsPaintState | sbsShapeUrlPaint} value - см. t_animationSBS__getTargetStepValue
1637 * @returns {string} - css-декларации значения цвета цели для keyframe
1638 */
1639function t_animationSBS__generateKeyframes__getColorDeclarations(target, prop, value) {
1640 const declarations = t_animationSBS__getTargetColorDeclarations(target, prop, value, false);
1641 return declarations.map(([cssProp, cssValue]) => `${cssProp}:${cssValue};`).join('');
1642}
1643
1644/**
1645 * Градиент фигуры (см. sbsShapeUrlPaint) и цвет между собой не интерполируются: без дополнительного кадра
1646 * браузер переключил бы их в середине шага. Кадр сразу после начала шага ставит значение конца шага только
1647 * тем свойствам, у которых градиент меняется на цвет или обратно, остальные свойства его не замечают
1648 *
1649 * @param {sbsColorTarget} target
1650 * @param {{styles: stepStyles, percent: number}} keyframe - keyframe начала шага
1651 * @param {{styles: stepStyles, percent: number} | undefined} nextKeyframe - keyframe конца шага
1652 * @returns {string} - keyframe переключения или ''
1653 */
1654function t_animationSBS__generateKeyframes__getShapeSwitchFrame(target, keyframe, nextKeyframe) {
1655 if (!target.shapeSelectors || !nextKeyframe) return '';
1656 // проценты keyframes округлены до сотых, см. t_animationSBS__generateKeyframes__countPercent
1657 const switchPercent = parseFloat((keyframe.percent + 0.01).toFixed(2));
1658 if (switchPercent >= nextKeyframe.percent) return '';
1659
1660 const changes = target.props.reduce((str, prop) => {
1661 if (!(prop in keyframe.styles) || !(prop in nextKeyframe.styles)) return str;
1662 const from = t_animationSBS__getTargetStepValue(target, keyframe.styles, prop);
1663 const to = t_animationSBS__getTargetStepValue(target, nextKeyframe.styles, prop);
1664 if (t_animationSBS__isShapeUrlPaint(from) === t_animationSBS__isShapeUrlPaint(to)) return str;
1665 return str + t_animationSBS__generateKeyframes__getColorDeclarations(target, prop, to);
1666 }, '');
1667 return changes ? `${switchPercent}% {${changes}}\n` : '';
1668}
1669
1670/**
1671 * Анимация цвета задается узлам атома внутри wrapperEl, поэтому для каждого узла
1672 * генерируем отдельные @keyframes с теми же процентами и easing, что и у wrapperEl.
1673 * Имя анимации заканчивается на t_animationSBS__COLOR_ANIM_SUFFIX + индекс, см. t_animationSBS__isColorAnimationEvent
1674 *
1675 * @param {AnimatedHTML} el - текущий элемент
1676 * @param {{
1677 * styles: stepStyles,
1678 * ease: '' | 'easeIn' | 'easeOut' | 'easeInOut' | 'bounceFin' | undefined,
1679 * percent: number | undefined
1680 * }[]} keyframes - массив keyframes основной анимации
1681 * @param {{timeDuration:number}} keyframesOpts - опции
1682 * @returns {string} - css
1683 */
1684function t_animationSBS__generateKeyframes__getColorsCss(el, keyframes, keyframesOpts) {
1685 // keyframe без процента пропущен в t_animationSBS__generateKeyframes__countPercent, как и в основной анимации
1686 const percentKeyframes = keyframes.filter(keyframe => typeof keyframe.percent === 'number');
1687 return t_animationSBS__getColorAnimTargets(el).reduce((css, target, i) => {
1688 const keyframesStr = percentKeyframes.reduce((str, keyframe, j) => {
1689 const changes = t_animationSBS__generateKeyframes__getColorChanges(target, keyframe);
1690 const ease = t_animationSBS__generateKeyframes__getEaseChanges(keyframe);
1691 const switchFrame = t_animationSBS__generateKeyframes__getShapeSwitchFrame(
1692 target,
1693 keyframe,
1694 percentKeyframes[j + 1]
1695 );
1696 return `${str}${keyframe.percent}% {${changes}${ease}}\n${switchFrame}`;
1697 }, '');
1698 const colorAnimOpts = {
1699 selector: t_animationSBS__getColorTargetSelector(el, target, false),
1700 nameSuffix: `${window.t_animationSBS__COLOR_ANIM_SUFFIX}${i}`,
Предыдущие 100 строкСледующие 100 строк