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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-animation-sbs-1.0.js

Код файла
Версия от 05.12.2026, 07:01:09 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
3801		const stepGeometry = {};3802		kinds.forEach(kind => {3803			stepGeometry[kind] = getNearestGeometry(i, kind);3804		});3805		geometry.set(step.styles, stepGeometry);3806	});3807 3808	return {3809		varPrefix: prop === 'bgColor' ? 'bg' : 'cl',3810		kinds,3811		varIds,3812		stops,
История файла и сравнение версий
  • 05.12.2026, 07:01:09 · 56c3b845
3813
solidKind: ['linear', 'conic'].find(kind => kinds.includes(kind)) || kinds[0],
3814 geometry,
3815 baseGeometry: geometry.get(animatedHTML.steps[0].styles),
3816 baseColor: undefined,
3817 };
3818}
3819
3820/**
3821 * Значения слоев свойства в режиме градиента на шаге. Слои, которых нет у цвета шага, прозрачные.
3822 * У color на шаге с цветом css-цвет текста прозрачный - текст рисует слой, на шаге без цвета - собственный цвет текста
3823 *
3824 * @param {sbsColorTarget} target
3825 * @param {stepStyles | null} styles - стили шага, null - исходный вид узла (шаг 0)
3826 * @param {'color' | 'bgColor'} prop
3827 * @returns {sbsPaintState}
3828 */
3829function t_animationSBS__getTargetStepPaint(target, styles, prop) {
3830 const meta = target.paint[prop];
3831 const value = styles ? styles[prop] : null;
3832 const geometry = (styles && meta.geometry.get(styles)) || meta.baseGeometry;
3833 const isGradient = t_animationSBS__isGradientPaint(value);
3834 const transparent = [0, 0, 0, 0];
3835 const state = {};
3836
3837 meta.kinds.forEach(kind => {
3838 const count = meta.stops[kind];
3839 let colors = Array.from({ length: count }, () => transparent);
3840 if (isGradient && value.kind === kind) {
3841 colors = t_animationSBS__normalizeStops(value.stops, count).map(stop => stop.color);
3842 } else if (value && !isGradient && meta.solidKind === kind) {
3843 colors = Array.from({ length: count }, () => value);
3844 }
3845 state[kind] = Object.assign({}, geometry[kind], { colors });
3846 });
3847 if (prop === 'color') state.color = value ? transparent : meta.baseColor;
3848 return state;
3849}
3850
3851/**
3852 * Смешивает значения слоев так же, как t_animationSBS__mixColors цвета: для анимации по скроллу
3853 *
3854 * @param {sbsPaintState} from
3855 * @param {sbsPaintState} to
3856 * @param {number} percentage - доля смешивания от 0 до 1
3857 * @returns {sbsPaintState}
3858 */
3859function t_animationSBS__mixPaint(from, to, percentage) {
3860 const mixNumber = (fromNumber, toNumber) => fromNumber + percentage * (toNumber - fromNumber);
3861 const mixLength = (fromLength, toLength) => {
3862 return { p: mixNumber(fromLength.p, toLength.p), x: mixNumber(fromLength.x, toLength.x) };
3863 };
3864 const state = {};
3865 Object.keys(to).forEach(kind => {
3866 if (kind === 'color') {
3867 state.color = t_animationSBS__mixColors(from.color, to.color, percentage);
3868 return;
3869 }
3870 const fromLayer = from[kind];
3871 const toLayer = to[kind];
3872 state[kind] = {
3873 colors: toLayer.colors.map((color, i) => t_animationSBS__mixColors(fromLayer.colors[i], color, percentage)),
3874 positions: toLayer.positions.map((pos, i) => mixNumber(fromLayer.positions[i], pos)),
3875 };
3876 if (toLayer.angle !== undefined) state[kind].angle = mixNumber(fromLayer.angle, toLayer.angle);
3877 if (toLayer.center) {
3878 state[kind].center = {
3879 x: mixLength(fromLayer.center.x, toLayer.center.x),
3880 y: mixLength(fromLayer.center.y, toLayer.center.y),
3881 };
3882 }
3883 if (toLayer.size) {
3884 state[kind].size = {
3885 w: mixLength(fromLayer.size.w, toLayer.size.w),
3886 h: mixLength(fromLayer.size.h, toLayer.size.h),
3887 };
3888 }
3889 });
3890 return state;
3891}
3892
3893/**
3894 * Css-декларации значений слоев: переменные слоев и, у color, css-цвет текста.
3895 * Ставятся в keyframes, а при анимации по скроллу - инлайном на узел
3896 *
3897 * @param {sbsPaintMeta} meta
3898 * @param {sbsPaintState} state
3899 * @returns {string[][]} - пары [свойство, значение]
3900 */
Предыдущие 100 строкСледующие 100 строк