Каталог файловtilda-animation-sbs-1.0.js
3101 * @param {sbsColorTarget} target3102 * @param {'color' | 'bgColor' | 'fill' | 'stroke'} prop3103 * @param {sbsRGBA | sbsPaintState | sbsShapeUrlPaint} value - см. t_animationSBS__getTargetStepValue3104 * @param {boolean} isScroll3105 * @returns {string[][]} - пары [свойство, значение]3106 */3107function t_animationSBS__getTargetColorDeclarations(target, prop, value, isScroll) {3108 const paintMeta = target.paint && target.paint[prop];3109 if (paintMeta) return t_animationSBS__getPaintDeclarations(paintMeta, value);3110 // обводки на стопах в props группы нет, см. t_animationSBS__collectShapeColorTargets3111
История файла и сравнение версий
if (t_animationSBS__isShapeOnStops(target, prop)) return isScroll ? [] : [['fill-opacity', '1']];
3112 const cssProp = isScroll 3113 ? t_animationSBS__getScrollColorCssProp(target, prop) 3114 : t_animationSBS__getColorCssProp(target, prop); 3115 if (target.gradientStops) { 3116 const declarations = [[cssProp, t_animationSBS__stringifyColor(value)]]; 3117 if (!isScroll) declarations.push(['stop-opacity', '1']); 3118 return declarations; 3120 if (!target.shapeSelectors) return [[cssProp, t_animationSBS__stringifyColor(value)]]; 3122 const declarations = [[cssProp, t_animationSBS__stringifyShapePaint(value)]]; 3123 if (prop !== 'fill') return declarations; 3124 // у цвета fill-opacity фигуры уже учтен в нем самом (см. t_animationSBS__getShapeBaseFill), у градиента - собственная 3125 const fillOpacity = String(t_animationSBS__getShapeFillOpacity(value)); 3126 const opacityProp = isScroll ? t_animationSBS__getShapeScrollFillOpacityVar(target) : 'fill-opacity'; 3127 if (opacityProp) declarations.push([opacityProp, fillOpacity]); 3128 return declarations; 3132 * Ставит инлайн-стиль и сохраняет прежнее инлайн-значение, чтобы потом его восстановить 3134 * @param {HTMLElement} node 3135 * @param {string} cssProp 3136 * @param {string} value 3138function t_animationSBS__setInlineStyleWithBackup(node, cssProp, value) { 3139 if (!node.sbsInlineStylesBackup) node.sbsInlineStylesBackup = {}; 3140 if (!(cssProp in node.sbsInlineStylesBackup)) { 3141 node.sbsInlineStylesBackup[cssProp] = { 3142 value: node.style.getPropertyValue(cssProp), 3143 priority: node.style.getPropertyPriority(cssProp), 3146 node.style.setProperty(cssProp, value); 3150 * Возвращает инлайн-стили, сохраненные в t_animationSBS__setInlineStyleWithBackup 3152 * @param {HTMLElement} node 3154function t_animationSBS__restoreInlineStyles(node) { 3155 if (!node.sbsInlineStylesBackup) return; 3156 Object.keys(node.sbsInlineStylesBackup).forEach(cssProp => { 3157 const { value, priority } = node.sbsInlineStylesBackup[cssProp]; 3159 node.style.setProperty(cssProp, value, priority); 3161 node.style.removeProperty(cssProp); 3164 delete node.sbsInlineStylesBackup; 3168 * Регистрирует переменную слоя цвета фона, чтобы браузер плавно интерполировал ее в keyframes. 3169 * Без поддержки @property переменная меняется скачком, а слой остается валидным за счет fallback в var() 3171function t_animationSBS__registerBgColorProperty() { 3172 if (window.t_animationSBS__isBgColorPropertyRegistered) return; 3173 window.t_animationSBS__isBgColorPropertyRegistered = true; 3174 if (!window.CSS || typeof CSS.registerProperty !== 'function') return; 3176 CSS.registerProperty({ 3177 name: window.t_animationSBS__BG_LAYER_PROP, 3180 initialValue: 'transparent', 3183 // свойство уже зарегистрировано другой копией скрипта 3188 * Делит значение css-списка (background-image, background-clip и т.д.) на слои по запятым верхнего уровня. 3189 * Простой split(',') не подходит: запятые есть внутри градиентов, rgba() и url() 3191 * @param {string} value 3192 * @returns {string[]} 3194function t_animationSBS__splitBackgroundLayers(value) { 3196 // глубина вложенности скобок и открытая кавычка: запятая внутри них не разделяет слои 3200 for (const char of value) {