Каталог файловtilda-animation-sbs-1.0.js
2801function t_animationSBS__getShapeFillOpacity(value) {2802 return t_animationSBS__isShapeUrlPaint(value) ? value.fillOpacity : 1;2803}2804 2805/**2806 * @param {sbsColorTarget} target2807 * @param {'color' | 'bgColor' | 'fill' | 'stroke'} prop2808 * @returns {boolean} - свойство группы фигур остается на градиенте, цвет шага рисуют стопы, см. sbsShapeUrlPaint2809 */2810function t_animationSBS__isShapeOnStops(target, prop) {2811 // url(...) бывает только в base группы фигур2812
История файла и сравнение версий
const base = target.base[prop];
2813 return t_animationSBS__isShapeUrlPaint(base) && Boolean(base.onStops); 2817 * Переменная fill-opacity группы фигур на wrapperEl при анимации по скроллу. Нужна только группе с градиентной 2818 * заливкой с мгновенным переключением: у остальных fill-opacity всегда 1, см. t_animationSBS__setShapeScrollColorRule 2820 * @param {sbsColorTarget} target 2821 * @returns {string} - имя переменной или '', если переменная не нужна 2823function t_animationSBS__getShapeScrollFillOpacityVar(target) { 2824 const base = target.base.fill; 2825 if (!t_animationSBS__isShapeUrlPaint(base) || base.onStops) return ''; 2826 return `--t-sbs-fill-opacity-${target.shapeGroup}`; 2830 * Селектор фигуры от атома по :nth-child. Теги не используются: у svg-элементов они чувствительны к регистру 2832 * @param {HTMLElement} root - .tn-atom вектора 2833 * @param {Element} node - фигура 2834 * @returns {string} - селектор вида '> :nth-child(1) > :nth-child(3)' 2836function t_animationSBS__getShapePathSelector(root, node) { 2837 const selectors = []; 2838 for (let current = node; current && current !== root; current = current.parentElement) { 2839 const index = Array.prototype.indexOf.call(current.parentElement.children, current) + 1; 2840 selectors.unshift(`:nth-child(${index})`); 2842 return `> ${selectors.join(' > ')}`; 2846 * При анимации по скроллу цвет фигур нельзя поставить инлайном, как у других целей: разметка svg сохраняется 2847 * в редакторе. Поэтому скрипт ставит на wrapperEl переменные цвета групп, а фигурам задается правило 2848 * с этими переменными, стопам градиентов - так же через stop-color. !important нужен, чтобы перебить инлайн-стили 2849 * фигур загруженного svg. 2850 * В редакторе правило отдается вместе с keyframes в t_animationSBS__generateKeyframes, как и слой фона 2852 * @param {AnimatedHTML} animatedHTML 2853 * @param {boolean} isEditMode 2855function t_animationSBS__setShapeScrollColorRule(animatedHTML, isEditMode) { 2856 if (animatedHTML.animType !== 'scroll') return; 2857 const css = animatedHTML.colorTargets.reduce((rules, target) => { 2858 if (!target.shapeSelectors) return rules; 2859 const selector = target.shapeSelectors.map(shapeSelector => `#${animatedHTML.uniqueID} ${shapeSelector}`); 2860 const declarations = target.props.map(prop => { 2861 const variable = t_animationSBS__getScrollColorCssProp(target, prop); 2862 const base = target.base[prop]; 2863 // у стопов stop-opacity уже учтена в их цвете, см. t_animationSBS__getStopBaseColor 2864 if (target.gradientStops) { 2865 return `stop-color:var(${variable}, ${t_animationSBS__stringifyColor(base)}) !important;stop-opacity:1 !important;`; 2867 // заливка остается на градиенте, ее fill-opacity учтена в стопах, см. t_animationSBS__getSmoothGradients. 2868 // Обводки на стопах в props группы нет, см. t_animationSBS__collectShapeColorTargets 2869 if (t_animationSBS__isShapeOnStops(target, prop)) return 'fill-opacity:1 !important;'; 2870 let fillOpacity = ''; 2871 if (prop === 'fill') { 2872 // у цвета fill-opacity фигуры уже учтен в нем самом, см. t_animationSBS__getShapeBaseFill, 2873 // у градиента fill-opacity меняется вместе с заливкой через свою переменную 2874 const opacityVar = t_animationSBS__getShapeScrollFillOpacityVar(target); 2875 const opacity = t_animationSBS__getShapeFillOpacity(base); 2876 fillOpacity = `fill-opacity:${opacityVar ? `var(${opacityVar}, ${opacity})` : opacity} !important;`; 2878 return `${prop}:var(${variable}, ${t_animationSBS__stringifyShapePaint(base)}) !important;${fillOpacity}`; 2880 return `${rules}${selector.join(',')} {${declarations.join('')}}\n\n`; 2885 animatedHTML.sbsShapeColorCss = css; 2888 const styleEl = document.createElement('style'); 2889 styleEl.classList.add('sbs-anim-shape-colors'); 2890 styleEl.textContent = css; 2891 document.head.appendChild(styleEl); 2892 animatedHTML.sbsShapeColorStyle = styleEl; 2896 * Css-свойство, которое ставится инлайном при анимации по скроллу. У группы фигур вектора - переменная 2897 * группы на wrapperEl, у группы стопов градиентов - переменная stop-color группы, см. t_animationSBS__setShapeScrollColorRule 2899 * @param {sbsColorTarget} target 2900 * @param {'color' | 'bgColor' | 'fill' | 'stroke'} prop